Completed Exercise 8-15 Printing Models
This commit is contained in:
parent
7c04f33a1c
commit
fee249807d
7
Chapter_08/8-15_printing_models.py
Normal file
7
Chapter_08/8-15_printing_models.py
Normal file
@ -0,0 +1,7 @@
|
||||
import printing_functions
|
||||
|
||||
unprinted_designs = ['phone case', 'robot pendant', 'dodecahedron']
|
||||
completed_models = []
|
||||
|
||||
printing_functions.print_models(unprinted_designs, completed_models)
|
||||
printing_functions.show_completed_models(completed_models)
|
||||
15
Chapter_08/printing_functions.py
Normal file
15
Chapter_08/printing_functions.py
Normal file
@ -0,0 +1,15 @@
|
||||
def print_models(unprinted_designs, 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()
|
||||
print(f"Printing 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)
|
||||
Loading…
x
Reference in New Issue
Block a user