-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate.py
More file actions
37 lines (27 loc) · 864 Bytes
/
Copy pathdate.py
File metadata and controls
37 lines (27 loc) · 864 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
from datetime import date
class Students:
students_no = 0
def __init__(self, name , age):
self.name= name
self.age= age
Students.students_no += 1
def describe(self):
return (f"my name is {self.name} , my age is {self.age}")
@classmethod
def years( cls, name , birthYear ):
return cls(name , date.today().year - birthYear)
class Pizza :
def __init__(self, ingredients):
self.ingredients = ingredients
@classmethod
def margrita(cls):
return cls(["mozarila" , "tomato" , "onions"])
@classmethod
def veg(cls):
return cls(["tomato" , "onions" , "salsa"])
def des(self):
print(f"my pizza ingredients {self.ingredients}")
pizza1= Pizza.margrita()
pizza2= Pizza.veg()
pizza3= Pizza(["beef" , "shawrma" , "strips"])
print(pizza3.des())