Flags

Task 1 - France

Write a program that will draw the French flag.

Algorithm

  1. Draw blue rectangle (100 x 200)
  2. Forward 100
  3. Draw white rectangle (100 x 200)
  4. Forward 100
  5. Draw red rectangle (100 x 200)

Code

from turtle import *
screen = getscreen()
tom = Turtle()

RectWidth = 100
rectHeight = 200
angle = 90

# BLUE STRIPE
tom.fillcolor("blue")
tom.begin_fill()
for counter in range(2):
    tom.forward(RectWidth)
    tom.right(angle)

    tom.forward(rectHeight)
    tom.right(angle)
tom.end_fill()

# MOVE TO NEXT STRIPE
tom.forward(RectWidth)

# WHITE STRIPE
tom.fillcolor("white")
tom.begin_fill()
for counter in range(2):
    tom.forward(RectWidth)
    tom.right(angle)

    tom.forward(rectHeight)
    tom.right(angle)
tom.end_fill()

# MOVE TO NEXT STRIPE
tom.forward(RectWidth)

# RED STRIPE
tom.fillcolor("red")
tom.begin_fill()
for counter in range(2):
    tom.forward(RectWidth)
    tom.right(angle)

    tom.forward(rectHeight)
    tom.right(angle)
tom.end_fill()

 

Task 2 - Germany

Write a program that will draw the German flag.

Algorithm

  1. Draw black rectangle
  2. Move down
  3. Draw red rectangle
  4. Move down
  5. Draw yellow rectangle

Code

from turtle import *
screen = getscreen()
tom = Turtle()

width = 450
height = 100
angle = 90

tom.fillcolor("black")
tom.beginfill()
for counter in range(4):
    tom.forward(width)
    tom.right(angle)
    tom.forward(height) 
    tom.right(angle)
tom.endfill()

# Draw red rectangle

# Draw yellow rectangle

 

Task 3 - England

Write a program that will draw the English flag.

Algorithm

  1. Draw horizontal red rectangle (100 x 200)
  2. Move o next position
  3. Draw vertical red rectangle (100 x 200)

Task 4 - Scotland

Write a program that will draw the Scottish flag.

Targets

State the code to create a variable

Identify the correct commands needed to solve a problem

Write a Python program to draw a flag