generated from mwc/lab_names
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:
parent
e2c7bd9dc7
commit
5839a4d2a1
20
shapes.py
20
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)
|
Loading…
Reference in New Issue