From 5839a4d2a1c1516d733d7450ef96eea08d4101e4 Mon Sep 17 00:00:00 2001 From: grace-xing6 Date: Tue, 3 Sep 2024 20:55:27 -0400 Subject: [PATCH] I revised shapes code to make it work 2: function is a series of variables By defining different functions and combine them, they could solve small problems specifically and then combine to fix the big problems that can be defined by a series of small problems example: If you want to draw something complicated or design some games with many elements, you need to think the elements involved in it and define individual functions and combine them in a logical way to achieve it. --- shapes.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/shapes.py b/shapes.py index 731ec39..aee9b53 100644 --- a/shapes.py +++ b/shapes.py @@ -5,7 +5,23 @@ from turtle import * def triangle(side_length): - pass + forward(side_length) + right(120) + forward(side_length) + right(120) + forward(side_length) + right(120) + def rectangle(height, width): - pass + penup() + goto(100,100) + pendown() + forward(width) + right(90) + forward(height) + right(90) + forward(width) + right(90) + forward(height) + right(90) \ No newline at end of file