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.
This commit is contained in:
grace-xing6 2024-09-03 20:55:27 -04:00
parent e2c7bd9dc7
commit 5839a4d2a1
1 changed files with 18 additions and 2 deletions

View File

@ -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)