0% found this document useful (0 votes)
6 views21 pages

Python L2 Calculations and Variables

This document provides an introduction to Python 3. It discusses basic Python syntax, variables, calculations, strings, lists, if/else statements, and loops. It also covers keywords, comments, order of operations, and saving Python scripts. The document is intended to teach programming concepts and objectives to students.

Uploaded by

muhaburiaz
Copyright
© © All Rights Reserved
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
Download as ppsx, pdf, or txt
0% found this document useful (0 votes)
6 views21 pages

Python L2 Calculations and Variables

This document provides an introduction to Python 3. It discusses basic Python syntax, variables, calculations, strings, lists, if/else statements, and loops. It also covers keywords, comments, order of operations, and saving Python scripts. The document is intended to teach programming concepts and objectives to students.

Uploaded by

muhaburiaz
Copyright
© © All Rights Reserved
Available Formats
Download as PPSX, PDF, TXT or read online on Scribd
Download as ppsx, pdf, or txt
Download as ppsx, pdf, or txt
You are on page 1/ 21

Introduction to Python

Introducing Python 3

Starter
• In your allocated group, you must as a group
together see if you can resolve the equation on the
whiteboard?
• You have around 4 min for this task. 1 st
Addition
• The equation is: 2nd Multiplication
3rd Division

30 + 20 * 15 / 2
Introduction to Python
Introducing Python 3

Getting it wrong
• Syntax Errors
• Experiment with errors

• In IDLE type the following erroneous lines:


primt ("Hello World!")
Print ("Hello World!")
print (Hello World!)
print "Hello World!"
Introduction to Python
Introducing Python 3

Keywords

Syntax: the arrangement of words and phrases to


create well-formed sentences
in a language.

Variable: not consistent or having a fixed pattern;


liable to change

Parenthesis: a pair of round brackets ( ) used to


mark off a parenthetical
word or phrase
Learning Objectives
• L1 To apply basic syntax calculations in
python (B)

• L2 To apply values to assigned variables


(D/E)

• L3 To understand the role of parenthesis


calculations in python(M)
IGCSE

IB
Introduction to Python
Introducing Python 3

What is a variable?
• A variable is a location in memory in which you can
temporarily store text or numbers
• It is used like an empty box or the Memory function
on a calculator
• You can choose a name for the box (the “variable
name”) and change its contents in your program
Introduction to Python
Introducing Python 3

Rules for naming variables


• A variable name can contain only numbers, letters
and underscores
• A variable name cannot start with a number
• You can’t use a Python “reserved word” as a variable
name – for example class is a reserved word so
class = input() will result in a syntax error
Introduction to Python
Introducing Python 3

Adding comments
• Comments are useful to help understand your code
• They will not affect the way a program runs
• Comments appear in red
• Comments have a preceding # symbol

#firstname is a variable
print ("What is your name?")
firstname = input()
print ("Hello,",firstname)
Introduction to Python
Introducing Python 3

Calculations
Introduction to Python
Introducing Python 3

Task
• Work through the booklet
‘Calculations and Variables’;
• Add comments after each segment
of code;
• When stopped, you must stop and
listen for specific instructions.
Introduction to Python
Introducing Python 3

Task (2 min max)


• Explain to the person next to you on what you have
done do far and what have you learnt? (1 min each)
Introduction to Python
Introducing Python 3

Task
• Work through the booklet
‘Calculations and Variables’;
• Add comments after each segment
of code;
• When stopped, you must stop and
listen for specific instructions.
Introduction to Python
Introducing Python 3

Task (2 mins max)


• Explain to a different person from last time on what
you have done do far and what have you learnt?
(1 min each)
Introduction to Python
Introducing Python 3

Task
• Work through the booklet
‘Calculations and Variables’;
• Work through the booklet
‘Strings and Lists’; ‘If loops’
• Add comments after each segment
of code;
• When stopped, you must stop and
listen for specific instructions.
Introduction to Python
Introducing Python 3

Task (3 min max)


• On the post-it note stuck on your PC, you must:
• Write your name;
• Write down where you think you are with the
learning intention and state why?
• Come to the whiteboard and stick your post-it note to
the correct learning intention.
Learning Objectives
• L1 To apply basic syntax calculations in
python (B)

• L2 To apply values to assigned variables


(D/E)

• L3 To understand the role of parenthesis


calculations in python(M)
Introduction to Python
Introducing Python 3

Saving your python scriptor...


Introduction to Python
Introducing Python 3

Parenthesis…
Introduction to Python
Introducing Python 3

Order of Operation Example


Real life situation:
Joe buys 2 shirts at $8.00 each.
He also buys a pair of jeans for
$20.00 that gets a $3.00
discount.
2 shirts + jeans – discount = cost
(2 x $8) + ($20 - $3) = $33
Introduction to Python
Introducing Python 3

Starter
• In your allocated group, you must as a group
together see if you can resolve the equation on the
whiteboard?
• You have around 4 min for this task. 1 st
Addition
• The equation is: 2nd Multiplication
3rd Division

30 + 20 * 15 / 2
Introduction to Python
Introducing Python 3

Exit pass – please fill in.

1st Addition
• Q1 Equation: 2nd Subtraction
3rd Division
40 – 67 + 15 / 2

You might also like