Python Challenges - Module 1

This module consists of 8 Challenges. The last challenge in this module will have you practicing all the tools that you have learned in the previous challenges. Students can submit their Challenge 8 to be recognized for their hard work and creativity.

Teachers:

Use Challenges with your students to help them build their coding skills using Scratch. This page is 'public' so you can choose to have students to go to this page and go through these Challenges as a class, small groups, pairs, or individually.

To celebrate the successful completion of coding challenges, you may want to send students home with a personalize congratulations postcard! Click here for more details.

Challenge One: Print & Variables

Watch the two videos on the left. Then try to do the following:

  • Start a new Colab notebook

  • Name your notebook 'Challenge Number One'

  • Create a program that has three different variables.

  • Print at least one sentence that includes all three variables.

Challenge Two: Input Function

Watch the video on the right. Then create a input functions to ask the end-user for the following information:

  • Name

  • Age

  • Favourite Colour

  • Favourite TV show or Movie

*Make sure that you created variables to 'store' this data received by the end-user.

Next, 'print' a sentence or two that uses the information gathered above.

Challenge Three: Input & Calculations

Watch the video on the left. Recreate what I have created. Once everything is in and working correctly, now extend the cell to include the following:

  • Calculate how long the end-user brushes their teeth per month

  • Print this calculation within a sentence.

  • Calculate how long the end-user brushes their teeth per year

  • Print this calculation within a sentence.

Challenge Four: Time Elapsed Activity

If you haven't already, watch the video for Challenge Three. Now do the following:

  • Create a new Colab notebook.

  • Decide on a a time elapsed situation, for example, how long you sleep or how much Netflix you watch.

  • Give your notebook an appropriate name based on the activity.

  • Type out the code required to ask the end-user the time they spend on the activity you chose for one day.

  • Calculate and print out the results for the time that they spent on the activity per week, month, year and ten years.

Challenge Five: Conditional Statements

What's For Dinner? Another example of where conditional statements are used.

*Look closely in this program to see how you can add spacing to make it easier to read output statements.

  1. Watch the video on the right. Recreate what I have created. Try to recreate the 'Going to the Movies' program.


  1. Read and execute (press play) this program: What's For Dinner?


  1. Use what you have learned from 1 and 2 to create your own program that includes conditional statements.

If you don't have an idea of a conditional situation that you would like to program, you can try doing this one...

Prompting question: Is the weather nice today? yes or no

    • If answered 'yes', then you can respond with an outdoor activity that you recommend that they do (i.e., go for a walk, take pictures, ...)

    • If answered 'no', then you can respond with an indoor activity that you recommend that they do (i.e., do a puzzle, call a friend, ...)

    • If neither 'yes' or 'no' was typed in as a response, you can print something like this, "This was an invalid response."

*Note: you can have as many elif statements as you need. You will need to be careful about uppercase and lowercase responses. You may want to include more elif statements to cover all options.

Challenge Six: Efficient Coding - Formatted String

Watch this brief video to see how you can program messages to be printed in a much simpler and efficient way. For practice on this strategy, redo Challenge Two with the new way of printing messages.

When you are little more comfortable with formatted strings, create a program that does the following:

  • Ask someone for 3 different toppings on a pizza. Create a statement that is printed that includes these 3 toppings.

Challenge Seven: Efficient Coding - Lower String Method

In Challenge Five you would have found out that when you try to anticipate what people type in with lowercase, uppercase, or a combination of the two, you will need to write a lot of if/elif statements. This can be repetitive and tedious. In this video you will see how using .lower() string method can save you a lot of time and code!

After you watch the above video:

  • make a copy of the What's For Dinner program (File > Save a copy in Drive). Alter the code to remove the uppercase elif statements and add the appropriate .lower() string method.

  • Edit the program you created in step 3 in Challenge 5. Make it more efficient by eliminating unnecessary code to anticipate uppercase responses and add a .lower() string method.

Challenge Eight (SUPER CHALLENGE) Choose Your Own Adventure (UNDER CONSTRUCTION)

Choose Your Own Adventure!

If you are unfamiliar with 'Choose Your Own Adventure' it is a fun book series that gives the reader (you) choices as you read through an adventure. The choices that are made determine the main character's actions and how the adventure continues or ends.

Your Coding Super Challenge

Let's see how much you learned. By using the tools in the previous challenges, try to create a mini Choose Your Own Adventure program.

To help get you started and give you some ideas on how this can work, take a look at this sample.

If you are interested, I would love to see what you created! Feel free to share the Google Colab file to: Tina.Franzen@tldsb.on.ca. Looking forward to seeing your hard work and creativity!