Академический Документы
Профессиональный Документы
Культура Документы
Introduction to Python
Learning to Program
What you need to be good at
Computing?
What you should be good
at?
Mathematics
Science (Physics)
Problem Solving
WHAT IT INVOLVES
Third Generation
Second Generation
First Generation
Hardware
What is a program then?
Sequence of instructions
Input
Process
Math
Branches: (Conditional execution)
Loops: (Repetition)
Output
Syntax errors
Runtime errors
Semantic errors
Programming and Debugging are the same
thing!
Only superheroes can write more than a few
lines of code without making a mistake.
SO
We write a tiny program, fix it, write a tiny bit
more, fix that,
.. and so on .
.. forever
Lets start using Python
Save it &
Press F5
Look at the
shell
Task 2
Task 2a
Change the program so it says - Pleased to meet
you.
String is the programming term for text (i.e. letters, numbers and symbols).
Variable names can contain letters and numbers but should always start with a letter.
We assign a value to a variable using =
Task 3
Copy and run the following program:
name='Bob'
print('Hello '+name)
Try this out
name='Bob'
name=name+'by'
print('Hello '+name)
This will print Hello Bobby
Whereas
name='Bob'
name=name+name
print('Hello '+name)
Will print Hello BobBob
Challenge Time
Complete the following program so it uses the
variables to print out the cat sat on the mat.
Remember you will need to add spaces.
E.g.
word1='the'
word2='cat'
word3='sat'
word4='on'
word5='mat'
Lesson 2 Task 4 Extension - Inputting
Data
We can now look at starting to make our
programs interactive. We are going to take in
input from the user using the input function.