G: Python Assessment

Task 1: Python Shell
Open a word document and put your name in the header [3 marks]
Open Python Shell (do not open a new file). Do the following calculations and screenshot An example is below

12 divided by 3
15 take 5
45 times 55
[3 marks]

Task 2: Finish code
Open Python IDLE and create a new file and save it
The following shapes have not been finished. Your task is to finish them and screenshot
[3 marks]
Square

1
2
3
4
5
6
import turtle # allows us to use the turtles library
wn = turtle.Screen() # creates a graphics window
ted= turtle.Turtle() # create a turtle named alex
ted.forward(150) # tell alex to move forward by 150 units
ted.left(90) # turn by 90 degrees
ted.forward(75)

Triangle

1
2
3
4
5
6
7
import turtle
window = turtle.Screen()
window.bgcolor("green") #background color
tom = turtle.Turtle()
tom.forward(100)
tom.left(120)
tom.forward(100)

Task 3:
Adapt the code for square so that it is a rectangle (2 sides longer)
[1 mark]
Task 4: Drawing Shapes
Copy and paste the following code into Python IDLE. Add a function for a square and a triangle. Adapt the code to make 3 more stars and one more triangle
[3 marks]
Add code for a square [3 marks]

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import turtle
shape = turtle.Turtle()

def star():
    for i in range(5):
        shape.forward(50)
        shape.right(144)

def hexagon():
    num_sides = 6
    side_length = 70
    angle = 360.0 / num_sides

    for i in range(num_sides):
        shape.forward(side_length)
        shape.right(angle)

star()
shape.penup()
shape.forward(200)
shape.pendown()
hexagon()

Task 5: Olympic Rings
[6 marks]
You have the code for part of the Olympic rings. Complete the Olympic rings. If you can’t remember the colour order google it.

olympic Rings Code

EXTENSION

Go to the following tutorials and experiment
Tutorial 1
Tutorial 2