Thursday, November 17, 2016

Divisibility Rules with Scratch

Elementary and middle school students benefit from knowing basic divisibility rules.  The four basic divisibility rules are:

A number can be divided by 2 if it ends in 2,4,6,8, or 0

A number can be divided by 2 if the sum of its digits can be divided by 3.  (Also helps students understand the difference between digits and numbers.)

A number can be divided by 5 if the number ends in 5 or 0.

A number can be divided by 10 if it ends in 0.

There are others, but these are essential.

If students are able to program a computer to follow the rules, then you can be pretty sure that they understand the rules.  Also, this program uses a mod operation, which is a cool thing for a middle school kid to learn.

Source code is here .  There are better ways to do this, I'm sure.

Friday, November 4, 2016

Transposition Cipher, Python

Kids who are motivated to learn a programming language will love Al Sweigart's books.  He's written four Python programming books, including a beginner game programming book and an intermediate game programming book.  They are freely downloadable, or you can buy printed copies.

I'm going through his Hacking Secret Ciphers with Python, which is a fun introduction to using Python to encrypt and decrypt messages.

This transposition code was pretty cool.  I want to teach this!  I also want to turn it into a Scratch program!