- 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.
Want to keep
learning?This content is taken from
Raspberry Pi Foundation online course,
Scratch to Python: Moving from Block- to Text-based ProgrammingView Course
#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.
## 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____ ?']
Commented codeHere’s a link to the code with some comments that I have written to explain the different sections.My comments are there to help you — have a read through them to make sure you fully understand what’s happening in the code. This will also fill any gaps in your comments. You can then use a version that has lots of comments with your learners after they have added their own comments.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 codeNow 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.
- Add some more questions and answers to the quiz.
- Add a picture round, so that an image is displayed with a question.
- Alter the code so that upper and lower case answers are accepted.
- Hide the ‘Next’ button until the user has submitted an answer.
Scratch to Python: Moving from Block- to Text-based Programming
Our purpose is to transform access to education.
We offer a diverse selection of courses from leading universities and cultural institutions from around the world. These are delivered one step at a time, and are accessible on mobile, tablet and desktop, so you can fit learning around your life.
We believe learning should be an enjoyable, social experience, so our courses offer the opportunity to discuss what you’re learning with others as you go, helping you make fresh discoveries and form new ideas.
You can unlock new opportunities with unlimited access to hundreds of online short courses for a year by subscribing to our Unlimited package. Build your knowledge with top universities and organisations.