Saturday, January 14, 2017

Binary to Base 10 with Python

Python has a unique syntax for exponents:   Instead of the standard 3^2 representing 3 to the second power, Python uses 3**2.  It makes sense.  I guess.  In a weird sort of way.  Of course, if no one told you, you might spend a while troubleshooting your code thinking the only thing that couldn't POSSIBLY be wrong is 3^2=9.  But....in the python world, 3**2 is 9.

The code for Binary to Base 10 in Python was a little more straightforward than Scratch.


Tuesday, January 3, 2017

Data Analysis (percentages) with Python

This is a great example of how encryption experts and homeland security 'spies' can analyze large quantities of data and flag elements that might be suspicious or important. 

This Python module allows you to compare a given sentence, paragraph, or phrase and compare it to a 350,000 word English dictionary to determine whether the sentence is written in English.  It simply asks the question, "What percentage of the words in the given sentence were in the dictionary file?"  It then makes a decision based on that percentage.

The students may not be up for coding this, but a teacher could easily walk students through a sample sentence to determine what percentage of the words were in the dictionary file.