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
eduard
3 years ago
15

Write a Python program to do the following: (a)Ask the user to enter as many integers from 1 to 10 as he/she wants. Store the in

tegers entered by the user in a list. Every time after the user has entered an integer, use a yes/no type question to ask whether he/she wants to enter another one. (b)Display the list. (c)Calculate and display the average of the integers in the list. (d)If the average is higher than 7, subtract 1 from every number in the list. Display the modified list.
Computers and Technology
1 answer:
Ilia_Sergeevich [38]3 years ago
7 0

Answer:

// program in Python

#empty list to store user input

i_list = []

#part a

#Loop until we read all the integer inputs from the user

while True:

   #read input from user

   value = input("Enter an integer (1-10): ")

   i_list.append(int(value))

   #read choice

   choice = input("Enter again? [y/n]: ")

   if choice == 'n':

       break

 

#part b

#Print list

print("Number List: " + str(i_list))

#part c

#find sum and Average

sum = 0

for i in i_list:

   #sum of all elements

   sum += i

#Average

avg = sum / len(i_list);

#print Average

print("Average: " + str(avg))

#part d

#If Avg > 7, subtract 1 from each element in the list and then display

if avg > 7:

   for i in range(0, len(i_list)):

       #subtract 1 from each element

       i_list[i] = i_list[i] - 1

#print new list

print("Modified List: " + str(i_list))  

Explanation:

Create an empty list to store the user input.Read input number from user  and store it into list.Then ask for choice(y/n).If user's choice is 'y' then again read a number and store it into list.Repeat this until user's  choice is 'n'. Find the sum and average of all inputs numbers and print the list,  and their average.If the average is greater than 7, subtract 1 from all the  inputs of the list and print Modified list.

Output:

Enter an integer (1-10): 9                                                                                                

Enter again? [y/n]: y                                                                                                      

Enter an integer (1-10): 6                                                                                                

Enter again? [y/n]: y                                                                                                      

Enter an integer (1-10): 7                                                                                                

Enter again? [y/n]: y                                                                                                      

Enter an integer (1-10): 8                                                                                                

Enter again? [y/n]: n                                                                                                      

Number List: [9, 6, 7, 8]                                                                                                  

Average: 7.5                                                                                                              

Modified List: [8, 5, 6, 7]  

You might be interested in
What is the correct syntax to take the first five characters from the cell A2 and place it to its right in cell A3? =RIGHT(A3,5)
vfiekz [6]

Answer:=LEFT(A2,5)

Explanation:

8 0
3 years ago
Read 2 more answers
Fill in the blank to complete the sentence.
Nina [5.8K]

Answer:

The correct answer is time

Explanation:

from time import localtime()

8 0
2 years ago
PLEASE HELP!!!! I'll mark Brainliest for whoever is first!!!!
Otrada [13]

Answer:

It counts the number of birds in the list.

7 0
3 years ago
Read 2 more answers
Mauricio plans on retiring in 20 years, and he wants to double his money by that time. He has contacted various banks, looking f
Novosadov [1.4K]

The rule of 72 is a very simple way to estimate and determine the number of years required to double your investments given a fixed annual rate of interest. It can also estimate and then calculate the annual interest rate required to double an investment in a given number of years. In the rule of 72, you can either choose to calculate the annual interest rate or the number of years.  

Use this formula to calculate the rule of 72

Rule of 72  ≈ 72 ÷ interest rate ≈ number of years to double

7 0
3 years ago
A Trojan horse:
Elis [28]

Answer:

The answer is "option D"

Explanation:

Trojan horse is a software, that is installed on a system and appears benign, but in actual it is the addition of malicious which unexpected modifications in config files and unusual activity even when the computer is idle are strong signs that a Trojan exists on a system. and other options are not correct that can be described as follows:

  • In option A, It is a malware that is also known as Trojan.
  • In option B, It is malware, not a virus but the malware includes viruses.
  • In option C, It doesn't install spyware on the user's computer.
  • In option E, It doesn't use for enterprise networks to penetrate.
4 0
3 years ago
Other questions:
  • How to save customised keyboard shortcuts on word
    11·1 answer
  • In statistics, what is the mode of a data set?
    6·2 answers
  • _______is the equal distribution of visual weight on either side of an imaginary axis through the center of a design. A building
    6·2 answers
  • Which description of the plain text file format is most accurate?
    10·1 answer
  • what are the Technologies in regarding of communication technology? Please help me I'll rate you as brainliest!​
    13·1 answer
  • someone who wants the credentials of skilled training, but in less time that a four -year degree should consider
    8·1 answer
  • ___ allow users to select controls by keyboard shortcuts. (Points : 3) Alternative keys
    13·1 answer
  • State four reasons why office automation is adopted in business establishment?​
    7·1 answer
  • Which is an example of an operating system? (5 points)
    5·1 answer
  • Choose the missing words in the code below.
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!