Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Computing average
#2
total = 0
counter = 0
 
while True:
    values = int(input("Enter the integer : "))
    if values > 0:
        total += values
        counter += 1
    else: 
        if counter > 0:
            average = total / counter
            print('The average of the numbers entered is %d' %average)
        else:
            print('enter value > 0')
Reply


Messages In This Thread
Computing average - by vestkok - Aug-12-2018, 09:04 AM
RE: Computing average - by Axel_Erfurt - Aug-12-2018, 09:38 AM
RE: Computing average - by vestkok - Aug-12-2018, 10:02 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  computing average in nested loops cap510 5 5,427 Sep-11-2020, 12:33 PM
Last Post: deanhystad
  Computing factorials Truman 6 4,316 Mar-14-2018, 06:38 AM
Last Post: DeaD_EyE
  computing the factorial of N foolsgold27 12 8,404 Aug-02-2017, 02:29 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020