-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcons.py
More file actions
50 lines (33 loc) · 921 Bytes
/
Copy pathcons.py
File metadata and controls
50 lines (33 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# class Car:
# def __init__(self):
# self.make = "Toyota"
# self.model = "Corolla"
# self.year = 2022
# c = Car();
# print(c.make)
# print(c.model)
# print(c.year)
class Car:
def __init__(self, make, model, year):
self.make = make
self.model = model
self.year = year
print("Constructor called: Car object created")
# Destructor
def __del__(self):
print("Destructor called: Car object destroyed")
c = Car("Honda", "Civic", 2022)
print("Make:", c.make)
print("Model:", c.model)
print("Year:", c.year)
del c
# print("Program end")
class UserInput:
def __init__(self):
self.name = input("Enter your name:")
self.age = int(input("Enter your age:"))
print(f"Constructor called: Hello: {self.name}, age: {self.age}")
def __del__(self):
print(f"Destructor called")
u = UserInput();
del u