You are on page 1of 13

WELCOME TO

PROGRAMMING CLUB!

Beginning.

Create a folder in My Documents called


Python
Open Python 3.3
Click file new
Welcome to IDLE!

Print Statement
Type the following into IDLE:
print(Hello World!)
print(Hello Again)
print(I like typing this.)
print(This is fun)
print(Yay! Printing.)
print(Id much rather you not.)
print(I said do not touch this.)

What do you notice are


the similarities between
all of the lines of code ?

YOU SHOULD HAVE GOT THIS


Swap with a partner after
youre done and check that
they have typed all of their
code correctly. Do this by
clicking the F5 button at the
top to run the program

COMMENTS
Create a comment in your code by using the octothorpe (otherwise known as the hash sign)
Type this into your program:

#A
#A print
print statement
statement is
is used
used to
to output
output a
a message
message
to
to the
the user
user

STUDY DRILL
Type three more print statements out:
- two of these should be correct
grammatically
-one of these should be incorrect
grammatically (i.e. use a capital letter for
print or have no speech marks, etc.)

SWAP WITH A PARTNERA DIFFERENT ONE


FROM LAST TIME
Check your partners code following these instructions:
1. Start from the last line
2. Read the line backwards and check that each part is correct
(it should end with a bracket, be followed by a speech
mark, have the text inside, speech mark, bracket, print).
3. If you find an error, type in a comment on the line below the
one you are checking. In your comment, say what the error
is and the corrected version
4. Go to the line above and repeat step 2-3, do this for all of the
lines of code

ONCE YOU HAVE DONE


Correct your code!
A key part of programming is
being able to spot your own
mistakes.

Why do I have
to read code
backward?

Its a trick to make


your brain not
attach meaning to
each part of the
code, and doing
that makes you
process each piece
exactly. This
catches errors and
is a handy error-

NUMBERS AND MATH

Notice how the


operations are
missing? After you
type in the code
for this exercise,
go back and figure
out what each of
these does and
complete the table
on the board.

EXERCISE TYPE OUT THE FOLLOWING IN A


NEW PROGRAM CALLED MATHS OPERATIONS
print(I will now county my chickens:)

The order to follow


is:
print(Roosters, 100 25 * 3 % 4)
print(Hens, 25 + 30 / 6)

print(Now I will count the eggs:)

PEMDAS

print(3 + 2 + 1 5 + 4 % 2 1 / 4 + 6)
print(Is it true that 3 + 2 < 5 7?)

Parenthesis
print(3 + 2 < 5 7)
(brackets)
print(Is is greater?, 5 > -2)
Exponents (powers)
Multiplication/Divisi
print(Is is greater or equal?, 5 ?=
-2)
on
print(Is it less or equal?, 5 <= -2)
Addition/Subtractio

MODULUS EXPLAINEDHOW DOES


WORK?
Another way to say it is X divide by Y with R
remaining. For example, 10 divided by 4 with 2
remaining
The result of % is the R part, or the remaining part.

INVESTIGATE:
What is the difference
between:
10 % 6 * 2
2 * 10 % 6

FOLLOW FROM LEFT TO RIGHT

Code is executed from left to right with


modulus
This means that if the modulus is first,
it will be carried out first, if it is
second, it will be carried out second