1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Flura [38]
2 years ago
10

Write a Python function LetterGame() that repeatedly asks the user to input a letter. The function is to count the number of vow

els the user entered. The function should stop if the user enters a digit (0-9). a) Use a while-loop and in the while loop ask the user to input a letter or to input a digit to stop. b) Check if the user entered a vowel (if command is your friend) c) If the user entered a vowel increase the counter by one d) If the user entered a digit, output the number of letters the user entered and the number and percentage of vowels among them. e) Call the function. Expected output: You entered 10 letters, 2 of which were vowels. The percentage of vowels was 20%.
Computers and Technology
1 answer:
kotegsom [21]2 years ago
4 0

Answer:

def LetterGame():

   vowels = ["a", "e", "i", "o", "u", "A", "E", "I", "O", "U"]

   count1 = count2 = 0

   while True:

       choice = input("Enter a letter / digit to stop: ")

       if choice.isdigit():

           break

       elif choice.isalpha():

           count1 += 1

           if choice in vowels:

               count2 += 1

   print("You entered " + str(count1) + " letters, " + str(count2) + " of which weere vowels.")

   print("The percentage of vowels was " + str(count2 / count1 * 100) + "%")

LetterGame()

Explanation:

Create a function called LetterGame

Inside the function:

Create a list of vowels

Initialize count1, counts the total letters, and count2, counts the vowels

Initialize a while loop that iterates until the specified condition is met in the loop

Get the input from the user. If it is a digit, stop the loop. If it is an alphabet, increase the count1 by 1, and also check if it is a vowel. If it is a vowel, increment the count2 by 1

When the loop is done, print the required information

Finally, call the function

You might be interested in
Where does the oracle11g server store information about objects in the database, including information about constraints?
tiny-mole [99]
The oracle11g server stores information about objects in the database, including information about constraints in the tables.  <span>An </span>Oracle database is a set of files that store Oracle data in persistent disk storage.<span>A database </span>instance<span> is a set of memory structures that manage database files</span>.
4 0
3 years ago
Sorry but, what are brainliest for?
Advocard [28]

Answer:

smartest and accurate answer

Explanation:

5 0
3 years ago
Read 2 more answers
!!! 20 points !!!!!
puteri [66]

Answer: I need more info to answer this question

Explanation:

8 0
1 year ago
What is the name of the variable in this code?
nata0808 [166]

Answer:

fav_color

Explanation:

4 0
2 years ago
Read 2 more answers
Rapunzel s-a născut într-un ţinut îndepărtat într-un regat necunoscut. Mama vitregă a închis-o pe Rapunzel într-un turn foarte î
andrey2020 [161]
Iche hebie zaft no guts dude
5 0
3 years ago
Other questions:
  • Which computer port transmits audio and video without the need for compression?
    6·1 answer
  • Which is true about POP3 and IMAP for incoming email?
    6·1 answer
  • Plz tell me a storage device that should be used for this and why
    11·1 answer
  • _____ allow(s) a user to double click with the mouse in a document to move the insertion point to a new location.
    11·1 answer
  • Suppose your SOHO network connects to the Internet using cable modem. When you open your browser and try to access a web site, y
    8·1 answer
  • Pls answer fast in five mins​
    12·1 answer
  • define a function named quarter_num that has one parameter number and return quarter of the number. For example: if we called th
    7·1 answer
  • What are your thoughts on copyright?<br><br> (Write 2 or more sentences)
    9·2 answers
  • define the term computer hardware and its various types mentioning 5 examples of IP or devices with one diagram each​
    9·1 answer
  • Is iphone battery being draned if plugged into car charger when listening to podcasts
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!