Exercises

Let's do some exercises to enhance your understanding.

Ex 1. Fix the box

This program doesn't work correctly. Can you fix it?

import turtle for a in 3: turtle.forward(100) turtle.left(90)

Ex 2. Many triangles

This program doesn't work correctly. Can you fix it?

import turtle number = input("How many triangles do you want?") for a in range(number): for a in range(3): turtle.forward(20) turtle.left(120) turtle.forward(30)

Ex 3. Sharing pizzas

Can you make this program work correctly? (Each pizza has 6 slices.)

pizzas = input("How many pizzas do we have?") students = input("How many students are in class?") slices = pizzas * 6 slices_per_student = slices / students print("Each student gets " + slices_per_student + " slices of pizzas.")

Ex 4. Draw a house

Write a program that draw the following house. Some of it has been done for you.

import turtle