Kathryn Odell-Hamilton

Started out with repetitive code to draw shapes, then used "ranges"
to simplfy code drawing shapes and print numbers (even, odd, multiples),
and experimenting with a complicated set of ranges drawing tiles
with patterns.

Checkpoint 1
- Yes, at first it was difficult drawing squares using a for-loop.
I understood the definition of "square" with a for-loop in range of 4,
the 4 sides using once each, forward and right. I didn't realize that
the sizes = [20, 20, 20, 20] needed to be included within the code
where it tells "for size in sizes" the square size and move forward
to draw the next square. I reviewed the Iteration documentation several
times and online, docs.python.org/3/library/turtle.html. Also, I asked
you for assistance and then it made sense.

Checkpoint 2
- I liked using “ranges” to generate a sequence of numbers and
simplifying repetitive code.
- Defining the sizes for a def and range. Such as "def square(side_length)".
I see it's reference in "forward(side_length)", but (side_length) it seems
arbitrary and abstract. Is it how to best describe what the "def" is.
Are we talking about the name and value? And then defined within a
"for-loop" incorporating a "range"?

Checkpoint 3
- Yes, I will write docstrings when writing programs. The docstrings good
for writing multiple lines of information explaining the code function
by using """ at the beginning and end of the lines instead of " for each
line.
-Docstrings were useful with typing the explanation in tile_grid.py
and experimented information in tile.py files.
This commit is contained in:
kathrynoh23 2023-08-15 15:02:10 -04:00
parent 2c569a2096
commit 3dcfa5d315
18 changed files with 284 additions and 56 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,25 @@
# shapes.py
# ---------
# By MWC contributors
from turtle import *
pendown()
def rectangle(height_width):
forward(height_width)
right(90)
forward(height_width)
right(90)
forward(height_width)
right(90)
forward(height_width)
right(90)
rectangle(100)
rectangle(80)
rectangle(60)
rectangle(40)
rectangle(20)

View File

@ -1,4 +1,5 @@
# drawtiles.py
list# drawtiles.py
# ------------
# By MWC Contributors
#
@ -14,6 +15,7 @@ parser = ArgumentParser("python drawtiles.py", description="Draws a grid of tile
parser.add_argument("width", type=int, help="How many tiles across the grid should be")
parser.add_argument("height", type=int, help="How many tiles high the grid should be")
parser.add_argument("size", type=int, help="Side length of each tile")
"I tried at add Color Choice (4 colors) here and within tile_grid.py, but it didn't work"
parser.add_argument("--fast", action="store_true", help="Skip turtle animation and show the result")
args = parser.parse_args()
@ -23,4 +25,3 @@ if args.fast:
else:
draw_tile_grid(args.width, args.height, args.size, draw_tile)
input()

12
experimenting_circles.py Normal file
View File

@ -0,0 +1,12 @@
from turtle import *
#Circle
circle(20)
position()
(-0.00,0.00)
#Semi-circle
circle(40, 180)
(0.00,240.00)
done()

91
poetry.lock generated
View File

@ -42,13 +42,13 @@ lxml = ["lxml"]
[[package]]
name = "certifi"
version = "2023.5.7"
version = "2023.7.22"
description = "Python package for providing Mozilla's CA Bundle."
optional = false
python-versions = ">=3.6"
files = [
{file = "certifi-2023.5.7-py3-none-any.whl", hash = "sha256:c6c2e98f5c7869efca1f8916fed228dd91539f9f1b444c314c06eef02980c716"},
{file = "certifi-2023.5.7.tar.gz", hash = "sha256:0f0d56dc5a6ad56fd4ba36484d6cc34451e1c6548c61daad8c320169f91eddc7"},
{file = "certifi-2023.7.22-py3-none-any.whl", hash = "sha256:92d6037539857d8206b8f6ae472e8b77db8058fec5937a1ef3f54304089edbb9"},
{file = "certifi-2023.7.22.tar.gz", hash = "sha256:539cc1d13202e33ca466e88b2807e29f4c13049d6d87031a3c110744495cb082"},
]
[[package]]
@ -159,13 +159,13 @@ files = [
[[package]]
name = "furo"
version = "2023.5.20"
version = "2023.7.26"
description = "A clean customisable Sphinx documentation theme."
optional = false
python-versions = ">=3.7"
files = [
{file = "furo-2023.5.20-py3-none-any.whl", hash = "sha256:594a8436ddfe0c071f3a9e9a209c314a219d8341f3f1af33fdf7c69544fab9e6"},
{file = "furo-2023.5.20.tar.gz", hash = "sha256:40e09fa17c6f4b22419d122e933089226dcdb59747b5b6c79363089827dea16f"},
{file = "furo-2023.7.26-py3-none-any.whl", hash = "sha256:1c7936929ec57c5ddecc7c85f07fa8b2ce536b5c89137764cca508be90e11efd"},
{file = "furo-2023.7.26.tar.gz", hash = "sha256:257f63bab97aa85213a1fa24303837a3c3f30be92901ec732fea74290800f59e"},
]
[package.dependencies]
@ -285,13 +285,13 @@ files = [
[[package]]
name = "pygments"
version = "2.15.1"
version = "2.16.1"
description = "Pygments is a syntax highlighting package written in Python."
optional = false
python-versions = ">=3.7"
files = [
{file = "Pygments-2.15.1-py3-none-any.whl", hash = "sha256:db2db3deb4b4179f399a09054b023b6a586b76499d36965813c71aa8ed7b5fd1"},
{file = "Pygments-2.15.1.tar.gz", hash = "sha256:8ace4d3c1dd481894b2005f560ead0f9f19ee64fe983366be1a21e171d12775c"},
{file = "Pygments-2.16.1-py3-none-any.whl", hash = "sha256:13fc09fa63bc8d8671a6d247e1eb303c4b343eaee81d861f3404db2935653692"},
{file = "Pygments-2.16.1.tar.gz", hash = "sha256:1daff0494820c69bc8941e407aa20f577374ee88364ee10a98fdbe0aece96e29"},
]
[package.extras]
@ -342,13 +342,13 @@ files = [
[[package]]
name = "sphinx"
version = "7.0.1"
version = "7.1.2"
description = "Python documentation generator"
optional = false
python-versions = ">=3.8"
files = [
{file = "Sphinx-7.0.1.tar.gz", hash = "sha256:61e025f788c5977d9412587e733733a289e2b9fdc2fef8868ddfbfc4ccfe881d"},
{file = "sphinx-7.0.1-py3-none-any.whl", hash = "sha256:60c5e04756c1709a98845ed27a2eed7a556af3993afb66e77fec48189f742616"},
{file = "sphinx-7.1.2-py3-none-any.whl", hash = "sha256:d170a81825b2fcacb6dfd5a0d7f578a053e45d3f2b153fecc948c37344eb4cbe"},
{file = "sphinx-7.1.2.tar.gz", hash = "sha256:780f4d32f1d7d1126576e0e5ecc19dc32ab76cd24e950228dcf7b1f6d3d9e22f"},
]
[package.dependencies]
@ -393,45 +393,54 @@ docs = ["furo", "ipython", "myst-parser", "sphinx-copybutton", "sphinx-inline-ta
[[package]]
name = "sphinxcontrib-applehelp"
version = "1.0.4"
version = "1.0.7"
description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books"
optional = false
python-versions = ">=3.8"
python-versions = ">=3.9"
files = [
{file = "sphinxcontrib-applehelp-1.0.4.tar.gz", hash = "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e"},
{file = "sphinxcontrib_applehelp-1.0.4-py3-none-any.whl", hash = "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228"},
{file = "sphinxcontrib_applehelp-1.0.7-py3-none-any.whl", hash = "sha256:094c4d56209d1734e7d252f6e0b3ccc090bd52ee56807a5d9315b19c122ab15d"},
{file = "sphinxcontrib_applehelp-1.0.7.tar.gz", hash = "sha256:39fdc8d762d33b01a7d8f026a3b7d71563ea3b72787d5f00ad8465bd9d6dfbfa"},
]
[package.dependencies]
Sphinx = ">=5"
[package.extras]
lint = ["docutils-stubs", "flake8", "mypy"]
test = ["pytest"]
[[package]]
name = "sphinxcontrib-devhelp"
version = "1.0.2"
description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document."
version = "1.0.5"
description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp documents"
optional = false
python-versions = ">=3.5"
python-versions = ">=3.9"
files = [
{file = "sphinxcontrib-devhelp-1.0.2.tar.gz", hash = "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4"},
{file = "sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e"},
{file = "sphinxcontrib_devhelp-1.0.5-py3-none-any.whl", hash = "sha256:fe8009aed765188f08fcaadbb3ea0d90ce8ae2d76710b7e29ea7d047177dae2f"},
{file = "sphinxcontrib_devhelp-1.0.5.tar.gz", hash = "sha256:63b41e0d38207ca40ebbeabcf4d8e51f76c03e78cd61abe118cf4435c73d4212"},
]
[package.dependencies]
Sphinx = ">=5"
[package.extras]
lint = ["docutils-stubs", "flake8", "mypy"]
test = ["pytest"]
[[package]]
name = "sphinxcontrib-htmlhelp"
version = "2.0.1"
version = "2.0.4"
description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files"
optional = false
python-versions = ">=3.8"
python-versions = ">=3.9"
files = [
{file = "sphinxcontrib-htmlhelp-2.0.1.tar.gz", hash = "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff"},
{file = "sphinxcontrib_htmlhelp-2.0.1-py3-none-any.whl", hash = "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903"},
{file = "sphinxcontrib_htmlhelp-2.0.4-py3-none-any.whl", hash = "sha256:8001661c077a73c29beaf4a79968d0726103c5605e27db92b9ebed8bab1359e9"},
{file = "sphinxcontrib_htmlhelp-2.0.4.tar.gz", hash = "sha256:6c26a118a05b76000738429b724a0568dbde5b72391a688577da08f11891092a"},
]
[package.dependencies]
Sphinx = ">=5"
[package.extras]
lint = ["docutils-stubs", "flake8", "mypy"]
test = ["html5lib", "pytest"]
@ -452,30 +461,36 @@ test = ["flake8", "mypy", "pytest"]
[[package]]
name = "sphinxcontrib-qthelp"
version = "1.0.3"
description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document."
version = "1.0.6"
description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp documents"
optional = false
python-versions = ">=3.5"
python-versions = ">=3.9"
files = [
{file = "sphinxcontrib-qthelp-1.0.3.tar.gz", hash = "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72"},
{file = "sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6"},
{file = "sphinxcontrib_qthelp-1.0.6-py3-none-any.whl", hash = "sha256:bf76886ee7470b934e363da7a954ea2825650013d367728588732c7350f49ea4"},
{file = "sphinxcontrib_qthelp-1.0.6.tar.gz", hash = "sha256:62b9d1a186ab7f5ee3356d906f648cacb7a6bdb94d201ee7adf26db55092982d"},
]
[package.dependencies]
Sphinx = ">=5"
[package.extras]
lint = ["docutils-stubs", "flake8", "mypy"]
test = ["pytest"]
[[package]]
name = "sphinxcontrib-serializinghtml"
version = "1.1.5"
description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)."
version = "1.1.8"
description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)"
optional = false
python-versions = ">=3.5"
python-versions = ">=3.9"
files = [
{file = "sphinxcontrib-serializinghtml-1.1.5.tar.gz", hash = "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952"},
{file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"},
{file = "sphinxcontrib_serializinghtml-1.1.8-py3-none-any.whl", hash = "sha256:27849e7227277333d3d32f17c138ee148a51fa01f888a41cd6d4e73bcabe2d06"},
{file = "sphinxcontrib_serializinghtml-1.1.8.tar.gz", hash = "sha256:aaf3026335146e688fd209b72320314b1b278320cf232e3cda198f873838511a"},
]
[package.dependencies]
Sphinx = ">=5"
[package.extras]
lint = ["docutils-stubs", "flake8", "mypy"]
test = ["pytest"]
@ -497,13 +512,13 @@ sphinx = ">=7.0.1,<8.0.0"
[[package]]
name = "urllib3"
version = "2.0.3"
version = "2.0.4"
description = "HTTP library with thread-safe connection pooling, file post, and more."
optional = false
python-versions = ">=3.7"
files = [
{file = "urllib3-2.0.3-py3-none-any.whl", hash = "sha256:48e7fafa40319d358848e1bc6809b208340fafe2096f1725d05d67443d0483d1"},
{file = "urllib3-2.0.3.tar.gz", hash = "sha256:bee28b5e56addb8226c96f7f13ac28cb4c301dd5ea8a6ca179c0b9835e032825"},
{file = "urllib3-2.0.4-py3-none-any.whl", hash = "sha256:de7df1803967d2c2a98e4b11bb7d6bd9210474c46e8a0401514e3a42a75ebde4"},
{file = "urllib3-2.0.4.tar.gz", hash = "sha256:8d22f86aae8ef5e410d4f539fde9ce6b2113a001bb4d189e0aed70642d602b11"},
]
[package.extras]

View File

@ -9,15 +9,18 @@ def print_all_numbers(maximum):
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(0 + 1, maximum + 1, 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}")

View File

@ -1,16 +1,16 @@
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 side in range(4):
forward(side_length)
right(90)
sizes = [20, 20, 20, 20]
sizes = [20, 40, 60, 80, 100]
for size in sizes:
square(size)
square(size)
penup()
forward(size+20)
pendown()

View File

@ -0,0 +1,18 @@
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)
sizes = [20, 40, 60, 80, 100]
for size in sizes:
square(size)
#Drawing 4 squares inside a square

View File

@ -0,0 +1,20 @@
from turtle import *
def square():
for square in range(4):
forward(20)
right(90)
square()
penup()
forward(40)
pendown()
square()
penup()
forward(40)
pendown()
square()
penup()
forward(40)
pendown()
square()

17
square_sidebyside.py Normal file
View File

@ -0,0 +1,17 @@
from turtle import *
def square():
forward(100)
right(90)
forward(100)
right(90)
forward(100)
right(90)
forward(100)
right(90)
square()
forward(100)
square()
forward(100)
square()

View File

@ -0,0 +1,17 @@
from turtle import *
def square(side_length):
for side in range(4):
forward(side_length)
right(90)
sizes = [20, 60, 90, 120]
for size in sizes:
square(size)
penup()
forward(size+20)
pendown()
done()

View File

@ -0,0 +1,36 @@
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)
sizes = [20]
for size in sizes:
square(20)
penup()
forward(40)
pendown()
square(20)
penup()
forward(40)
pendown()
square(20)
penup()
forward(40)
pendown()
square(20)
penup()
forward(40)
pendown()
done()

14
tile.py
View File

@ -4,17 +4,25 @@ def draw_tile(size):
"Draws one tile, which can be repeated to form a pattern."
draw_tile_outline(size)
draw_squiggle(size)
"""Here. If you change outline the boxes are small, not connencted and squiggles drawing outside.
Here. If you change squiggles, they draw extremley small in bottom left corner of boxes, correct size."""
def draw_tile_outline(size):
pencolor("#dddddd")
"Changed Pen color from black to blue"
pencolor("blue")
pensize(2)
square(size)
def draw_squiggle(size):
pensize(3)
forward(size/4)
pencolor("black")
pencolor("purple")
left(90)
quarter_arc_right(size/4)
quarter_arc_left(size/4)
pensize(1)
pencolor("red")
quarter_arc_left(size/4)
quarter_arc_right(size/4)
left(90)
@ -42,3 +50,5 @@ def quarter_arc_right(radius):
def quarter_arc_left(radius):
"Draws a quarter of an arc, turning to the left."
circle(radius, 90)

View File

@ -10,7 +10,16 @@ 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.)
(The draw_tile_grid function is importing from the tile.py defined functions "draw_tile_outline" and
draw_squiggle to repeat the individual elements, tiles.
Within draw_tile_grid, you use a "range" to repeat the height and width for size and moving (fly) without
drawing. Then using the definition of "return_to_x_origin" and "return_to_y_origin" to the next x and y
coordinates to position the pen to draw the next tile or begin the next row.
Just as important is "drawtiles.py" file that calls the arguments/parameters for user input of width,
height, and size. Although, the if else statement is using the defintion "draw_tile" where the argument prompt
is coming from the "tile.py" definition "draw_tile.
The 3 python files, drawtiles.py, tile.py, and tile_grid.py are drawing functions from each file without
having to repeat the code in each file. Complicated and intricate. It's functional.)
"""
for y in range(height):
for x in range(width):

45
tile_new_pattern.py Normal file
View File

@ -0,0 +1,45 @@
from turtle import *
def draw_tile(size):
"Draws one tile, which can be repeated to form a pattern."
draw_tile_outline(size)
draw_squiggle(size)
def draw_tile_outline(size):
pencolor("#dddddd")
square(size)
def draw_squiggle(size):
forward(size/2)
pencolor("black")
left(90)
pendown()
quarter_arc_right(size/2)
quarter_arc_left(size/2)
quarter_arc_left(size/2)
quarter_arc_right(size/2)
left(90)
fly(size/2)
left(90)
fly(size)
left(90)
def fly(distance):
"Moves without drawing."
penup()
forward(distance)
pendown()
def square(size):
"Draws a square of side length `size`"
for side in range(4):
forward(size)
left(90)
def quarter_arc_right(radius):
"Draws a quarter of an arc, turning to the right."
circle(-radius, 90)
def quarter_arc_left(radius):
"Draws a quarter of an arc, turning to the left."
circle(radius, 90)