Independent learning

In any learning environment, it is inevitable that some individuals will progress faster than others. This can make differentiating tasks for your learners a real challenge.

Up until now, you have been learning about the Python language by following fairly didactic instructions, either in written or video form. Afterwards, you’ve hopefully been experimenting with your code to see what else you can do. However, educators often don’t have the time or resources to go through such a process with their learners, so they want more independent learning opportunities.

The following independent activity is structured in such a way that both beginners and confident Python programmers can develop their skills further.

In this activity, you are going to look at a GUI I have created, and read and attempt to explain the Python code that I have used. You will then attempt to extend my program. As usual, you can reuse this activity with your own learners.

Below is a demonstration of my GUI:

The code

1. Here is a link to download the full code for the demonstrated application. Do not read the code, just load and run it to have a play with the program.
2. Read through the code and add comments to explain as many lines of code as you can. Comments always start with one or more # symbols. I prefer to use two (##), but it’s up to you. In the classroom you can ask your learners to do this at the same time to give them more confidence and understanding of the code.

For example, you might comment the first few lines like this:

## Import some guizero code
from guizero import App, TextBox, PushButton, Picture, Text
## Import code for making random numbers
from random import randrange

## Create a list of questions
questions = ['Which Python function is equivalent to the Scratch "say" block ?',
'Which Python module contains the randint function ?',
'Fill in the blank - pseudo____ ?']


If you don’t know what a line of code does, don’t worry: you can leave the line uncommented and come back to it later.

Commented code

Here’s a link to the code with some comments that I have written to explain the different sections.

If you’re unsure about anything, now would be a good time to add your questions to the comment section below. If you need a little help, or want some clarification on a few lines, don’t be afraid to ask.

Extending the code

Now it’s your turn to alter the code and make it your own.

Don’t feel you need to attempt all of the tasks. Do as many or as few as you want. Every little bit of progress you make is a success, so if you’re using Python for the first time in this course and you’ve made it this far, you’ve already achieved a huge amount.

If you use this activity with your learners, you can give one extension task each and then share each other’s code, or differentiate by giving more tasks to the higher-ability learners. You can continue the activity by asking the higher-ability learners who have completed their task to support other learners, and then they can use the other learners ideas and code to complete more tasks on their own program.

Don’t forget that there is guidance for using guizero, and that it’s always a good idea to search for answers to a programming question on the internet if you’ve spent a fair amount of time struggling to find a solution.

Below are a few suggestions for things you could try. They’re not in any order, so just pick one that looks interesting to you and have a go.

Possible extensions

1. Add a picture round, so that an image is displayed with a question.

1. Alter the code so that upper and lower case answers are accepted.

1. Hide the ‘Next’ button until the user has submitted an answer.

If you have other ideas, feel free to have a go at programming them. Please share your ideas and finished programs in the comments section.

Note: Code in comments should be enclosed in tilde characters (~~~) — three tildes before and after the code. Refer to our ‘Sharing code on FutureLearn’ guide for more information.