Python Programming
Topic of the Week: String Functions + print()
Instructor: Ms. Sadia Zulfiqar
1. upper() / lower()
Use a simple string:
s = "Hello World"
print([Link]())
print([Link]())
Output:
HELLO WORLD
hello world
2. strip() (remove spaces)
s = " hello "
print([Link]())
Output:
hello
3. replace()
print([Link]("World", "Python"))
Output:
Hello Python
4. split()
print([Link]())
Output:
['Hello', 'World']
5. find()
print([Link]("World"))
Output:
index position
6. count()
print([Link]("l"))
Output:
3
7. startswith() / endswith()
print([Link]("Hello"))
print([Link]("World"))
Output:
True
True
8. len()
print(len(s))
11
print() Function Parameters
print("A", "B", "C")
Output:
ABC
1. sep (separator)
print("A", "B", "C", sep="-")
Output:
A-B-C
2. end (what comes at end)
print("Hello", end=" ")
print("World")
Output:
Hello World
3. Combine both
print("2026", "04", "21", sep="/", end=" DONE")
Output:
2026/04/21 DONE
Simple input() example (connect with strings)
name = input("Enter your name: ")
print("Hello", name)
Strings are immutable
replace() does not change original string
split() → gives list
print() has sep and end
Part 1: Short Coding Tasks
Task 7 – Print with Separator Task 10 – Reverse
Task 1 – Name Input Task 4 – Split Input
String
Take user name and print:
Print:
Input:
Take input and print reverse
Hello Ali 2026-04-21
apple,banana,mango
Task 2 – Uppercase + Length (using sep)
Convert into list
Take a sentence and:
Task 5 – Count Character
Task 8 – Print in One Line
● convert to uppercase
● print its length Take a word and count how Print:
many times ‘a’ appears
Task 3 – Replace Word Hello World Python
Input: Task 6 – Remove Spaces (using end)
I like Java Input:
Task 9– Check Start/End
Replace Java → Python " Python "
Take input and check:
Remove extra spaces
● starts with “A”
● ends with “z”