Search Header Logo
Russian Multiplication

Russian Multiplication

Assessment

Presentation

•

Computers, Mathematics

•

10th - 11th Grade

•

Medium

Created by

Coder Dojo

Used 6+ times

FREE Resource

26 Slides • 11 Questions

1

Russian Multiplication

Say what.....!


What does this have to do with coding?

Slide image

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)

1

5

2

3

3

0

4

1

5

Multiple Choice

Try it 77 % 6

1

5

2

7

3

2

4

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

1

4

2

5

3

6

4

7

8

Multiple Choice

Try it - 66 // 6

1

6

2

11

3

9

4

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

Slide image

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

1

17

2

52

3

34

4

6

13

Multiple Choice

5 // 2 is

1

2.5

2

3

3

2

4

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....

Slide image

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

Slide image

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

Slide image

18

Multiple Choice

Question image

What does this symbol mean

1

Terminator

2

Decision

3

Sub Process

4

Process

5

Input / output

19

Multiple Choice

Question image

What does this symbol mean

1

Decsion

2

Terminator

3

Sub Process

4

Process

5

Input / output

20

Multiple Choice

Question image

What does this symbol mean

1

Process

2

Terminator

3

Sub Process

4

Decision

5

Input / output

21

Multiple Choice

Question image

What does this symbol mean

1

Process

2

Terminator

3

Input / output

4

Decision

5

Sub Process

22

Multiple Choice

Question image

What does this symbol mean

1

Process

2

Terminator

3

Input / output

4

Decision

5

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...

Slide image

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

Slide image

27

Problem area

Discuss if this is the right error and if where I think it should go fixes the problem

Slide image

28

Problem area

Or is this a better way to correct, why have I put a line through the zero?

Slide image

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?

Slide image

Show answer

Auto Play

Slide 1 / 37

SLIDE