Alx09

Untitled

May 13th, 2022 (edited)
388
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.95 KB | None | 0 0
  1. import datetime
  2. class Artist():
  3.      def __init__(self, nume, varsta):
  4.          self.nume = nume
  5.          self.varsta = varsta
  6.      def afis(self):
  7.         print(self.nume + " " + str(self.varsta) + "  ", end =" ")
  8.  
  9. class Pictor(Artist):
  10.     def __init__(self, nume, varsta, nume_pictura, an_realizare):
  11.         super().__init__(nume, varsta)
  12.         self.nume_pictura = nume_pictura
  13.         self.an_realizare = an_realizare
  14.     def afis(self):
  15.         super().afis()
  16.         print(self.nume_pictura + " " + str(self.an_realizare) + "  ")
  17.  
  18. class Compozitor(Artist):
  19.      def __init__(self, nume, varsta, nume_compozitie, an_compozitie):
  20.         super().__init__(nume, varsta)
  21.         self.nume_compozitie = nume_compozitie
  22.         self.an_compozitie = an_compozitie
  23.      def afis(self):
  24.         super().afis()
  25.         print(self.nume_compozitie  + " " + str(self.an_compozitie) + "  ")
  26. pictori = []
  27. pictori.append(Pictor("Ion panedele", 44, "Noua stea", 2009))
  28. pictori.append(Pictor("Alexandru Dumitru", 55, "Lumina Vieti mele", 2005))
  29. pictori.append(Pictor("Cristina Marglatu", 36, "Apusul", 2010))
  30. compozitori = []
  31. compozitori.append(Compozitor("Ion nenncu", 30, "Mandra mea", 2022))
  32. compozitori.append(Compozitor("Calin crisan", 50, "Hai mandr-o sa te tuc", 2019))
  33. compozitori.append(Compozitor("Alex de la Orastie", 29, "Sarutarile tale", 2020))
  34. for  p in pictori:
  35.      p.afis()
  36. for  c in compozitori:
  37.      c.afis()
  38.  
  39. print("Difereta " + str(pictori[2].an_realizare - pictori[1].an_realizare))
  40. try:
  41.     with open("informati.txt", "w") as f:
  42.         for  p in pictori:
  43.             f.write(p.nume)
  44.             f.write(str(p.varsta))
  45.             f.write(p.nume_pictura)
  46.             f.write(str(p.an_realizare))
  47.         for  c in compozitori:
  48.             f.write(c.nume)
  49.             f.write(str(c.varsta))
  50.             f.write(c.nume_compozitie)
  51.             f.write(str(c.an_compozitie))
  52.        
  53.  
  54. except:
  55.      print("An exception occurred")
  56.  
Add Comment
Please, Sign In to add comment