Watch the video and take notes, paying attention to how different types of data held in variables are used to complete math simple functions.
Run and walk through the example (in code window).
Read the task and write code to solve.
Make a note of successful code in your book.
Answer questions in your book.
Watch the video and create notes in order to be able able to apply the knowledge given.
+ addition 13 = 10 + 3
- substraction 7 = 10 - 3
/ divide 3.3333 = 10 / 3 (always gives decimal answer)
// floor divide 3 = 10 // 3 (rounds answer to int)
* multiply 30 = 10 * 3
** exponent 1000 = 10 ** 3 (10x10x10)
% modulus 1 = 10 % 3 (remainders)
#Example code (Simple Math)
num1 = 10 # The variable num1 is assigned the integer number 10
num2 = 5 # The variable num2 is assigned the integer number 5
total = num1 + num2 # The variable total is assigned to hold the result of the sum of num1 and num2
print(total) # prints out the total to inform the user
Apply your knowledge and write a program that will use the following variables and assigned numbers. The printed output from the program should be 100.
# Code exercise (Simple Math)
num1 = 10
num2 = 20
num3 = 2
# Answer by completing math below
total =
print(total)
num1 = 10
num2 = 20
num3 = 2
total = num1 * num2 // num3
print(total)
total = 29 - 4 * 6 + 5
Calculate the value held in the above total variable.
Describe the purpose of BIDMAS in math.
Identify by converting the calculation into code and running it, do computers use BIDMAS?
Give the corrected calculation
total =
total = 29 - 4 * 6 + 5
Calculate the value held in the above total variable.
The answer should be 0 when completed using BIDMAS
B
I
D
M 24 = 4 * 6
A 29 = 24 + 5
S 0 = 29 - 29
Describe the purpose of BIDMAS in math.
BIDMAS means; Brackets, Indices, Division, Multiplication, Addition, Subtraction. It describes the order a mathematical calculation should be performed.
Identify by converting the calculation into code and running it, do computers use BIDMAS?
Yes computers follow the rules of BIDMAS and they need direction when performing complex math.
Give the corrected calculation to achieve the desired outcome of 155
total = (((29 - 4) * 6 ) + 5)