38 lines
823 B
Python
38 lines
823 B
Python
from random import choice, randint
|
|
|
|
nazwiska = [
|
|
"Sylwia Ciuruś",
|
|
"Marcelina Janc",
|
|
"Dorota Leśny",
|
|
"Hubert Beker",
|
|
"Albert Budzeń",
|
|
"Bruno Kargol",
|
|
"Olaf Juroszek",
|
|
]
|
|
|
|
class Osoba:
|
|
def __init__(self, name="XXX", age=30, sex="M"):
|
|
self.name = name
|
|
self.sex = sex
|
|
self.age = age
|
|
print(f"Start obiektu: {id(self)} - plec: {self.sex} wiek: {self.age}")
|
|
|
|
def __del__(self):
|
|
print (f"Bye, bye: {id(self)}....")
|
|
|
|
def __str__(self):
|
|
return f"Oto osoba - {self.name} "
|
|
|
|
lista_osob = []
|
|
for nr in range(10):
|
|
wiek = randint(20,50)
|
|
plec = choice(["M","K","X"])
|
|
nazwisko = choice(nazwiska)
|
|
osoba = Osoba(nazwisko, sex=plec, age=wiek)
|
|
lista_osob.append(osoba)
|
|
|
|
|
|
print(lista_osob)
|
|
print("----------------------")
|
|
for osoba in lista_osob:
|
|
print(osoba) |