Computer Science, asked by navneet1974, 9 months ago

to input 10 numbers and print their sum and average using while loop to make a Python program​

Answers

Answered by vidit05gupta
14

Explanation:

The following steps are taken to make the program-

  • Declare the required variables.
  • use the while loop.
  • inside the loop, input the values and calculate the sum.
  • outside the loop, calculate the average.
  • finally, print the answer.

Program:

print("Enter 10 numbers")

i = 0 # to iterate the loop

s = 0 # intializing the value to 0 to calculate the sum

while i < 10:

   n = int(input()) # taking input as integer

   s = s + n # modifying the variable to calculate the sum after every input

   i += 1 # incrementing the loop counter

avg = s / 10 # calculating the average of the values

print("The sum is = ",s)

print("The average is =",avg)

#answerwithquality

#BAL

Attachments:
Answered by satyam21461
0

Explanation:

The following steps are taken to make the program-

Declare the required variables.

use the while loop.

inside the loop, input the values and calculate the sum.

outside the loop, calculate the average.

finally, print the answer.

Program:

print("Enter 10 numbers")

i = 0 # to iterate the loop

s = 0 # intializing the value to 0 to calculate the sum

while i < 10:

  n = int(input()) # taking input as integer

  s = s + n # modifying the variable to calculate the sum after every input

  i += 1 # incrementing the loop counter

avg = s / 10 # calculating the average of the values

print("The sum is = ",s)

print("The average is =",avg)

#answerwithquality

#BAL

Attachments:
Similar questions