Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import datetime
- class Artist():
- def __init__(self, nume, varsta):
- self.nume = nume
- self.varsta = varsta
- def afis(self):
- print(self.nume + " " + str(self.varsta) + " ", end =" ")
- class Pictor(Artist):
- def __init__(self, nume, varsta, nume_pictura, an_realizare):
- super().__init__(nume, varsta)
- self.nume_pictura = nume_pictura
- self.an_realizare = an_realizare
- def afis(self):
- super().afis()
- print(self.nume_pictura + " " + str(self.an_realizare) + " ")
- class Compozitor(Artist):
- def __init__(self, nume, varsta, nume_compozitie, an_compozitie):
- super().__init__(nume, varsta)
- self.nume_compozitie = nume_compozitie
- self.an_compozitie = an_compozitie
- def afis(self):
- super().afis()
- print(self.nume_compozitie + " " + str(self.an_compozitie) + " ")
- pictori = []
- pictori.append(Pictor("Ion panedele", 44, "Noua stea", 2009))
- pictori.append(Pictor("Alexandru Dumitru", 55, "Lumina Vieti mele", 2005))
- pictori.append(Pictor("Cristina Marglatu", 36, "Apusul", 2010))
- compozitori = []
- compozitori.append(Compozitor("Ion nenncu", 30, "Mandra mea", 2022))
- compozitori.append(Compozitor("Calin crisan", 50, "Hai mandr-o sa te tuc", 2019))
- compozitori.append(Compozitor("Alex de la Orastie", 29, "Sarutarile tale", 2020))
- for p in pictori:
- p.afis()
- for c in compozitori:
- c.afis()
- print("Difereta " + str(pictori[2].an_realizare - pictori[1].an_realizare))
- try:
- with open("informati.txt", "w") as f:
- for p in pictori:
- f.write(p.nume)
- f.write(str(p.varsta))
- f.write(p.nume_pictura)
- f.write(str(p.an_realizare))
- for c in compozitori:
- f.write(c.nume)
- f.write(str(c.varsta))
- f.write(c.nume_compozitie)
- f.write(str(c.an_compozitie))
- except:
- print("An exception occurred")
Add Comment
Please, Sign In to add comment