-
Notifications
You must be signed in to change notification settings - Fork 0
/
8.py
213 lines (139 loc) · 4.17 KB
/
8.py
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
from printing_functions import print_models, show_completed_models
# 8.1
print("\n8.1")
def display_messages():
print("Uczymy sie funkcji")
display_messages()
# 8.2
print("\n8.2")
def favourite_book(title):
print(f"Jedna z moich ulubionych ksiazek jest {title.title()}")
favourite_book('alicja w krainie czarow')
# 8.3
print("\n8.3")
def make_shirt(size, text):
print(f"Koszulka z rozmiarem {size} zostanie wydrukowana z textem: {text}")
make_shirt('S', 'Pokemon')
make_shirt(size='L', text='Jack')
# 8.4
print("\n8.4")
def make_shirt(size='L', text='Lubie Pythona'):
print(f"Koszulka z rozmiarem {size} zostanie wydrukowana z textem: {text}")
make_shirt('L')
make_shirt('S')
make_shirt('M', 'Jack')
make_shirt(size='S', text='Jack2')
# 8.5
print("\n8.5")
def describe_city(city_name, country_name='Polska'):
print(f"{city_name.title()} lezy w {country_name.title()}")
describe_city('Wroclaw')
describe_city('Rzeszow')
describe_city('Rzym', 'Wlochy')
# 8.6
print("\n8.6")
def city_country(city_name, country_name):
return f"{city_name.title()}, {country_name.title()}"
print(city_country('Rzym', 'Wlochy'))
print(city_country('Wroclaw', 'Polska'))
print(city_country('Berlin', 'Niemcy'))
# 8.7
print("\n8.7")
def make_album(band_name, title_album, track_number=None):
album = {'band_name': band_name, 'title_album': title_album}
if track_number:
album['track_number'] = track_number
return album
print(make_album('Pezet', 'Noc'))
print(make_album('Peja', 'Dzien'))
print(make_album('Ktos', 'Poludnie'))
print(make_album('Jeszzcze ktos inny', 'Polnoc', 12))
# 8.8
print("\n8.8")
# active = True
active = False
albums = []
while active:
bn = input('Podaj nazwe teamu: ')
ta = input('Podaj tytul albumu: ')
tn = input('Podaj liczbe utworow (opcjonalne - jesli nie chcesz podac wcisnij enter): ')
albums.append(make_album(bn, ta, tn))
if input('Chcesz podac nastepny? Y/N ') == 'N':
active = False
print(albums)
# 8.9
print("\n8.9")
comms = ['STOP', 'JEDZ', 'COSTAM']
def show_messages(msgs):
for msg in msgs:
print(msg)
show_messages(comms)
# 8.10
print("\n8.10")
comms = ['STOP', 'JEDZ', 'COSTAM']
sent_messages = []
def show_messages(msgs, name=''):
print(f"Printuje : {name}")
for msg in msgs:
print(msg)
def send_messages(msgs):
show_messages(msgs)
while msgs:
item = msgs.pop()
sent_messages.append(item)
send_messages(comms)
show_messages(comms, 'comms')
show_messages(sent_messages, 'sent_messages')
# 8.11
print("\n8.11")
comms = ['STOP', 'JEDZ', 'COSTAM']
sent_messages = []
send_messages(comms[:])
show_messages(comms, 'comms')
show_messages(sent_messages, 'sent_messages')
# 8.12
print("\n8.12")
def build_sandwitch(*toppings):
print('Bedziemy robic kanapke z takimi skladnikami:')
for topping in toppings:
print(topping)
build_sandwitch('ser')
build_sandwitch('ser', 'mieso')
build_sandwitch('ser', 'mieso', 'ogorek')
# 8.13
print("\n8.13")
def build_profile(first, last, **user_info):
"""Budowa uzytkownia"""
user_info['first_name'] = first
user_info['last_name'] = last
return user_info
user_profile = build_profile('M', 'M', location='Rzeszow', lang='Python', exp='mid')
print(user_profile)
# 8.14
print("\n8.14")
def make_car(company, model, **car_info):
"""Budowanie samochodu"""
car_info['company'] = company
car_info['model'] = model
return car_info
car = make_car('subaru', 'impreza', color='black', tow_package=True)
print(car)
# 8.15
print("\n8.15")
unprinted_designs = ['etui', 'drzewo', 'wieza']
completed_models = []
print_models(unprinted_designs, completed_models)
show_completed_models(completed_models)
# 8.16
print("\n8.16")
# import printing_functions
unprinted_designs = ['etui', 'drzewo', 'wieza']
completed_models = []
# printing_functions.print_models(unprinted_designs, completed_models)
# printing_functions. show_completed_models(completed_models)
# from printing_functions import print_models, show_completed_models
# from printing_functions import print_models as pm, show_completed_models as scm
# import printing_functions as pf
# from printing_functions import *
# 8.17
print("\n8.17")