Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
# zadatak od korisnika prihvaća podatke za 5 studenata i zatim ih ispisuje
# sortirane po abecedi (usporedba n-torki) i sortirane po prosjeku
# (potrebno je najprije izmijeniti redoslijed elemenata u n-torci)
# napomena: prije pokretanja programa unijeti podatke o studentima u STDIN
# u zasebne redove
# unos podataka za 5 studenata
studenti = []
for i in range(5):
prezime_ime = str(input(''))
ID = input()
prosjek = input()
student = (prezime_ime[:-1], int(ID[:-1]), float(prosjek[:-1]))
studenti.append(student)
print (studenti)
print('----------')
# sortiranje studenata po abecedi i ispis
studenti.sort()
print('Studenti sortirani po abecedi:')
for s in studenti:
print(s)
print('----------')
# kreiranje liste n-torki sa izmijenjenim redoslijedom
studenti_po_prosjeku = []
for s in studenti:
studenti_po_prosjeku.append((s[2], s[0], s[1]))
print(studenti_po_prosjeku)
print('----------')
# sortiranje po prosjeku (silazno) i ispis
studenti_po_prosjeku.sort(reverse = True)
print('Studenti sortirani po prosjeku:')
for s in studenti_po_prosjeku:
print(s)
print('----------')
# nije moguće izbrisati n-torku koja je element liste iterativnim prolaskom
for s in studenti_po_prosjeku:
del(s)
print(studenti_po_prosjeku)
print('----------')
# brisanje pojedinačne n-torke
moj_tuple = (1, 2, 3)
print(moj_tuple)
del(moj_tuple)
# print(moj_tuple)
Advertisements
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.
AcceptLearn more