CodeSolved

Solved Programming Questions & Exercises

Average numbers (infinite)

Practice Easy 24/ Download 4158 Views

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

The program must first get the user's numbers (as long as 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

23 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.
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
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)
User 3026 Download Python
s=0
while 1:
 num= int(input('num:'))
 if num==0:
  break
 s+=num
print(s)
Maryam.n Download Python
numbers = []

while True:
    g = int(input("enter a number:"))
    if g == 0:
        break
    numbers.append(g)
print (sum(numbers) / len (numbers))
User 558 Download Python
num_list = []
while 1 == 1:
    number = int(input('Enter number (0 = close) : '))
    if number == 0:
        break
    else:
        num_list.append(number)

print('Average : ' , sum(num_list)/len(num_list))

an = 0
te = 0 
while True:
    print("برای وارد کردن نمره عدد 1 را وارد کن")
    print("برای میانگین گرفتن عدد 2")
    a = int(input("gozineye morede nazar ro vared kon : "))
    if a == 1 :
        x = float(input("nomarateto darj kon: "))
        an += x
        te += 1 
        continue
    if a == 2 :
        if te == 0:
            print("meghdari vared nashodeh ast dobare talash konid")
            continue
    if a == 2 :
        print(f"miyangin nomarat: {an / te}")
    if a != 1:
        if a != 2:
            print(f"{a} رو از کجاست بیرون کشیدی یابووووو دو گزینه بیشتره مگه!!!")
Azhgun Download Python
<< Previous page 1 2 3 Next page >>

Submit answer

Submitting answers is currently unavailable.

Related content

Detection using AI
×
×
Close