I am working on Python. I have been asked to write a program for this question. Write a program that prompts the user to enter a series of strings, but with each string containing a small integer. Use a while loop and stop the loop when the user enters a zero. When the loop has finished, the program should display: • the number of user inputs (not counting the final zero input). • the total of the integers in the strings entered. • the average of the integers accurate to one decimal place. I have gotten to this point however I want the program to let me enter as many strings as I want until I press 0 to calculate everything. how do I do that? This is the code i have so far. import re inputs = 0 numberSum = 0 #Enter the string string=input('Enter a string and a number.") #Condition to check if its not 0 while string!=0: #input is incremented by 1 inputs += 1 #find the integer in string and save to num number=re.findall(\d+,string)[0] #Add number value to numberSum numberSum+=int(number) #Enter each string again string-input('Enter a string: ') #Calculate the average average=numberSum / inputs #Display result print("\nNumber of user inputs:,inputs) print('Total of these integers:',numberSum) print('Average of the integers:',average)
I am working on Python. I have been asked to write a program for this question. Write a program that prompts the user to enter a series of strings, but with each string containing a small integer. Use a while loop and stop the loop when the user enters a zero. When the loop has finished, the program should display: • the number of user inputs (not counting the final zero input). • the total of the integers in the strings entered. • the average of the integers accurate to one decimal place. I have gotten to this point however I want the program to let me enter as many strings as I want until I press 0 to calculate everything. how do I do that? This is the code i have so far. import re inputs = 0 numberSum = 0 #Enter the string string=input('Enter a string and a number.") #Condition to check if its not 0 while string!=0: #input is incremented by 1 inputs += 1 #find the integer in string and save to num number=re.findall(\d+,string)[0] #Add number value to numberSum numberSum+=int(number) #Enter each string again string-input('Enter a string: ') #Calculate the average average=numberSum / inputs #Display result print("\nNumber of user inputs:,inputs) print('Total of these integers:',numberSum) print('Average of the integers:',average)
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
This is a popular solution!
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY