Question: Program to compute the average of the numbers provided. Enter each number followed by . When you are done, just hit in response to
Program to compute the average of the numbers provided. Enter each number followed by . When you are done, just hit in response to the prompt.. Enter a number: 10 Enter a number: 15 Enter a number: 5 Enter a number: 10 Enter a number: You entered 4 numbers. The average is 10.0. HINTS 1. When a user hits without typing any text, input () returns an empty string (called a null string). If checked as a boolean, a null string will be interpreted as False. A string containing characters will be interpreted as True. You can use this property to control a while loop. 2. As we gain knowledge, we also gain the ability to evaluate different solution methods. Here, you could keep a running total as the user enters each number OR you could accumulate the numbers in a list and process them after exiting the loop. You could accumulate the response strings through concatenation and convert that to a list using split() or you could accumulate the response strings in a list or you could convert the response strings to floats and append the floats to a list. Which results in the most readable code? What circumstances would prefer one solution over the other?
Step by Step Solution
3.30 Rating (150 Votes )
There are 3 Steps involved in it
Answer initializing variables total 0 count 0 reading ... View full answer
Get step-by-step solutions from verified subject matter experts
