class Jarmu: def __init__(self, id, marka, uzemanyag, ev, ar, szin, rendszam): self.id = id self.marka = marka self.uzemanyag = uzemanyag self.ev = ev self.ar = ar self.szin = szin self.rendszam = rendszam
from jarmu import Jarmu jarmu1 = Jarmu(1, "Volkswagen", "benzin", 2010, 2000, "fekete", "ABC123") jarmu2 = Jarmu(2, "Mercedes", "benzin", 2015, 2500, "kek", "DEF456") print(jarmu1.marka, jarmu1.rendszam) print(jarmu2.marka, jarmu2.rendszam)
class Termek: def __init__(self, id, nev, ar, mennyiseg): self.id = id self.nev = nev self.ar = ar self.mennyiseg = mennyiseg
from termek import Termek def beker(): id = input('id: ') nev = input('nev: ') ar = input('ar: ') mennyiseg = input('mennyiseg: ') return Termek(id, nev, ar, mennyiseg) def termekHozzafuzes(termek): with open('products.csv', 'a') as f: f.write(termek.id) f.write(';') f.write(termek.nev) f.write(';') f.write(termek.ar) f.write(';') f.write(termek.mennyiseg) f.write('\n') termek = beker() termekHozzafuzes(termek)