I drew my favorite animal - a penguin.

Just trying to learn the language more efficiently and I believe this project helped heavily.
This commit is contained in:
Mike 2023-08-10 11:51:30 -04:00
parent 70a9a8957b
commit 9a01280a35
2 changed files with 88 additions and 15 deletions

View File

@ -5,3 +5,76 @@
# (Briefly describe what this program does.)
from turtle import *
from superturtle.movement import no_delay
# We'll define our functions in terms of units.
def square(unit):
"Draws a square of size unit"
begin_fill()
for side in range(4):
forward(unit)
right(90)
end_fill
def row_of_squares(unit, quantities_and_colors):
"Draws a row of squares, one in each color in colors"
begin_fill()
for quantity, color in quantities_and_colors:
fillcolor(color)
for each_square in range(quantity):
square(unit)
forward(unit)
end_fill()
def go_back(unit, quantities_and_colors):
total = 0
for quantity, color in quantities_and_colors:
total += quantity
right(90)
forward(unit)
right(90)
forward(unit * total)
left(90)
left(90)
drawing_size = 20
data = [
[[3, "white"], [5, "black"], [3, "white"]],
[[3, "white"], [3, "black"], [1, "white"], [1, "black"], [3, "white"]],
[[3, "white"], [5, "black"], [1, "orange"], [2, "white"]],
[[3, "white"], [5, "black"], [1, "orange"], [2, "white"]],
[[3, "white"], [4, "black"], [4, "white"]],
[[3, "white"], [4, "black"], [4, "white"]],
[[3, "white"], [4, "black"], [4, "white"]],
[[3, "black"], [7, "black"], [1, "white"]],
[[3, "white"], [1, "black"], [2, "white"], [1, "black"], [4, "white"]],
[[3, "white"], [1, "black"], [2, "white"], [1, "black"], [4, "white"]],
[[3, "white"], [1, "black"], [2, "white"], [1, "black"], [4, "white"]],
[[3, "white"], [4, "black"], [4, "white"]],
[[3, "white"], [1, "orange"], [2, "white"], [1, "orange"], [4, "white"]],
]
with no_delay():
for row in data:
row_of_squares(drawing_size, row)
go_back(drawing_size, row)
go_back
input()

30
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]
@ -497,13 +497,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]