Remember
upper() returns a Unicode uppercase version. Some characters can expand into more than one character.
upper() returns a Unicode uppercase version. Some characters can expand into more than one character.
Follow the example, change its sample, and compare what happens.
Explain the result and test your understanding.
Focus on how the names, objects, and calculations change. We’ll inspect the printed output in the next section.
Follow the code and watch its state change. Guided simulation.
text = 'tea'
result = text.upper()
print(result)Top-level scope
'tea'Object 2 · str'TEA'upper() returns a Unicode uppercase version. Some characters can expand into more than one character.
(no output)
What do you expect this program to print?
EXAMPLE INSTRUCTIONS
text = 'tea'
result = text.upper()
print(result)
|
v
DISPLAYED RESULT
TEA
FINAL BINDINGS
text --> object 1 (str)
result --> object 2 (str)
object 1: 'tea'
object 2: 'TEA'Choose a different sample input, then follow every step through to the output. Before revealing it, predict what the program will display.
Choose a sample and follow its execution. Guided simulation.
text = 'tea'
result = text.upper()
print(result)Top-level scope
'tea'Object 2 · str'TEA'The example has finished. Compare the final output with the values and references above.
TEA
What do you expect this program to print?
text = 'tea'
result = text.upper()
print(result)upper() MethodThe upper() method in Python converts all lowercase characters in a string to uppercase. It is a built-in string method and is very useful when you want to standardize or compare text.
string.upper()
text = "hello world"
print(text.upper())
HELLO WORLD
name = "Alice123"
print(name.upper())
ALICE123
Note: Numbers and symbols remain unchanged.
No. Strings in Python are immutable. upper() returns a new string — it does not modify the original.
word = "python"
new_word = word.upper()
print(word) # python
print(new_word) # PYTHON
upper without parentheses – remember it’s a method: string.upper()In coding tests, upper() is handy for making string comparisons or normalizing data without worrying about the input case.
upper() converts all characters in a string to uppercase.Write a program that asks the user to enter their name and prints it in all capital letters.
name = input("Enter your name: ")
print("Your name in uppercase is:", name.upper())
Connect what you noticed in the example with the idea below.
upper() returns a Unicode uppercase version. Some characters can expand into more than one character.
upper() always preserves the exact number of characters.
This is the misconception to avoid.Reference checks are optional and do not count toward course progress.