PS: Please use Python do the coding. And Please just show me the code. Write a p
ID: 3786292 • Letter: P
Question
PS: Please use Python do the coding. And Please just show me the code.
Write a program that asks the user for a letter. The program should then determine if the letter is a vowel or not. In this homework you will, of course, be writing functions to perform the individual components of the program. For this assignment, you should have the following functions: First function: AskForLetter(): This function will repeatly as the user for a single letter until the user types 'quit' to exit the program or they have entered a vowel. This function will use the built-in python function called len. len is used to determine the length of an input. For example, if the input from the user is 'i', len('i') will return 1. Try this in python interpreter. If the len of the user input is 1, then this function should call the second function below. Finally this function outputs the input letter if it is a vowel. Second function: IsVowel(letter): This function will take as input a variable called letter and will determine if this letter is a vowel or not. If it is a vowel it will return it will return False. To determine if letter is vowel or not, this function will call a third and a fourth function below. Third function: IsLowercaseVowel(letter): this function will take a single variable as input called letter and will return True if the letter is an lowercase vowel. Fourth function: IsUppercaseVowel(letter): this function will take a single variable as input called letter and will return True if the letter is an uppercase vowel. Make sure you account for user input error. Test your code by trying to cause errors in input.Explanation / Answer
def AskForLetter():
ch = input("Enter the letter(quit to exit): ")
while ch != "quit":
if isVowel(ch):
print("Given letter is vowel")
else:
print("Given letter is not vowel")
ch = input("Enter the letter(quit to exit): ")
def isVowel(letter):
s = "aeiouAEIOU"
if letter in s:
if isLowerCaseVowel(letter):
print("Vowel is lowercase")
if isUpperCaseVowel(letter):
print("Vowel is uppercase")
return True
else:
return False;
def isLowerCaseVowel(letter):
s = "aeiou"
if letter in s:
return True
else:
return False
def isUpperCaseVowel(letter):
s = "AEIOU"
if letter in s:
return True
else:
return False
AskForLetter();
Output:
sh-4.3$ python3 main.py
sh-4.3$ python3 main.py
sh-4.3$ python3 main.py
Enter the letter(quit to exit): a
Vowel is lowercase
Given letter is vowel
Enter the letter(quit to exit): E
Vowel is uppercase
Given letter is vowel
Enter the letter(quit to exit): Q
Given letter is not vowel
Enter the letter(quit to exit): quit
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.