cs/Practical File/outputs/question_14_output.txt
Neil Revin 780baf678e
chore: move question & output files
Move python question files to 'questions' directory
Move output files to 'outputs' directory
Copy output files to 'questions' for ease of viewing

Signed-off-by: Neil <neil@willofsteel.me>
2025-06-24 02:34:07 +05:30

28 lines
954 B
Plaintext

Question 14:
Write a Python program to check if a character is an uppercase or lowercase letter.
Answer:
def main(char: str) -> None:
if char.isupper():
print(f"{char} is an uppercase letter.")
elif char.islower():
print(f"{char} is a lowercase letter.")
else:
raise ValueError("Invalid input. Please enter an alphabetic character.")
if __name__ == '__main__':
main('A')
main('a')
main('B')
main('b')
main('1') # also works with a int
Output:
Traceback (most recent call last):
File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 16, in <module>
main('1') # also works with a int
^^^^^^^^^
File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_14.py", line 9, in main
raise ValueError("Invalid input. Please enter an alphabetic character.")
ValueError: Invalid input. Please enter an alphabetic character.