Exercise
Conditional Symbols
Objective
Develop a Python program to prompt the user for a symbol and respond if it's an uppercase vowel, a lowercase vowel, a digit, or any other symbol, using "if".
Example Python Exercise
Show Python Code
# Prompt the user for a symbol
symbol = input("Enter a symbol: ")
# Check if the symbol is an uppercase vowel
if symbol in 'AEIOU':
print("It's an uppercase vowel.")
# Check if the symbol is a lowercase vowel
elif symbol in 'aeiou':
print("It's a lowercase vowel.")
# Check if the symbol is a digit
elif symbol.isdigit():
print("It's a digit.")
# If it's neither an uppercase vowel, lowercase vowel, nor a digit, it's another symbol
else:
print("It's another symbol.")
Output
Case 1:
Enter a symbol: A
It's an uppercase vowel.
Case 2:
Enter a symbol: b
It's a lowercase vowel.
Case 3:
Enter a symbol: 5
It's a digit.
Case 4:
Enter a symbol: #
It's another symbol.
Share this Python Exercise