Log in
Sign up for FREE
arrow_back
Library
L2 Python KPRIDE: Math Operators
By Matthew Chau
star
star
star
star
star
Share
share
Last updated 9 months ago
12 questions
Add this activity
Learning Objectives:
I can tell someone what an algorithm is
I know how to create a simple Python Program (Input and Output)
I can explain and debug an algorithm/Python Program
D
ebug
Click on each link and try dragging and dropping code into the correct order
https://7strikelink7.github.io/NormalPythonParsons/parsons/Maths.html
For GCSE, you must know the following for programming:
Outputs and Inputs
Variables
Maths Operators
Random numbers
Strings and Casting
Booleans
If, elif, else
Nested Ifs
For loops
While loops
Nested loops
Arrays/Lists
2D Lists
File handling
Subprograms(functions/procedures)
Warm-up Practice:
https://type.withcode.uk/python/Variables_and_Constants
K
eywords
Sequence:
Lines of code are run in order they appear once.
* symbol:
Multiply e.g. 2 * 4 = 8
/ symbol:
Divide e.g. 10 / 5 = 2
// Integer Division symbol:
this only gives a whole number e.g. 11 // 5 = 2
% Modulus symbol:
this gives the whole number remainder e.g. 11//2 = 1
+ symbol:
Add numbers or Concatenate strings e.g. 5 + 2 = 7 e.g. "Hello " + "World" = "Hello World"
** symbol:
To the power of. e.g. 2 ** 3 = 8 (This is 2 x 2 x 2)
P
redict and
R
un
Look at the code for each question.
What do you think will be the output?
What is the actual output?
1
1
1
1
1
1
1
1
I
nvestigate
Look at the code on the right.
Run it and see what it does.
Click on the pencil icon at the top to see the code again.
First Example:
change
Second Example:
Change the variable - basketCanHold to another number.
What do you think str( ) does?
E
xtend
Help:
print ( ) is used to output text
input( ) is used to get the user to type something
Variables store values that can change.
Name = Value here
e.g. myName = "John"
1
Question 9
9.
Make a program to create a variable called myAge, then add 7. Output the message: "In Dog years, you are [age + 7] years old!"
myAge = 12
Outputs: In dog years, you are 19 years old!
1
Question 10
10.
Output the result of two numbers multiplied by each other
e.g. 5 x 3
Outputs: 15
1
1
Question 1
1.
What will be printed by the following code:
print(6 * 3)
18
6
333
666
Question 2
2.
What will be printed by the following code:
print("Hi " * 3)
Hi * 3
HiHiHi
Hi Hi Hi
Error - not possible to multiply words by numbers
Question 3
3.
What will be printed by the following code:
print("Password" + "123")
123
Password123
Password+123
Error - not possible to add words and numbers
Question 4
4.
What will be printed by the following code:
print(3 * 3 * 3)
9
27
333
Error - not possible to multipy 3 numbers
Question 5
5.
What will be printed by the following code:
print(3** 3)
9
27
333
Error - not possible to multipy 3 numbers
Question 6
6.
What will be printed by the following code:
print(13 / 2)
6
2
6.5
1
Question 7
7.
What will be printed by the following code:
print(13 // 2)
6
2
6.5
1
Question 8
8.
What will be printed by the following code:
print(13 % 2)
6
2
6.5
1
Question 11
11.
Output the result of a number multiplied to the power of 4.
e.g. 2 to the power of 4
Outputs: 32 (2x2x2x2)
Question 12
12.
CHALLENGE:
Create two variables to store two numbers.
Divide the first number by the second number to give the answer as a whole number, and how much is remaining.
Number 1: 11
Number 2: 4
Outputs: 11 divided by 4 is 2
Outputs: remainder 3