Python programming
Python programming
whiteboard
What is the difference between input and
output in Python? Provide an example for
each
Python programming
Revision lesson
Lesson Objective
• Understand what a variable is and why it’s important in programming.
• Learn the difference between input (user gives data) and output
(program shows data).
• Understand how iteration works, using for loops and while loops to
repeat tasks.
• Recognize common programming errors (syntax and logic) and learn
ways to write error-free code.
What is Iteration • Is a process of repeating steps
?
There are two techniques
- FOR LOOPS - Repeat for a fixed
number of times.
- WHILE LOOPS - Repeat as long as a
condition is true.
FOR LOOPS :
Repeat for a
Here are some fixed number of
different coding times
examples of FOR
LOOPS
# For each of the number in the range the code prints out
the value of i
Here are some WHILE LOOPS :
different coding Repeat as long
examples of as a condition
WHILE LOOPS is true
Input
#count starts at 0
#the loop runs as long a count is less
than 5
Input
Output
Selection
Input Output
Variables
Talk in pairs and decide which of these are good variable
names.
• postcode • first name
• number1
• print
• 2024_sales
• avg_score • totalSales
• 42
• zoo_closing time
• Surname
Variables ANSWERS
Talk in pairs and decide which of these are good variable
names.
• postcode • first name
• number1 • 2024_sales
• print • totalSales
• 42 • Surname
Input and output
• Instead of entering the name into our programming we could ask the
user to enter a first name.
display a message to ask
the user to input their
1 print("What’s your name?") name
2 f_name = input() the input command will
3 print("Hello", f_name) wait until they enter a
value and then store that
in the variable f_name
display a message saying
"Hello“ and the name
they entered
Variables
What is wrong with these variable names?
• print
• 42
• first name
• 2024_sales
• zoo_closing time
• Surname
Robust Programming
Is the ability of a computer system to cope
with errors during performance and cope
with incorrect input.
The two type of errors
• Syntax Errors
• Logic Errors
A spelling or grammatical
mistake in the program
Grammatical
Mistake
Syntax Errors
Spelling Mistake
Missing punctuation
(quotes and brackets)
A mistake in the logic of the
program
Missing all altogether
Float
Task
• Go on to teams finish off all the task from lesson
7
Plenary
What part of Python programming do you feel most confident about?