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
Suppose end system A wants to send a large file to end system B. At a very high level, describe how end system A creates packets
sashaice [31]

Answer:

The answer is below

Explanation:

Suppose end system A wants to send a large file to end system B, the large file is first divided into smaller chunks. Each chunk is then assigned a header forming a packet. Multiple packets are being generated with each of the packet containing a unique destination address in its header.

When a packet arrives at the packet switch, the switch uses the unique destination address that is attached in the header of the packet to determine the link onto which the packet is to be forwarded.

5 0
3 years ago
If an image has only 4 colors, how many bits are necessary to represent one pixel’s color? Describe a new custom encoding that u
MakcuM [25]

Answer:

1) 2 bits 2) shown in explanation 3) shown in explanation 4) 22 bits per pixel (2.75 bytes)

Explanation:

As a bit is one of two states, 1 or 0, 2 bits is sufficient to represent 4 colors:

00 = color 1

01 = color 2,

10 = color 3,

11 = color 4

This would be the custom type of encoding for that specific image as it only uses 4 colors.

Now to calculate the amount of memory saved, which is quite simple:

24-2=22

So you Would save 22 bits per pixel or 2.75 bytes per pixel.

5 0
3 years ago
Write a while loop that prints that number doubled without reaching 100. Follow each number with a space. After the loop, print
elena55 [62]

Answer:

The program to this question as follows:

Program:

#include <iostream> //defining header file

using namespace std;

int main() //defining main method

{

int n; //defining integer variables

cout<<"Enter number: "; //message

cin>>n; //input value by user

while (n< 100) //loop for check condition

{

cout<<n<<" ";//print value

n=n*2; //calculate value

}

return 0;

}

Output:

Enter number: 8

8 16 32 64  

Explanation:

In the above C++ language code, a header file is included, then defining the main method, inside the method an integer variable n is defined, which is used for user input for calculating their double number.  

In the next step, The while loop is declared, and the loop variable n range is defined, that its value is less than 100, inside the loop the variable n is used to calculate, its double number, and print function "cout" to print its value.

4 0
3 years ago
Hw to gain more knowledge ​
LenaWriter [7]

Answer:

Read Books, Search the Internet, etc...

Explanation:

6 0
3 years ago
Write a method that determines the total number of chars in each string of an array.
Serjik [45]
The total number of chars in each string is basically the size of each string.

Using JAVA:

        String[] arr = {"hello", "my", "name", "is", "Felicia"};                int count = 0;        for(int i = 0; i < arr.length; i++) {            count = count + arr[i].length();            System.out.println("Characters in " + arr[i] + ": " + count);        }

Output: 
<span>Characters in hello: 5
Characters in my: 7
Characters in name: 11
Characters in is: 13
Characters in Felicia: 20</span>


8 0
3 years ago
Other questions:
  • David has a laptop that is having a problem with the video system. You believe the problem might be the backlight. During your r
    13·1 answer
  • Whatis meant by Translation Lookaside Buffer?
    5·1 answer
  • A merge is _____.
    5·2 answers
  • How to cite a website, like asha.org?
    6·1 answer
  • What are some disadvantages of using a word processor over a type writer?​
    7·1 answer
  • Match the elements of a web page with their description
    15·2 answers
  • Instructions
    15·1 answer
  • Terrell, a programmer, is creating a website for an online merchant and wants the program to calculate the total price based on
    14·2 answers
  • How do I mark brainlyist
    7·2 answers
  • In which cipher method are values rearranged within a block to create the ciphertext?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!