

Russian Multiplication
Presentation
•
Computers, Mathematics
•
10th - 11th Grade
•
Medium
Coder Dojo
Used 6+ times
FREE Resource
26 Slides • 11 Questions
1
Russian Multiplication
Say what.....!
What does this have to do with coding?

2
The Basics
To mulitply two numbers together
Essentially doubling one number and halving the other, with a twist
3
Basics - MODULUS
Divide by a number and keep the remainder
Python - %
Other languages - MOD
Example 14 % 4 = 2 (4 goes into 14, 3 times (12) with remainder 2 )
Try it in Python
4
Multiple Choice
Try it - 35 % 5
in your head and in Python Print(35 %5)
5
3
0
1
5
Multiple Choice
Try it 77 % 6
5
7
2
8
6
Basics - INTEGER or FLOOR DIVISION
Divide by a number and ignore the remainder
Python - // (double forward slash)
Other languages - DIV
Example 14 // 4 = 3 (4 goes into 14 3 times (12) ignore the remainder)
Try it in Python
7
Multiple Choice
Try it - 45 // 6
in Python and your head
4
5
6
7
8
Multiple Choice
Try it - 66 // 6
6
11
9
3
9
Step by Step
We are going to multiply 23 x 47
The correct answer is 1081
REMINDER, one side is doubled the other side integer divide by 2 (halving)
10
We know the answer as a check
Work across each row, double one side and integer divide the other.
Any row where there is a remainder highlight, the other rows we don't need
Then add up the doubling numbers.. 23 + 46 + 92 + 184 + 736 = 1081
11
Your turn, an easier one
Find the product of 17 * 5
Answer we are looking for is
17*5 = 85
12
Multiple Choice
17 doubled is
17
52
34
6
13
Multiple Choice
5 // 2 is
2.5
3
2
1
14
Keep building up your table
Russian peasants would do all of this in the head out in the field
Me, I'd need a little more time
You should have something looking like this
15
Why are we doing this??
We are going to create a flowchart of this process and then code it up in Python....
16
Flowcharts
Help with your algorithm and then help you with your code
(Main symbols shown, for exam don't need to remember the annotation one)
The predefined process symbol would typically have a full flowchart created
Image from Wikipedia
17
Russian Multiplication - Flowchart
Should ALWAYS have a start and end
All routes should eventually reach the end
This is a first untested draft!! BEWARE
18
Multiple Choice
What does this symbol mean
Terminator
Decision
Sub Process
Process
Input / output
19
Multiple Choice
What does this symbol mean
Decsion
Terminator
Sub Process
Process
Input / output
20
Multiple Choice
What does this symbol mean
Process
Terminator
Sub Process
Decision
Input / output
21
Multiple Choice
What does this symbol mean
Process
Terminator
Input / output
Decision
Sub Process
22
Multiple Choice
What does this symbol mean
Process
Terminator
Input / output
Decision
Sub Process
23
Trace Table
To check our flowchart does what we expect we can create a trace table
Trace table simply allows us to check each step
Let's do one for our example of 17 * 5
24
Create a table with the following headings
num1
num2
total
num2 = 1?
num2(MOD2) =1?
Can use any tool ( excel, word, powerpoint or pen an paper!)
25
This is what mine looks like to start
Work logically down the page
Don't trust what I have done!
Use that thing on top of your shoulders!!
DON'T change slide until you have a thought in your head that what I've done is ok...
REMINDER:- DON'T change slide until you have a thought in your head that what I've done is ok...
26
This is what mine looked like
so I boobed!!
can you work out what needs to change?
total = 17, when it ought to total 85
27
Problem area
Discuss if this is the right error and if where I think it should go fixes the problem
28
Problem area
Or is this a better way to correct, why have I put a line through the zero?
29
Ask me why!
30
Discussion
Original problem
Algorithm
Flow Chart
Trace Table
And we've not done some pseudocode
We've not coded it yet!
All steps are not always needed
31
pseudocode ( describes the steps )
input first number
input second number
set total to zero
while num2 not equal to Zero
____if num2 is ODD (MOD2):
________add num1 to total
____num1 doubled
____num2 DIV 2 (integer divide)
print out total
(note I have had to use _ here to pad out)
32
Programming Constructs we have ued
Sequence - Writing down in the order that they happen
Selection - If this then do this or something else
Iteration - Loops, Do or Repeat loops when you know how many times, While loops when testing for a condition
33
Now you can code it!
Next two slide are my first attempt and then a tidy up taking on board other concepts
Don't peep forward until you have had a go!!
34
No peeping!!
35
First Attempt
num1 = input("What is the first number? ")
num2 = input("What is the second number? ")
total = 0
while num2 != 0:
____if (num2%2 != 0):
________total= total+num1
____num1 = num1 * 2
____num2 = num2 //2
print("the product is",(total))
NOTE_ has been used for padding
36
Second Attempt
num1 = int(input("What is the first number? "))
num2 = int(input("What is the second number? "))
total = 0
# != 0 is not needed: num2 is True if it is not 0
while num2:
# no need to have brackets here
____if num2 % 2:
________total += num1 # shorthand for total = total + num1
____num1 *= 2 # shorthand for num1 = num1 * 2
____num2 / /= 2 # shorthand for num2 = num2 DIV 2
print("the product is", (total))
37
Discuss what you have learnt
Programming constructs
Sequence ( the order of the code )
Selection ( if statements )
Iteration ( loops)
Flowcharts
Psudocode
It's OK to make mistakes! It's important to learn from them!!
Russian Multiplication
Say what.....!
What does this have to do with coding?

Show answer
Auto Play
Slide 1 / 37
SLIDE
Similar Resources on Wayground
32 questions
4.15 U7.L1 Trapezoids & Parallelograms
Lesson
•
10th - 11th Grade
34 questions
World War II: The Homefront
Lesson
•
10th - 11th Grade
32 questions
Complete the Square
Lesson
•
10th Grade
30 questions
Unit 2.6: Fossil Fuels
Lesson
•
9th - 12th Grade
32 questions
Circle Vocabulary & Central Angles
Lesson
•
11th Grade
31 questions
Intro to the Mole and Molar Mass
Lesson
•
10th - 11th Grade
27 questions
Triangle Congruence Practice
Lesson
•
9th - 11th Grade
27 questions
Intro to Polynomials
Lesson
•
10th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
14 questions
Boundaries & Healthy Relationships
Lesson
•
6th - 8th Grade
13 questions
SMS Cafeteria Expectations Quiz
Quiz
•
6th - 8th Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
12 questions
SMS Restroom Expectations Quiz
Quiz
•
6th - 8th Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
10 questions
Pi Day Trivia!
Quiz
•
6th - 9th Grade
Discover more resources for Computers
15 questions
Pi Day Trivia
Quiz
•
9th - 12th Grade
10 questions
Understanding Pi and Its Applications
Interactive video
•
7th - 12th Grade
10 questions
Cell Organelles and Their Functions
Interactive video
•
6th - 10th Grade
5 questions
Did You Know? Ireland
Interactive video
•
9th - 10th Grade
10 questions
Exploring Basic Probability Concepts
Interactive video
•
6th - 10th Grade
20 questions
Figurative Language Review
Quiz
•
10th Grade
15 questions
Pi Day Trivia
Quiz
•
10th Grade
10 questions
Exploring the Layers of the Earth
Interactive video
•
6th - 10th Grade