Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # coding=utf-8
- # Lista Ocen Studentów
- class Student:
- imie = ""
- nazwisko = ""
- ocena = 0.0
- studenci = []
- nr = 0
- while True:
- naz = raw_input("Podaj nazwisko studenta nr %i (ENTER = koniec): " % (nr + 1))
- if not naz: break
- studenci.append(Student())
- studenci[nr].nazwisko = naz
- studenci[nr].imie = raw_input("Podaj imię studenta nr %i: " % (nr + 1))
- studenci[nr].ocena = float(raw_input("Podaj ocenę studenta nr %i: " % (nr + 1)))
- nr += 1
- print
- print "%-4s %-14s %-10s %7s" % ("L.p.", "Nazwisko", "Imię", "Ocena")
- for s in studenci:
- print "%3i. %-14s %-10s %7.1f" % (studenci.index(s)+1, s.nazwisko, s.imie, s.ocena)
- srednia = 0
- for s in studenci:
- srednia += s.ocena
- srednia = srednia/len(studenci)
- print "%13s %25.2f" % ("Średnia ocen:", srednia)
Advertisement
Add Comment
Please, Sign In to add comment