0
0
Pythonprogramming~20 mins

String validation checks in Python - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
๐ŸŽ–๏ธ
String Validation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
โ“ Predict Output
intermediate
2:00remaining
Output of string isalnum() method
What is the output of this Python code snippet?
Python
s = "Hello123"
print(s.isalnum())
ATrue
BFalse
CSyntaxError
DTypeError
Attempts:
2 left
๐Ÿ’ก Hint
isalnum() returns True if all characters are letters or digits and string is not empty.
โ“ Predict Output
intermediate
2:00remaining
Output of string isdigit() with spaces
What will this code print?
Python
s = "123 456"
print(s.isdigit())
AFalse
BTrue
CSyntaxError
DTypeError
Attempts:
2 left
๐Ÿ’ก Hint
Spaces are not digits.
โ“ Predict Output
advanced
2:00remaining
Result of islower() on mixed case string
What does this code output?
Python
s = "helloWorld"
print(s.islower())
ATrue
BSyntaxError
CTypeError
DFalse
Attempts:
2 left
๐Ÿ’ก Hint
islower() returns True only if all letters are lowercase and there is at least one letter.
โ“ Predict Output
advanced
2:00remaining
Output of isspace() with newline character
What will this code print?
Python
s = "\n"
print(s.isspace())
AFalse
BTrue
CSyntaxError
DTypeError
Attempts:
2 left
๐Ÿ’ก Hint
isspace() returns True if all characters are whitespace characters.
โ“ Predict Output
expert
3:00remaining
Output of complex string validation expression
What is the output of this code?
Python
s = "Python3"
result = s.isalpha() or s.isalnum() and not s.isdigit()
print(result)
AFalse
BSyntaxError
CTrue
DTypeError
Attempts:
2 left
๐Ÿ’ก Hint
Remember operator precedence: 'and' before 'or'.