In Python, write a function numLetters() that keeps prompting the user for words until they hit return (using while loops). The function should then return the percent of 3-letter words that were entered. So, if a user entered ten words and 4 of the words had 3 letters, then the percent of 3-letter words is 40
def numLetters():
wordsInput=[] #list for storing
words
#reading words until enter return
while(True):
inpt=input("Enter word :")
if(inpt!="return"):
wordsInput.append(inpt)
else:
break
wordsDigitCount=[] #for storing every word count
#counting every word count
for word in wordsInput:
dcount=0
for ch in word:
if(ch.isspace()!= True):
dcount=dcount+1
wordsDigitCount.append(dcount)
#calculating 3 letter word count and
percentage
threeLetter=0
for i in range(len(wordsDigitCount)):
if(wordsDigitCount[i]==3):
threeLetter=threeLetter+1
return len(wordsInput),threeLetter*10
#returning count of total words and percentage of 3 letter
words
#main program
totalWords,percentage=numLetters() #storing function return
values
print("out of {} words, 3-letter percentage :
{}".format(totalWords,percentage))
In Python, write a function numLetters() that keeps prompting the user for words until they hit...
Perl Write a program with a subroutine that keeps prompting for a filename until a valid file is entered by the user (print out "file found, thanks") or until five attempts have failed (print out "you did not enter a valid file name"). The sub in this case does not return any value.
Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...
Using Python, write a program that keeps asking the user for text until they type "exit" To Exit Or Not Write a program that keeps asking the user for text until they type "exit" Console 1 Enter number 1 3 Enter number 5 5 Enter number 7 Enter number 8 1 9 Enter number 10 9 11 Enter number 12 3 13 Enter number 14 4 15 Enter number 16 exit 17 Bye! 18
python Write a progran that reads values from the user until a blank line is entered. Display the total of al1 the values entered by the user (or 0.0 if the first value entered is a blank 1ine). Complete this task using recursion. program must not use any loops. Your Hint: The body of your recursive function will need to read one value from the user, and then determine whether or not to make a recursive call. Your funetion does...
Python Programming Q.3) Write a program that repeatedly asks the user to enter words until they enter a period ("."). Your program should then print all of the words they entered including the period) on a single line separated by spaces. For example, Enter some words (. to stop): > hello > world hello world.
In python Prompt user to input the number of the month they were born. Using a while loop, continue prompting for the month until the user inputs a valid month number. Figure out the number of days in the month the user entered. Then prompt the user to input the day they were born. Using a while loop, continue prompting until they input a day that is within the range of the number of days in their month. Assume 28...
Write a function in python ABC() that prompts for a choice of A, B, or C and uses a while loop to keep prompting until it receives the string 'A', 'B', or 'C'. The function should then return the choice.
Write a full python program that asks the user to type in 10 words using a loop, prompting the user for each word with a number. The program then displays the longest word and the shortest word the user typed in.
1. In Python, Write a function to convert inches into yards, feet and inches. The functions should take one parameter, 'inches', and print out the number of yards, feet, and inches equivalent to the value of the argument. Call the function after prompting the user to enter the number of inches. Don't forget to convert the input to an 'int'. 2. In Python,Write a function to convert celsius to fahrenheit. The function should return a value, which you should assign...
IN PYTHON Write a function that does not receive parameters but the user must enter numbers until they give him a 0. While the user does not give him a 0, the program must show how many numbers were entered, the sum of these numbers and the average (not counting the 0) example: 16 4 42 8 23 15 0 output: numbres = 6 sum = 108 average = 18.0