"> ");
100%
LESSONS & TOPICS

Exercises Lists, other Collections Data Types & Iterations

Exercises Lists, other Collections Data Types & Iterations

Exercises

 

Exercise 1

(Please use IDLE editor)

After you create a new turtle named Alex and a new window to move the turtle named window, then draw a square side 10 by using the repeat command for.

Exercise 2

(Please use IDLE editor)

Write the code below for the same turtle


for number in range (100):
[TAB]for i in range (4):
[TAB][TAB]Edison.forward (100)
[TAB][TAB]Edison.left (90)
[TAB][TAB]Edison.left (25)


Run the code to see the result.
Try to explain how it works.
Which instructions make up the loop of the first for? The second?
The idea of the developer was to first create a square. So he first made the inner loop. Then he decided to create 100 same squares so he created the second for. To prevent the squares falling over each other, she/he decided, before creating each new square, to turn the turtle just a bit.

 

Exercise 3

Change this Python program to create the multiplication table (from 1 to 10) of given number.

ex.


Exercise 4

Write a program so that when your Edison robot drives, it makes a triangle.

Use coloured tape to mark the lines and a ‘start’ point on a desk or the floor. Download your program and test there, placing your Edison at the ‘start’ point and following the lines.

Exercise 5

Write a program so that when your Edison robot drives, it makes a hexagon.

Use coloured tape to mark the lines and a ‘start’ point on a desk or the floor. Download your program and test there, placing your Edison at the ‘start’ point and following the lines.

 

Write a program where your Edison robot drives in a circle. Your Edison needs to drive in the shape of a circle, not just spin in one spot.
Download your program and test it using the activity sheet above this paragraph, placing your Edison at the ‘start’ point and following the line. You can also make your robot drive around any circular object, like a round rubbish bin or a round table.
Hint: A shape with many hundreds of very small sides can closely approximate a circle.

 

Click the following link to get access to more exercises..