2024-05-07 08:28:05 +02:00
|
|
|
# personclass2.py
|
2024-05-06 08:02:31 +02:00
|
|
|
|
|
|
|
class Person:
|
|
|
|
|
|
|
|
def __init__(self, name="", age=0, gender=None):
|
|
|
|
self.name = name
|
|
|
|
self.age = age
|
|
|
|
self.gender = gender
|
|
|
|
|
|
|
|
|
|
|
|
person1 = Person()
|
|
|
|
|
|
|
|
print(person1)
|
|
|
|
print(person1.__class__)
|
|
|
|
print(person1.name)
|
|
|
|
print(person1.age)
|
|
|
|
print(person1.gender)
|
|
|
|
|
|
|
|
person2 = Person("Joe Doe", 32, gender="m")
|
|
|
|
|
|
|
|
print(person2)
|
|
|
|
print(person2.__class__)
|
|
|
|
print(person2.name)
|
|
|
|
print(person2.age)
|
|
|
|
print(person2.gender)
|
|
|
|
|
|
|
|
|