8.2 Python Geometry Art
STARTERS / ENDERS |
Extension: |
INTRODUCTION:
This term we're going to be learning a computer programming language called Python. The person who created Python named it after his favourite TV show: Monty Python’s Flying Circus. Python is used by loads of programmers for many different things. Python is a powerful and clever language, used at YouTube, NASA, CERN and others.
Download these files that you will need for the first two weeks:
Download these files that you will need for the first two weeks:
|
|
Sabotage
#SABOTAGE
#A program that takes an input and stores it in a VARIABLE
print ("My name is _________ ")
input = name("Whats your name\n")
print ("Hello + name " Nice to meet you!")
colour = input("Whats your favourite colour?")
print ("Wow " colour + " is my favourite colour too!")
#A program that takes an input and stores it in a VARIABLE
print ("My name is _________ ")
input = name("Whats your name\n")
print ("Hello + name " Nice to meet you!")
colour = input("Whats your favourite colour?")
print ("Wow " colour + " is my favourite colour too!")
Turtle Time!
Homework Zone 1 - https://quizizz.com/admin/quiz/5bbc9d0e501f76001a13cde8/python-y8z1
Homework Zone2 - https://quizizz.com/admin/quiz/5bb87b2522b20d001aa58d75/python-y81
Next, we're going to have some fun with turtles. A turtle is a tiny robot that draws on your screen, we can tell it to move around using Python commands.
Open IDLE, the editor that comes with Python. All our code will be written in this editor. When you open it,you will
see an Output window, where errors and results will appear. click file new window to open the script mode.
|
|
|
REPEATING YOURSELF (WITH A FOR LOOP)
That last program was the same commands over and over again . Instead of writing them down, let's ask the computer to repeat them for us. You should have encountered iteration in Scratch before using the forever and repeat/repeat until blocks. In Python for loops are used when you have a piece of code which you want to repeat n number of times. In this case we want to repeat the code (that is indented) 4 times (because a square has 4 sides).
STEP 5: TURN, TURN, TURN
Instead of us working out the angle, why don't we let the computer do it for us. Python can let you do some operations on numbers, like addition, subtraction,multiplication and division.
STEP 6: SOLID SHAPE
We can ask the turtle to fill in shapes with a colour, by using begin fill and end fill commands
STEP 7: PEN GOES UP, PEN GOES DOWN
If you want to move the turtle without leaving a trail behind it, you can use pen up and pen down to turn drawing on and off.
STEP 8: GO WILD!
You can go forward() , backward(),left(),right() ,you can loop using for count in range (4), change colours, change speed and even fill in shapes! What shapes can you draw?
That last program was the same commands over and over again . Instead of writing them down, let's ask the computer to repeat them for us. You should have encountered iteration in Scratch before using the forever and repeat/repeat until blocks. In Python for loops are used when you have a piece of code which you want to repeat n number of times. In this case we want to repeat the code (that is indented) 4 times (because a square has 4 sides).
STEP 5: TURN, TURN, TURN
Instead of us working out the angle, why don't we let the computer do it for us. Python can let you do some operations on numbers, like addition, subtraction,multiplication and division.
STEP 6: SOLID SHAPE
We can ask the turtle to fill in shapes with a colour, by using begin fill and end fill commands
STEP 7: PEN GOES UP, PEN GOES DOWN
If you want to move the turtle without leaving a trail behind it, you can use pen up and pen down to turn drawing on and off.
STEP 8: GO WILD!
You can go forward() , backward(),left(),right() ,you can loop using for count in range (4), change colours, change speed and even fill in shapes! What shapes can you draw?
Resources:
Evaluation |