-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython_exercise_page162.py
More file actions
88 lines (62 loc) · 2.95 KB
/
python_exercise_page162.py
File metadata and controls
88 lines (62 loc) · 2.95 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# esercizio numero 9.1 pagina 162
class Restaurant:
"""a simple model to attempt two restaurant attributes"""
def __init__(self, restaurant_name, restaurant_type):
"""Initialize restaurant name and type attributes"""
self.restaurant_name = restaurant_name
self.restaurant_type = restaurant_type
def describe_restaurant(self):
"""prints this two pieces of information"""
print(f"the restaurant is called {self.restaurant_name}.")
print(f"This is a {self.restaurant_type}-style restaurant.")
def open_restaurant(self):
"""prints that the restaurant is open"""
print(f"{self.restaurant_name} is now open!")
restaurant = Restaurant('Bella Italia', 'mediterranean')
restaurant.describe_restaurant()
restaurant.open_restaurant()
#esercizio numero 9.2
class Restaurant:
"""a simple model to attempt two restaurant attributes"""
def __init__(self, restaurant_name, restaurant_type):
"""Initialize restaurant name and type attributes"""
self.restaurant_name = restaurant_name
self.restaurant_type = restaurant_type
def describe_restaurant(self):
"""prints this two pieces of information"""
print(f"the restaurant is called {self.restaurant_name}.")
print(f"This is a {self.restaurant_type}-style restaurant.")
def open_restaurant(self):
"""prints that the restaurant is open"""
print(f"{self.restaurant_name} is now open!")
restaurant = Restaurant('Bella Italia', 'mediterranean')
new_restaurant = Restaurant('Il mannarino', 'apulian')
mountain_restaurant = Restaurant('il crotto valtellina', 'mountain')
restaurant.describe_restaurant()
new_restaurant.describe_restaurant()
mountain_restaurant.describe_restaurant()
#esercizio numero 9.3
class User:
def __init__(self, first_name, last_name, email_address, phone_number, ID_card_number):
self.first_name = first_name
self.last_name = last_name
self.email_address = email_address
self.phone_number = phone_number
self.ID_card_number = ID_card_number
def describe_user(self):
print(f"your first name is {self.first_name}.")
print(f"your last name is {self.last_name}.")
print(f"your email address is {self.email_address}.")
print(f"your phone number is {self.phone_number}.")
print(f"your ID card number is {self.ID_card_number}.")
def greet_user(self):
print(f"Thank you for your time, {self.first_name}!")
user0.describe_user()
user0.greet_user()
user1.describe_user()
user1.greet_user()
user2.describe_user()
user2.greet_user()