CodeSolved

Solved Programming Questions & Exercises

Average numbers (infinite)

Practice Easy 24/ Download 5028 Views Most popular

Write a program that can obtain the average infinite number of numbers:

The program must first receive the user's numbers (until the user has not entered the number 0, taking the numbers must continue)

Next step must be calculated and printed the mean numbers received and printed

34 Answers

This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
This answer is only visible to premium members
This answer is only visible to premium members
This answer is only visible to premium members
let msg = 'error'
alert(msg) 
This answer is only visible to premium members
This answer is only visible to premium members

This answer is only visible to premium members

Subscription is currently unavailable.
print("start!!")
s = 0
n = 0
while True:
    i = int(input("Number:")) 
    if i == 0:
        break 
    s += i 
    n += 1 
print("avg:",s / n )   
print("end") 
User 3385 Download Python
def calculate_average():
    numbers = []  # List to save numbers

    while True:
        # Get a number from the user
        number = float(input("لطفاً یک عدد وارد کنید (برای پایان عدد 0 را وارد کنید): "))
        
        # Checking whether the user has entered the number 0
        if number == 0:
            break
        
        # Add the number to the list
        numbers.append(number)

    # Calculating and printing average
    if len(numbers) > 0:
        average = sum(numbers) / len(numbers)
        print("میانگین اعداد وارد شده برابر است با:", average)
    else:
        print("هیچ عددی وارد نشده است.")

# Implementation of the function
calculate_average()
Mma123 Download Python
a = 0
b = 0

while True:
    n = int(input("adad:"))
    if n ==0:
        break
    a = a + n
    b = b + 1   
print(a/b)

F.sarli Download Python
sum = 0
count = 0

while True:
    num = int(input("Num: "))
    if num == 0:
        break
    sum += num
    count += 1

average = sum / count
print(average)
Awlizf Download Python
num=int(input("enter a number: "))
sum=0
count=0
while(num!=0):
    sum+=num
    count+=1 
    num=int(input("enter a number: "))
print("avg: ",sum/count)
Saeeda33 Download Python
print(" salam ; baray etmam add giri add  0  ra vared kon ta mieangin ro bede")
mieangin = 0
j = 1
a = float(input("add {} :      ".format(j)))
while a != 0 :
    mieangin = a / j
    j = j + 1
    a = float(input("add {} :      ".format(j)))
    mieangin = (mieangin + a) / j
else:
    print(mieangin)
Esmaeelphy Download Python
s=0
while 1:
 num= int(input('num:'))
 if num==0:
  break
 s+=num
print(s)
Maryam.n Download Python
<< Previous page 1 2 4 Next page >>

Submit answer

Submitting answers is currently unavailable.

×
×
Close