week1 python
DESCRIPTION
Introduction lesson to python programming!TRANSCRIPT
Welcome to Programming Club!
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 programComments
Create a comment in your code by using the octothorpe (otherwise known as the hash sign)
Type this into your program:
#A print statement is used to output a message to the 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:
Start from the last line
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).
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
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-checking technique.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:)
print(Hens, 25 + 30 / 6)
print(Roosters, 100 25 * 3 % 4)
print(Now I will count the eggs:)
print(3 + 2 + 1 5 + 4 % 2 1 / 4 + 6)
print(Is it true that 3 + 2 < 5 7?)
print(3 + 2 < 5 7)
print(Is is greater?, 5 > -2)
print(Is is greater or equal?, 5 ?= -2)
print(Is it less or equal?, 5