COMPUTER
PROGRAMMING
PYTHON
Learning Outcomes
–Lesson 1
Evaluate the effectiveness of Siri on the
iPhone
Create a “Hello World” program in the
Python
Identify and correct common errors in
Python programs
Create, save and test a 'Hello World'
program
You are going to create a
computer program that can think
and reply to a question like ‘Siri.
What is ‘Siri’?
Could you describe in 2 sentences?
Siri - Phone 4s -
http://youtu.be/5mNcnj2l6RE
Siri talks to Siri -
http://youtu.be/XBRXA8zmJr8
Siri – demonstration -
http://youtu.be/MpjpVAB06O4
Let’s start to program
Open the Python IDLE.
What does it look like?
Python IDLE
The command prompt
Write your first program
>>> print("Hello
World")
What happens?
Did you get this?
What happens if you type this?
>>> print(Hello
World)
Oh dear - something is wrong
Syntax errors
Computers follow instructions
EXACTLY!
Computers are not good at
dealing with nearly, almost,
not quite.
Syntax describes the rules
that must be used when
commands are written.
Colours
Different colours are used
for different elements to
help you.
In pairs – predict what will happen.
>>> print "Hello World"
>>> print ("Hello World");
>>> Print ("Hello World")
>>> print ("Hel World")
>>> prin (Hello World)
In pairs – find out what happens
>>> print "Hello World"
>>> print ("Hello World");
>>> Print ("Hello World")
>>> print ("Hel World")
>>> prin (Hello World)
Debugging
Now you know how to spot some
errors.
This is called DEBUGGING
This is really important because
you need to know how to correct
your mistakes.
Create, save and test a program
In IDLE click on
File and New Window
This is the
Edit mode
- there is
no
command
prompt
Interactive mode and file editor
Think of shopping……
If you are in the interactive mode
(IDLE) if you said “buy milk” it would
do it straight away, then “buy eggs”
etc
If you are in the editor it is like making
a list of items to buy which will only
work when you say “run shopping list”
Using the editor
Save the program Then press the f5
in your python key to run the
folder as my_name program
Using the editor
Save the program Then press the f5
in your python key to run the
folder as my_name program
What other programs can you write?
Add more questions into your
my_name program by copying
the first lines of code, pasting
them and changing the question
text.
Homework
Creating programs in Python
sheet
Review
–Lesson 1
Evaluate the effectiveness of Siri on the
iPhone
Create a “Hello World” program in the
Python
Identify and correct common errors in
Python programs
Create, save and test a 'Hello World'
program