Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bn,bs=0,0 #count of boys,Sum of grades of boys
- gn,gs=0,0 #Count of girls, Sum of grades of girls
- while(1):
- grades=input("Enter grades = ") #Enter grades as 10b where 10 is grade and "b"->boys "g"->girls or any other character to quit.
- if('b' in grades):
- bs+=int(grades.replace('b',''))
- bn+=1
- else:
- if('g' in grades):
- gs+=int(grades.replace('g',''))
- gn+=1
- else:
- if(bn!=0): #Divide by zero error
- print("Average of boys = "+ str(bs/bn))
- if(gn!=0):
- print("Average of girls = "+ str(gs/gn))
- break
Add Comment
Please, Sign In to add comment