0 Replies - 266 Views - Last Post: 26 January 2009 - 11:54 AM

#1 atik97   User is offline

  • ???
  • member icon

Reputation: 144
  • View blog
  • Posts: 715
  • Joined: 16-September 08

A function to find the mean of grouped data items

Posted 26 January 2009 - 11:54 AM

Description: This function can find the mean of a grouped data items.
def mean():
    n=int(input("Enter number of class:"))
    h=float(input("Enter class interval:"))
    sum_f=0
    sum_fx=0
    for i in range(n):
        print ("For class %s"%(i+1))
        l=float(input("Enter lower limit:"))
        #upper limit
        u=l+h
        f=int(input("Enter frequency:"))
        x=(l+u)/2.0
        fx=f*x
        sum_fx=sum_fx+fx
        sum_f=sum_f+f
    
    #mean of the data
    mean=sum_fx/sum_f
    print("The mean of the given data is:%s"%mean)




Is This A Good Question/Topic? 0
  • +

Page 1 of 1