generated from mwc/lab_iteration
For Checkpoint 3 I added in the coordinates used for the
code. To me, this provided more information for thereader. I thinkI would use docstrings. They are helpful because they put what the code does info "laymans" terms.
This commit is contained in:
@@ -9,15 +9,18 @@ def print_all_numbers(maximum):
|
|||||||
|
|
||||||
def print_even_numbers(maximum):
|
def print_even_numbers(maximum):
|
||||||
"Prints all even integers from 0 to maximum."
|
"Prints all even integers from 0 to maximum."
|
||||||
pass
|
for number in range(0,maximum, 2):
|
||||||
|
print(number)
|
||||||
|
|
||||||
def print_odd_numbers(maximum):
|
def print_odd_numbers(maximum):
|
||||||
"Prints all odd integers from 0 to maximum."
|
"Prints all odd integers from 0 to maximum."
|
||||||
pass
|
for number in range(0,maximum, 3):
|
||||||
|
print(number)
|
||||||
|
|
||||||
def print_multiples_of_five(maximum):
|
def print_multiples_of_five(maximum):
|
||||||
"Prints all integers which are multiples of five from 0 to maximum."
|
"Prints all integers which are multiples of five from 0 to maximum."
|
||||||
pass
|
for number in range(0,maximum, 5):
|
||||||
|
print(number)
|
||||||
|
|
||||||
chosen_maximum = int(input("Choose a number: "))
|
chosen_maximum = int(input("Choose a number: "))
|
||||||
print(f"All numbers from 0 to {chosen_maximum}")
|
print(f"All numbers from 0 to {chosen_maximum}")
|
||||||
|
|||||||
10
tile.py
10
tile.py
@@ -4,15 +4,21 @@ def draw_tile(size):
|
|||||||
"Draws one tile, which can be repeated to form a pattern."
|
"Draws one tile, which can be repeated to form a pattern."
|
||||||
draw_tile_outline(size)
|
draw_tile_outline(size)
|
||||||
draw_squiggle(size)
|
draw_squiggle(size)
|
||||||
|
draw_triangle(size)
|
||||||
|
|
||||||
def draw_tile_outline(size):
|
def draw_tile_outline(size):
|
||||||
pencolor("#dddddd")
|
pencolor("#dddddd")
|
||||||
square(size)
|
square(size)
|
||||||
|
|
||||||
|
def draw_triangle(size):
|
||||||
|
for i in range(3):
|
||||||
|
forward(size)
|
||||||
|
left(360//3)
|
||||||
|
|
||||||
def draw_squiggle(size):
|
def draw_squiggle(size):
|
||||||
forward(size/4)
|
forward(size/4)
|
||||||
pencolor("black")
|
pencolor("green")
|
||||||
left(90)
|
left(80)
|
||||||
quarter_arc_right(size/4)
|
quarter_arc_right(size/4)
|
||||||
quarter_arc_left(size/4)
|
quarter_arc_left(size/4)
|
||||||
quarter_arc_left(size/4)
|
quarter_arc_left(size/4)
|
||||||
|
|||||||
@@ -10,8 +10,10 @@ from tile import fly
|
|||||||
def draw_tile_grid(width, height, tile_size, tile_function):
|
def draw_tile_grid(width, height, tile_size, tile_function):
|
||||||
"""Draws a (width x height) grid, with tile_function drawn on each tile.
|
"""Draws a (width x height) grid, with tile_function drawn on each tile.
|
||||||
|
|
||||||
(Your explanation here.)
|
Draws a (width x height) grid using x, y coordinates, with tile_function drawn on each
|
||||||
|
tile )
|
||||||
"""
|
"""
|
||||||
|
|
||||||
for y in range(height):
|
for y in range(height):
|
||||||
for x in range(width):
|
for x in range(width):
|
||||||
tile_function(tile_size)
|
tile_function(tile_size)
|
||||||
|
|||||||
Reference in New Issue
Block a user