Remember
lower() returns a lowercase version using Unicode case rules. The source string remains unchanged.
lower() returns a lowercase version using Unicode case rules. The source string remains unchanged.
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 = 'HELLO'
result = text.lower()
print(result)Top-level scope
'HELLO'Object 2 · str'hello'lower() returns a lowercase version using Unicode case rules. The source string remains unchanged.
(no output)
What do you expect this program to print?
EXAMPLE INSTRUCTIONS
text = 'HELLO'
result = text.lower()
print(result)
|
v
DISPLAYED RESULT
hello
FINAL BINDINGS
text --> object 1 (str)
result --> object 2 (str)
object 1: 'HELLO'
object 2: 'hello'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 = 'HELLO'
result = text.lower()
print(result)Top-level scope
'HELLO'Object 2 · str'hello'The example has finished. Compare the final output with the values and references above.
hello
What do you expect this program to print?
text = 'HELLO'
result = text.lower()
print(result)lower() MethodThe lower() method in Python is used to convert all the characters in a string to lowercase. It's useful when comparing strings or working with user input where case sensitivity doesn't matter.
string.lower()
text = "HELLO WORLD"
print(text.lower())
hello world
greeting = "GoOd MoRnInG"
print(greeting.lower())
good morning
a = "Python"
b = "PYTHON"
print(a.lower() == b.lower())
True
Even though the original strings differ in case, they are equal after using lower().
No, strings in Python are immutable. The lower() method returns a new string — it doesn’t modify the original one.
name = "ALICE"
name.lower()
print(name)
ALICE
Why? Because name.lower() returns a new string, but it wasn't assigned back to name.
name = name.lower()
print(name)
lower() converts a string to lowercase.Ask the user to input a sentence and print it in lowercase.
text = input("Enter a sentence: ")
print("In lowercase:", text.lower())
Connect what you noticed in the example with the idea below.
lower() returns a lowercase version using Unicode case rules. The source string remains unchanged.
lower() changes the source string in place.
This is the misconception to avoid.Reference checks are optional and do not count toward course progress.