generated from mwc/lab_iteration
made a abstract shape using tiles.py, was fun
This commit is contained in:
18
poetry.lock
generated
Normal file
18
poetry.lock
generated
Normal file
@@ -0,0 +1,18 @@
|
||||
# This file is automatically @generated by Poetry 2.3.1 and should not be changed by hand.
|
||||
|
||||
[[package]]
|
||||
name = "superturtle"
|
||||
version = "0.2.0"
|
||||
description = "Extensions to Python's turtle"
|
||||
optional = false
|
||||
python-versions = "<4.0,>=3.9"
|
||||
groups = ["main"]
|
||||
files = [
|
||||
{file = "superturtle-0.2.0-py3-none-any.whl", hash = "sha256:ca3a31be3259387b4490846adbf64502acc9d23472912cc43497ab170e89f506"},
|
||||
{file = "superturtle-0.2.0.tar.gz", hash = "sha256:807fb419c1dba9cb809a22a68e72c0193bdeed4a9326eb36ad940b2a7ff6ac04"},
|
||||
]
|
||||
|
||||
[metadata]
|
||||
lock-version = "2.1"
|
||||
python-versions = ">=3.10,<4.0"
|
||||
content-hash = "6aad436bbbf760fa856344262eab22d62a167cac4e5dfefbf4be77d5a37428c9"
|
||||
12
ranges.py
12
ranges.py
@@ -8,16 +8,16 @@ def print_all_numbers(maximum):
|
||||
print(number)
|
||||
|
||||
def print_even_numbers(maximum):
|
||||
"Prints all even integers from 0 to maximum."
|
||||
pass
|
||||
for number in range(0, maximum, 2):
|
||||
print(number)
|
||||
|
||||
def print_odd_numbers(maximum):
|
||||
"Prints all odd integers from 0 to maximum."
|
||||
pass
|
||||
for number in range(1, maximum, 2):
|
||||
print(number)
|
||||
|
||||
def print_multiples_of_five(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: "))
|
||||
print(f"All numbers from 0 to {chosen_maximum}")
|
||||
|
||||
12
square.py
12
square.py
@@ -1,17 +1,13 @@
|
||||
from turtle import *
|
||||
|
||||
def square(side_length):
|
||||
forward(side_length)
|
||||
right(90)
|
||||
forward(side_length)
|
||||
right(90)
|
||||
forward(side_length)
|
||||
right(90)
|
||||
forward(side_length)
|
||||
right(90)
|
||||
for i in range (4):
|
||||
forward(side_length)
|
||||
right(90)
|
||||
|
||||
sizes = [20, 40, 60, 80, 100]
|
||||
for size in sizes:
|
||||
square(size)
|
||||
|
||||
input()
|
||||
|
||||
|
||||
36
tile.py
36
tile.py
@@ -10,18 +10,18 @@ def draw_tile_outline(size):
|
||||
square(size)
|
||||
|
||||
def draw_squiggle(size):
|
||||
forward(size/4)
|
||||
pencolor("black")
|
||||
left(90)
|
||||
quarter_arc_right(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_left(size/4)
|
||||
quarter_arc_right(size/4)
|
||||
left(90)
|
||||
fly(size/4)
|
||||
left(90)
|
||||
fly(size)
|
||||
left(90)
|
||||
forward(size/25)
|
||||
pencolor("pink")
|
||||
left(135)
|
||||
half_arc_right(size * 2)
|
||||
half_arc_left(size * 2)
|
||||
half_arc_left(size * 2)
|
||||
half_arc_right(size * 2)
|
||||
left(135)
|
||||
fly(size/2)
|
||||
left(135)
|
||||
fly(size/2)
|
||||
left(135)
|
||||
|
||||
def fly(distance):
|
||||
"Moves without drawing."
|
||||
@@ -31,14 +31,14 @@ def fly(distance):
|
||||
|
||||
def square(size):
|
||||
"Draws a square of side length `size`"
|
||||
for side in range(4):
|
||||
for side in range(9):
|
||||
forward(size)
|
||||
left(90)
|
||||
left(135)
|
||||
|
||||
def quarter_arc_right(radius):
|
||||
def half_arc_right(radius):
|
||||
"Draws a quarter of an arc, turning to the right."
|
||||
circle(-radius, 90)
|
||||
circle(-radius, 180)
|
||||
|
||||
def quarter_arc_left(radius):
|
||||
def half_arc_left(radius):
|
||||
"Draws a quarter of an arc, turning to the left."
|
||||
circle(radius, 90)
|
||||
circle(radius, 180)
|
||||
|
||||
@@ -10,7 +10,7 @@ from tile import fly
|
||||
def draw_tile_grid(width, height, tile_size, tile_function):
|
||||
"""Draws a (width x height) grid, with tile_function drawn on each tile.
|
||||
|
||||
(Your explanation here.)
|
||||
(it works by drawing one version of the expected shape and then returning to its orignal starting point but also then moving up one row to draw the orignal shape in one spot above the original)
|
||||
"""
|
||||
for y in range(height):
|
||||
for x in range(width):
|
||||
|
||||
Reference in New Issue
Block a user