Remember
isupper() requires at least one cased character and checks that all cased characters are uppercase.
isupper() requires at least one cased character and checks that all cased characters are uppercase.
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 = 'TEA42'
result = text.isupper()
print(result)Top-level scope
'TEA42'Object 2 · boolTrueisupper() requires at least one cased character and checks that all cased characters are uppercase.
(no output)
What do you expect this program to print?
EXAMPLE INSTRUCTIONS
text = 'TEA42'
result = text.isupper()
print(result)
|
v
DISPLAYED RESULT
True
FINAL BINDINGS
text --> object 1 (str)
result --> object 2 (bool)
object 1: 'TEA42'
object 2: TrueChoose 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 = 'TEA42'
result = text.isupper()
print(result)Top-level scope
'TEA42'Object 2 · boolTrueThe example has finished. Compare the final output with the values and references above.
True
What do you expect this program to print?
text = 'TEA42'
result = text.isupper()
print(result)isupper() MethodThe isupper() method in Python is used to check if all the alphabetic characters in a string are uppercase. It’s one of the most useful string-checking methods when validating text inputs.
string.isupper()
True – If all cased characters in the string are uppercase.False – If there is at least one lowercase letter, or no cased characters at all.text = "HELLO"
print(text.isupper())
True
text = "WELCOME123!"
print(text.isupper())
True
Numbers and symbols are ignored; only alphabetic characters are considered.
text = "Hello"
print(text.isupper())
False
text = "12345!@#"
print(text.isupper())
False
If there are no alphabetic characters, isupper() returns False.
This method is often used when you want to ensure user input is in all capital letters – such as license plates, codes, or acronyms.
code = input("Enter secret code in uppercase: ")
if code.isupper():
print("Valid code.")
else:
print("Code must be in uppercase!")
isupper() will convert the string – it only checks, it does not change anything.isupper() is commonly used in data validation or parsing logic where case sensitivity matters, such as password rules or form validations.
isupper() checks if all letters in a string are uppercase.False if there are no letters at all.Write a Python program that asks the user to enter their name and prints a warning if the name is not in uppercase.
name = input("Enter your name in UPPERCASE: ")
if name.isupper():
print("Thank you!")
else:
print("Please enter your name in all uppercase.")
Connect what you noticed in the example with the idea below.
isupper() requires at least one cased character and checks that all cased characters are uppercase.
isupper() returns True for text containing only punctuation.
This is the misconception to avoid.Reference checks are optional and do not count toward course progress.