simbax

oceny.py

Dec 28th, 2012
6,460
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. # coding=utf-8
  2. # Program obliczy średnią podanych ocen
  3. wydzial_ocen = ("1", "2", "3", "4", "5", "6")
  4. oceny = []
  5. ocena = raw_input("Podaj ocenę: ")
  6. while ocena != '':
  7.     if ocena in wydzial_ocen:
  8.         oceny += int(ocena),
  9.     else:
  10.         print "Ocena nie jest w wydziale ocen:\n",wydzial_ocen
  11.     ocena = raw_input("Podaj kolejną ocenę: ")
  12. srednia = 0
  13. for ocena in oceny:
  14.     srednia += ocena
  15. srednia = float(srednia)/len(oceny)
  16. print "Średnia tych ocen jest równa",srednia
Advertisement
Add Comment
Please, Sign In to add comment