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]
3 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]3 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
For LG, on the app Messages, will the delete button on the upper right corner cancel a sending message?
OLga [1]

It deleted the conversation. Past messages and stuff like that. I don't think it will delete the contact, just the text messages.

6 0
4 years ago
How do say phone in French?
olga_2 [115]

Answer:

téléphone

Explanation:

thats how you say phone in French also you can go on Google translate or word reference to translate words.

6 0
4 years ago
Read 2 more answers
Which osi model layer manages data encryption?
Hoochie [10]
The presentation Layer manages data encryption.
7 0
4 years ago
Write a program to find the sum of given series: (a) S = 1 + (1/2) + (1/3) + ...... + (1/20)
Snowcat [4.5K]

total = 0

numerator = 1

denominator = 1

while denominator != 20:

   total += numerator/denominator

   denominator+=1

print(total)

I wrote my code in python 3.8. I hope this helps.

3 0
3 years ago
Can someone just help Im really struggling right now<br> Tysm if you help
frutty [35]

That's really really hard, my god Cassie!

Explanation:

I don't know what the answer is. bekos Yu du not is da layer of da peyk Cassie. di ka mukhang dragon

6 0
3 years ago
Other questions:
  • Which of the following accurately completes this sentence? The Internet is ____.
    6·2 answers
  • What key combination in excel takes you back to the first cell
    7·1 answer
  • Copyrighted software that is distributed at no cost for a trial period is called?
    12·1 answer
  • Osha requires employers pay for most required personal protective equipment including
    11·1 answer
  • Two DHCP servers, Server1 and Server2, are running Windows Server 2016. As the administrator, you create a scope called Scope1.
    8·1 answer
  • Files exist on ____ storage devices, such as hard disks, dvds, usb drives, and reels of magnetic tape.
    11·1 answer
  • What breakthrough in sound recording facilitated stereophonic recording? Ο Α. overdubbing O B. multitrack recording O C. digital
    10·1 answer
  • Which of the following is NOT one of the three main ways to control a program when writing code?
    13·2 answers
  • LAB: Parsing dates in M/D/Y format
    5·1 answer
  • Write a function solution that given an array a of n integers (between -100 and 100), returns the sign (-1,0,1) of product of al
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!