Explanation:
Step 1: Understanding the String
"2026"
"2026" is a string because it is enclosed within double quotes.
Although it contains numbers, Python treats it as text (str type).
Step 2: Understanding isdigit()
"2026".isdigit()
isdigit() is a string method.
It checks whether all characters in the string are numeric digits (0–9).
If all characters are digits, it returns True.
Otherwise, it returns False.
Step 3: Evaluating the Condition
Python checks each character in "2026":
2 → Digit ✔
0 → Digit ✔
2 → Digit ✔
6 → Digit ✔
Since every character is a digit, the method returns:
True
Step 4: Understanding print()
print(True)
The print() function displays the result on the screen.
Since isdigit() returned True, print() outputs True.
Output
True

0 Comments:
Post a Comment