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
Brainiest To Best Answer!! Java coding help, can you tell me what Switch and Case does using the example below?
fiasKO [112]
The switch statement is an n-way branch. An n-way branch can branch to any of an arbitrary number ( n ) of branches. An if statement can branch two ways, whether the condition is true or false.

The example you gave is a great example of how how code is written can make the code make sense or not.

public void setQuiz( int quiz, int grade )
{
  switch( quiz )
  {
    case 1: // if quiz == 1
      grade1 = grade; //where was grade1 declared?
      break;  // otherwise execution will continue through the next case block
    case 2: // if quiz == 2
      grade2 = grade;
      break;
  }
}

The variable named in the switch statement is tested against each case statement and whichever case statement's value matches, the rest of the switch statement's code is executed. (That's why the break statements are needed) Usually switch statements are written with a default case at the end as a "catchall".
4 0
4 years ago
How is a Creative Commons license different from a regular copyright?
gayaneshka [121]

Answer:

Creative Commons is actually a license that is applied to a work that is protected by copyright. It's not separate from copyright, but instead is a way of easily sharing copyrighted work. ... Copyright confers some pretty heavy duty protections so that others don't use your work without your permission.

Explanation:

8 0
3 years ago
Answer im timed i'll mark brainliest
NNADVOKAT [17]

Answer:

The answer is shapes.

Explanation:

5 0
3 years ago
Assume a disk cache hit rate (dchr) of 95% and 2 millisecond on average to access a page in cache. If the average access time to
MrRa [10]

Answer:

The answer is provided in the form of explanation

Explanation:

A page fault occurs means that the required page is not in main memory. First OS check for

page in the cache memory, if the page is present then retrieved but if not present then check for

page in main memory and if the page is not present here too then it searches for page in hard

drive. To calculate the expected time, the following formula is used:

Cache hit ratio = 95% = 0.95

Cache miss ratio = 5% = 0.05

Cache access time = 2 millisecond

The average access time of hard drive = 30 milliseconds

Expected time = Hit ratio (cache access time +memory access time) + Miss ratio (cache

access time + 2 * memory access time)

= 0.95 (2+30) + 0.05 (2+2*30)

= 0.95 (32) + 0.05(62)

=30.4 + 3.1

= 33.5 millisecond

Expected time = cache hit ratio * cache access time + (1 – hit ratio) * cache miss ratio

= 0.95*2+(1-0.95)*0.05

= 1.9025

4 0
3 years ago
What type of websites, which let users share personal stories and photos, became popular in the 2000s?.
Lina20 [59]

Answer:

MMORPGS was a type of website that let users share their stories and pics across the world wide web

Explanation:

8 0
3 years ago
Other questions:
  • Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the g
    12·2 answers
  • Write code to print the location of any alphabetic character in the 2-character string passCode. Each alphabetic character detec
    8·1 answer
  • What type of tests is suitable for automated testing?
    12·1 answer
  • Sabiendo que el engranaje motriz tiene 14 dientes y gira a 4000 RPM, y el conducido tiene 56 dientes, responde:
    11·1 answer
  • 2(x-5)-3(3-x)=1/2(x-2)
    9·1 answer
  • Encapsulation is the process of “packaging” information prior to transmitting it from one location to another. true or false
    14·1 answer
  • Preparing for jobs that are high in demand allow you to...
    11·1 answer
  • What's ur favorite color and your dream car
    8·2 answers
  • What is the output of the given code?<br><br> A. Compiler error<br> B. 0505<br> C. Smooth<br> D. 0.0
    10·1 answer
  • Could anyone help me with this assignment please?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!