BBampaa

Lessons › Python

Python lesson

Text

+ joins strings end to end, so we add a space in the middle ourselves. .upper() gives back a copy in capital letters.

Try this lesson free →
About 5–10 minutes · no sign-up needed

Example

Text in Python is called a string. You can store it, join pieces with +, and change its case:

first = "Ada"
last = "Obi"
full = first + " " + last
print(full)
print(full.upper())

Output:

Ada Obi
ADA OBI

Key points

"Ada" + " " + "Obi"+ joins text together. Add the space yourself.
.upper() .lower()Change text to all capitals, or all lower case.
"35" + "5"Numbers in quotes are text: this gives 355, not 40.

Put together: full = first + " " + last, then full.upper().

Practice

Try each one in your head first, then open the answer.

1. Build a line that joins first and last, with a space between, into full.
full = first + " " + last
2. Build a line that shows city in capitals.
print(city.upper())
3. Join "Phone" and "case" with a space into a variable called product, then print it.
product = "Phone" + " " + "case"
print(product)
4. store holds abuja. Print it in capital letters.
store = "abuja"
print(store.upper())
5. Print the text Order: followed by the id in oid, so it reads Order: O101
oid = "O101"
print("Order: " + oid)

Learn it by doing. This lesson is a short hands-on level on Bampaa: see it work, then build and write it yourself, with instant feedback.

Try this lesson free →
About 5–10 minutes · no sign-up needed