1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Reika [66]
3 years ago
7

Write a program that prompts a user to enter numeric values. As each value is entered, the program should: - Append the value to

a list - Display the values of the list - Display the updated average of the list - Continue to prompt until the user enters any of: quit, stop, or end. Allow upper or lower case
Computers and Technology
1 answer:
VMariaS [17]3 years ago
7 0

Answer:

Following are the program in the Python Programming Language:

my_lst=[] #set list

while(True): #set while loop

 print("Enter stop, end or quit to stop the loop")

 n=input("Enter the number of elements: ")  

 #get input from user

 if(n=="quit" or n=="QUIT" or n=="stop" or n=="STOP" or n=="end" or n=="END"): #set if statement for break the loop

   print(n)

   break

 else:  #set else statement

   a=int(n) #type conversion

   for num in range(0,a): #set for loop

     l=float(input("Enter the element for list: ")) #get elements of list

     my_lst.append(l) #elements append to the list

   print("List: ",my_lst) #print list

   print("Average of the list:", sum(my_lst)/a)  

   #print average of the list

<u>Output</u>:

Enter the number of elements: 5

Enter the element for list: 1

Enter the element for list: 2

Enter the element for list: 3

Enter the element for list: 4

Enter the element for list: 5

List:  [1.0, 2.0, 3.0, 4.0, 5.0]

Average of the list: 3.0

Enter the number of elements: STOP

STOP

Explanation:

Here, we set list data type variable "my_lst" then, we set the while loop statement and pass condition "True" and inside it.

  • Then, we set a variable "n" and get input from the user in it.
  • Then, we set the if statement and pass the condition is when user input stop, end, or quit then loop is break.
  • Then, otherwise we set the variable "a" and the value of "n" is converted into the integer and store into "a".
  • Then, we set the for loop statement inside the else statement which starts from 0 to n inside the loop.
  • Then, we set the variable "l" which stores the elements of the list from the user in float data type.
  • Then, we append the elements of the "l" into the list "my_lst" and end for loop.
  • Finally, we print the list with message and then print average with message.
You might be interested in
Light travels at 3 × 108 meters per second. A light-year is the distance a light beam travels in one year.Write a PYTHON program
Volgvan

Answer: This is a python code

def lightyear():

   rate=3*100000000   //speed of light

   seconds=365*24*60*60   //number of seconds in 1 year

   return str((rate*seconds)/1000)+" km"    //distance=speed x time

print(lightyear()) //will print value of light hear in kilometers

OUTPUT :

9460800000000.0 km

Explanation:

In the above code, there is a variable rate, which stores the speed of light, i.e. distance traveled by light in 1 second which is in meters. Another variable is seconds, which store the number of seconds in 1 year, which is no of days in 1 year multiplied by the number of hours in a day multiplied by the number of minutes in an hour multiplied by the number of seconds in a minute. Finally, distance is speed multiplied by time, so distance is printed in kilometers and to convert distance in kilometers it is divided by 1000.

4 0
3 years ago
Http://moomoo.io/?server=8:16:0
love history [14]

Explanation:

noooooooooooooooooooooooooooooooooo

5 0
3 years ago
Read 2 more answers
Janice has decided that the best approach to programming a new social media app is to start with a small portion of it by writin
Maru [420]

Answer:

blacc

bhhj

Explanation:

4 0
3 years ago
What is the primary limitation of free versions of antivirus applications?
weqwewe [10]
The correct answer is A because they cant protect in real time
5 0
3 years ago
If the value of the expression,
mr Goodwill [35]

Answer:

<u>Arithmetic underflow</u>

Explanation:

Great question, it is always good to ask away and get rid of any doubts that you may be having.

Since the answer given is a negative. We can say the error that is seen here is an <u>Arithmetic underflow </u>error. This is because the answer given is a smaller absolute value which the computer cannot actually represent or save in its memory in the CPU. Therefore this is the closest representation of the arithmetic error displayed.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
Other questions:
  • What are the core scripting and coding technolies used to build ai platforms?
    14·1 answer
  • 2. Add a _______ to manually force text from one page to the next page. A. footer B. page break C. blank page D. header
    11·2 answers
  • Constraints are a. quantities to be minimized in a linear programming model. b. quantities to be maximized in a linear programmi
    5·1 answer
  • If a tv was showing a flat black or blue screen or had "snow", what steps would you take to fix it? Give an example of the direc
    11·1 answer
  • Where could an identity thief access your personal information?
    13·1 answer
  • Imma say something random...
    13·2 answers
  • The Arizona Department of Transportation has offices throughout the state. State documents are stored on a large server in a cen
    5·2 answers
  • You and a friend have just started a small business. How could you use the Internet to make your business successful?
    15·2 answers
  • What kind is a utility file that shrinks the size of a file
    14·1 answer
  • How do solar ovens track the sun as it moves during the day?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!