@Charanpreet/

Lab 4.03 Example - Dancing turtle

Python (with Turtle)

No description

fork
loading
main.py
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
import turtle

class DancingTurtle(turtle.Turtle):
  def shimmy(self):
    for _ in range(6):
      self.left(30)
      self.right(30)

  # Move in a zig-zag.
  def zig_zag(self):
    self.left(30)
    for _ in range(4):
      self.right(60)
      self.forward(20)
      self.left(60)
      self.forward(20)
    self.right(30)

  # Move forward and backward 10 times.
  def shake(self):
    pass
  
  # Change color to a random color.
  def change_color(self):
    pass

  # Point in the up direction. Then go up and down 3 times.
  # Then point back to the right.
  def jump_up_and_down(self):
    pass

  # Point in the up direction. Go up. Then do a 360 degree turn.
  # Come back down and then point to the right again.
  def do_backflip(self):
    pass

  # Move backwards 60 steps and forward 30 steps.
  # Repeat 6 times.
  def do_backwards_shuffle(self):
    pass


# Create a DancingTurtle and have it do some dance moves.
# Make sure to incorporate all of the dance moves.
dorothy = DancingTurtle()
dorothy.shape('turtle')
dorothy.penup()
dorothy.speed(3)
dorothy.goto(-300, 0)
for _ in range(3):
  dorothy.shimmy()
  dorothy.zig_zag()
result
console