Python is one the most popular language for learning coding today, and I have been using it successfully in my computer science elective classes for grades 7 and 8.
Python is a text based language without the fussy semicolons and curly braces and variable declarations that can be so difficult to use for younger middle school students. Since Python is also widely used in industry, students are happy to be learning a 'real programming language' as they call it, and there are TONS of resources available online.
We also use the micro:bit if there is time in the class and they are able to use MicroPython to code and use their Python skills in a different setting.
What do I actually use in my Python classroom and Why?
I use Python 3, and I use it with IDLE in the computer labs at my schools. IDLE is an offline editor and development environment that comes for free with the Python download. Using this setup means that my students have to create files using the naming conventions I give them, make folders, back up files and submit their solutions to me on the school server (I use a simple script to grade them as a batch). In addition to teaching them some of these basic file management skills, they are also not distracted by other things online. They tend to stay more on task using the offline IDLE environment. I may switch to a more full featured editor like PyCharm in future classes.
I teach Python by introducing basic coding concepts using small snippets of code (usually run in the shell) and then doing a 'Code-along' to build a small project that will use the new concept. Students code along with me, and participate by contributing/ suggesting / guessing what to add to the project. At the end, each student has a working project.
Python Coding Challenge Sets
Each new concept Code-Along session is followed by students working on a set of coding challenges. These are a set of 5-10 projects that are leveled tasks that provide them with plenty of choice, and opportunities to be creative and extend projects as needed. I customize the project set based on the class level/interest to make sure there is enough interesting and challenging tasks for all students.
Here are some sample coding challenges that could be part of a first Challenge Set - these involve ideas of input, output, variables, data types
- Rectangle calculator - ask user for width, and height, Print total area, and perimeter. Do not worry about units
- Mad Lib : ask user for different items and print a mad lib
- When will you be 21? - ask user for name, and age and tell them the year they will be 21. Assume user enters a number below 21.
- Weight on the moon : Ask user for weight in pounds and give weight on the moon.
- Candy calculator : Ask user for number of boxes of M&M and number of bars of Hersheys chocolate, and then print total cost of candy. You can use any known amount for the price of each box of candy.
- Calculate tip on the restaurant bill. Ask the user for the amount of the bill and then print out the tip amount for 15% and 20% .
- Ask user for 2 numbers and then print out as many operations as possible between first and second number.
Here are some challenges that involve using lists, and loops
- Magic 8 Ball: Write a program that gives a random response to any question. You will need a list of responses, input, print, and modules random and time/sleep so it looks like program is thinking
- Write a program that gives a different story each time it is run. Use lists for phrases, names, places, adjectives and more to create a story that is generated using random values from the list.
- Write a program that gives different versions of the following Limerick each time it is run. Some more about limericks at http://www.poetry4kids.com/lessons/how-to-write-a-limerick/
- Write a program that asks user to enter a food item until they press the word ‘exit’. It then prints the list sorted, formatted and without duplicates.
- Use the following list in your code.Breakfast = [ 'toast', 'eggs', 'oatmeal', 'cereal' ]
- Print the food choices as a nicely formatted menu, with one food item per line with a random price between $1 and $10
(Hint: Use a for loop to print menu. Use the random module to get the prices
Make it look nice if you want an extra challenge.
Yes- you can change the list to different foods ! )
(Optional challenge) Ask the user for a food to replace in the above Breakfast list, and what to replace it by, and then change it and print the new list
6. Given a list of student names ( use from our class or make up the names) as a list , exampleStudents = [ ‘john’, ‘susan’ ]
Use for loop and
1)Print list of names one per line.
2) Find the number of students name begins with ‘a’ and print the total
3) find the % of students name begins with ‘a'
4) find average length of name
7. Write a program that takes a list of high scores separated by , as input, and then prints the lowest score, and the highest score. Extra : print the average of the numbers.
HINT: Use the following to take information and split it based on the ,
userInput = input(‘Enter high scores’)
scoresList = userinput.split(‘,’)