@Charanpreet/

3.06 Starter Code - Drawing shapes

Python (with Turtle)

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.6172615849226593","path":"main.py","file":{"path":"main.py","content":{"asEncoding":{"base64":"aW1wb3J0IHR1cnRsZQoKZGVmIGRyYXdfc3F1YXJlKHNpZGVfbGVuZ3RoKToKICBzdGFydGluZ194ID0gdHVydGxlLnhjb3IoKQogIHN0YXJ0aW5nX3kgPSB0dXJ0bGUueWNvcigpCiAgdHVydGxlLnNldGhlYWRpbmcoMCkKICB0dXJ0bGUucGVuZG93bigpCiAgdHVydGxlLmZvcndhcmQoc2lkZV9sZW5ndGgpCiAgdHVydGxlLmxlZnQoOTApCiAgdHVydGxlLmZvcndhcmQoc2lkZV9sZW5ndGgpCiAgdHVydGxlLmxlZnQoOTApCiAgdHVydGxlLmZvcndhcmQoc2lkZV9sZW5ndGgpCiAgdHVydGxlLmxlZnQoOTApCiAgdHVydGxlLmZvcndhcmQoc2lkZV9sZW5ndGgpCiAgdHVydGxlLnBlbnVwKCkKCmRlZiBkcmF3X3JlY3RhbmdsZSh3aWR0aCwgaGVpZ2h0KToKICBzdGFydGluZ194ID0gdHVydGxlLnhjb3IoKQogIHN0YXJ0aW5nX3kgPSB0dXJ0bGUueWNvcigpCiAgdHVydGxlLnNldGhlYWRpbmcoMCkKICB0dXJ0bGUucGVuZG93bigpCiAgdHVydGxlLmZvcndhcmQod2lkdGgpCiAgdHVydGxlLmxlZnQoOTApCiAgdHVydGxlLmZvcndhcmQoaGVpZ2h0KQogIHR1cnRsZS5sZWZ0KDkwKQogIHR1cnRsZS5mb3J3YXJkKHdpZHRoKQogIHR1cnRsZS5sZWZ0KDkwKQogIHR1cnRsZS5mb3J3YXJkKGhlaWdodCkKICB0dXJ0bGUucGVudXAoKQoKCmRlZiBkcmF3X2VxdWlsYXRlcmFsX3RyaWFuZ2xlKHNpZGVfbGVuZ3RoKToKICBzdGFydGluZ194ID0gdHVydGxlL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gLTEwMCkKdHVydGxlLmNvbG9yKCdyZWQnKQpkcmF3X3NxdWFyZSg4MCkKdHVydGxlLmdvdG8oMTAwLCAtMTAwKQp0dXJ0bGUuY29sb3IoJ2JsdWUnKQpkcmF3X3JlY3RhbmdsZSgxMDAsODApCnR1cnRsZS5nb3RvKC0xMDAsMTAwKQp0dXJ0bGUuY29sb3IoJ3llbGxvdycpCmRyYXdfZXF1aWxhdGVyYWxfdHJpYW5nbGUoMTAwKQp0dXJ0bGUuZ290bygxMDAsIDEwMCkKdHVydGxlLmNvbG9yKCdvcmFuZ2UnKQpkcmF3X3JlZ3VsYXJfaGV4YWdvbigxMDAp"},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import turtle

def draw_square(side_length):
  starting_x = turtle.xcor()
  starting_y = turtle.ycor()
  turtle.setheading(0)
  turtle.pendown()
  turtle.forward(side_length)
  turtle.left(90)
  turtle.forward(side_length)
  turtle.left(90)
  turtle.forward(side_length)
  turtle.left(90)
  turtle.forward(side_length)
  turtle.penup()

def draw_rectangle(width, height):
  starting_x = turtle.xcor()
  starting_y = turtle.ycor()
  turtle.setheading(0)
  turtle.pendown()
  turtle.forward(width)
  turtle.left(90)
  turtle.forward(height)
  turtle.left(90)
  turtle.forward(width)
  turtle.left(90)
  turtle.forward(height)
  turtle.penup()


def draw_equilateral_triangle(side_length):
  starting_x = turtle.xcor()
  starting_y = turtle.ycor()
  turtle.setheading(0)
  turtle.pendown()
  turtle.forward(side_length)
  turtle.left(120)
  turtle.forward(side_length)
  turtle.left(120)
  turtle.forward(side_length)
  turtle.penup()


def draw_regular_hexagon(side_length):
  starting_x = turtle.xcor()
  starting_y = turtle.ycor()
  turtle.setheading(0)
  turtle.pendown()
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.left(60)
  turtle.forward(side_length)
  turtle.penup()


# BONUS
def draw_regular_polygon(num_sides, side_length):
  pass



# Use your functions to draw a picture:
turtle.penup()
turtle.goto(-100, -100)
turtle.color('red')
draw_square(80)
turtle.goto(100, -100)
turtle.color('blue')
draw_rectangle(100,80)
turtle.goto(-100,100)
turtle.color('yellow')
draw_equilateral_triangle(100)
turtle.goto(100, 100)
turtle.color('orange')
draw_regular_hexagon(100)
result
console