Guest User

Untitled

a guest
Feb 17th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. bn,bs=0,0 #count of boys,Sum of grades of boys
  2. gn,gs=0,0 #Count of girls, Sum of grades of girls
  3. while(1):
  4. grades=input("Enter grades = ") #Enter grades as 10b where 10 is grade and "b"->boys "g"->girls or any other character to quit.
  5. if('b' in grades):
  6. bs+=int(grades.replace('b',''))
  7. bn+=1
  8. else:
  9. if('g' in grades):
  10. gs+=int(grades.replace('g',''))
  11. gn+=1
  12. else:
  13. if(bn!=0): #Divide by zero error
  14. print("Average of boys = "+ str(bs/bn))
  15. if(gn!=0):
  16. print("Average of girls = "+ str(gs/gn))
  17. break
Add Comment
Please, Sign In to add comment