Use the Design Recipe to write a function called running_average that repeatedly asks the user to input integers at the keyboard until they type the word done. Return the average of the values they entered. You may assume the user will only enter integers or "done". Include a docstring!

Question
Asked Oct 16, 2019
65 views

Use the Design Recipe to write a function called running_average that repeatedly asks the user to input integers at the keyboard until they type the word done. Return the average of the values they entered. You may assume the user will only enter integers or "done". Include a docstring!

check_circle

Expert Answer

star
star
star
star
star
1 Rating
Step 1

DESIGN RECIPE:

  1. Based on the given problem use meaningful variable and function name. And perform the given problem's solution. Write a method called running_average and return float datatype after calculation of all integer type entries and terminates the method when the user enters "done".

"""running_average_module module's docstring"""

  1. Write the function's header with void parameter, and returns average.

def running_average() :

  1. Declare all required variables and create a while loop that will get the user's input and checks whether that input is of integer type of not. If it is of integer type then continue the loop by adding value in variable num_averger and if it is false then terminate the program with calculating entered values data and return that data to the main function.

                         """running_average function's docstring"""

                         num_avg = 0

                         count = 0

                         while(True) :

                                     num = input("please enter here: ")

                                     If(num[0] >= '0' and num[0] <= '9') :

                   ...

Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

Engineering

Computer Science

Python

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: in c++ Write a program to generate a random number between 1 - 100, and then display which quartile ...

A: Program Instructions:Use the header files, constants, seed and random number generator given in the ...

question_answer

Q: In Lab 2, you created a menu for a simple calculator program. In Lab 6, you added some functionality...

A: Program Algorithm-STARTStep1 Import essential headers.Step2 Define main functionStep3 Print “Hello u...

question_answer

Q: Please put into SOP form~xyz + yz + x~y

A: It is said that a Boolean expression consisting solely of Minterms (product terms) is in the form of...

question_answer

Q: 1

A: Different business rules are given in the question which form the entities like Volunteer, Area, Loc...

question_answer

Q: the question i am having trouble with is: you are designing an application at work that transmits da...

A: Design the application at work and it must transmit data records to another building within the same...

question_answer

Q: In C++ Create a function called CopyAndInsertArray.  It should take in two arrays (the first array s...

A: Program designThe overall program design is as follows:The function CopyAndInsertArray would accept ...

question_answer

Q: Python 3.7.4 Write a statement to open the file priceList.txt for writing.

A: To open the file priceList.txt for writing, the statement is: f=open('priceList.txt','w')The followi...

question_answer

Q: I need help tackling this program:     Write a C++ console application that allows your user to ente...

A: For solving this problem following variables and data type are used to execute this file :1.Variable...

question_answer

Q: Explain how the minimum-sum descent problem can be solved by Dijkstra’s algorithm.    This is a prob...

A: The problem is to find the solution of minimum-sum descent  problem is relatively simple using Top-t...