Answered step by step
Verified Expert Solution
Question
1 Approved Answer
In Python, using while loops please! If possible A. Write a function named calculations() that repeatedly asks the user to enter a number. When the
In Python, using while loops please! If possible
A. Write a function named calculations() that repeatedly asks the user to enter a number. When the user enters in the number 0, the calculations() function should display the sum of all the numbers entered so far, how many numbers have been entered, the averagell of all the numbers, and the largest number entered. You should not include the last 0 in the calculations. Hint: start by just doing the sum and make sure you can get it to work. Then implement how many numbers have been entered and make sure that works. After that, the average should be easy. And finally, when you've got everything else working, get the maximum value to work. [1 By "average, we mean the arithmetic mean. In case you don't remember how to calculate Here's what our version of the looks like when we run it (the black text represents input that the user typed in). Yours doesn't have to look identical to this, but it should be close. For example, your calculations() function needs to say what it wants from the user (including how to stop), and it should state what the values printed at the end represent. Please enter a number (enter 0 when done): Please enter a number (enter 0 when done): 2.5 Please enter a number (enter 0 when done) : Please enter a number (enter 0 when done) : You have entered 3 numbers The sum of all the numbers is 0.5 The average of all the numbers is 0.16666666666666666 The largest number entered is 5.0 Warning: in this rare occasion, we are asking you to write a function that takes no arguments, and returns no value. Instead, your calculations() function needs to display various outputs (using print)) and respond to user input (using input()). 121 f you are stuck, make sure that you understand all the while loop examples in the about while loops, e.g. the Using while Loops Without User Input example, &c. Save your calculations() function in a Python script file named hw06- functions.py B. Improve your calculations function, so that the program doesn't crash if the user immediately enters 0 as the first input. You have to decide for yourself how to handle that situation and what to do when it happens Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started