cs/Practical File/outputs/question_11_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

30 lines
958 B
Plaintext

Question 11:
Write a Python program to check whether a given character is a vowel or consonant.
Answer:
def main(char: str) -> None:
vowels = 'aeiou'
if char.lower() in vowels:
print(f"{char} is a vowel.")
elif char.isalpha():
print(f"{char} is a consonant.")
else:
raise ValueError("Invalid input. Please enter an alphabetic character.")
if __name__ == '__main__':
main('a')
main('b')
main('A')
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_11.py", line 17, in <module>
main('1') # also works with a int
^^^^^^^^^
File "\\homeassistant.local\share\data\school\Grade 11 CS\Practical File\question_11.py", line 10, in main
raise ValueError("Invalid input. Please enter an alphabetic character.")
ValueError: Invalid input. Please enter an alphabetic character.