-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprinting_models_func.py
48 lines (32 loc) · 1.44 KB
/
printing_models_func.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
# Start with dome designs that need to be printed.
unprinted_designs = ['iphone_case', 'robot pendant', 'dodecahedron']
completed_models = []
# Simulate printing each design, until none are left.
# Move each design to completed_models after printing.
while unprinted_designs:
current_design = unprinted_designs.pop()
# Simulate creating 3D print from the design.
print("Printing model: " + current_design)
completed_models.append(current_design)
# Display all completed models.
print('\nThe following models have been printed:')
for completed_model in completed_models:
print(completed_model)
#### Rewritten with functions ####
def print_models(unprinted_designs, completed_models):
"""Simulate printing each design, until none are left.
Move each design to complete_models after printing"""
while unprinted_designs:
current_design = unprinted_designs.pop()
# Simulate creating 3D print from the design.
print("\nPrinting model: " + current_design)
completed_models.append(current_design)
def show_completed_models(completed_models):
"""show all the models that were printed."""
print("\nThe following models have been printed:")
for completed_model in completed_models:
print(completed_model)
unprinted_designs = ['iphone_case', 'robot pendant', 'dodecahedron']
completed_models = []
print_models(unprinted_designs, completed_models)
show_completed_models(completed_models)