A fun experiment to conduct with students is to compare how fast a Python can determine if a number is prime versus how fast Scratch can do it.
Below is (clunky) Python code:
I checked to see how fast the Python program could determine that 7,465,001 is not prime. It did it in about 7 seconds. It took Scratch about 90 seconds to find a factor. Ask the students why they think Python solves the problem 13 times faster than Scratch. Their answers will interest you and give you insight as to how they understand computers and programming.
Another learning opportunity for students is to see how creating a program with Scratch makes it much easier to program with Python. If they created the "Is it Prime" program on Scratch, they will have solid pseudocode to write the program in Python.
Using coding concepts to teach middle school math and programming. I focus primarily on coding with Scratch and Python.
Saturday, February 18, 2017
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.
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.
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.
Subscribe to:
Posts (Atom)