0% found this document useful (0 votes)
13 views14 pages

Lesson 6 - Consolidation Workbook

This lesson focuses on enhancing a Python program, specifically a Maths Quiz, by consolidating and sequencing IF statements to achieve differentiated outcomes. Students will learn to use the random module to generate questions and assign ranks based on scores. The lesson includes tasks for improving the quiz's functionality and personalizing the game experience.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views14 pages

Lesson 6 - Consolidation Workbook

This lesson focuses on enhancing a Python program, specifically a Maths Quiz, by consolidating and sequencing IF statements to achieve differentiated outcomes. Students will learn to use the random module to generate questions and assign ranks based on scores. The lesson includes tasks for improving the quiz's functionality and personalizing the game experience.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 14

Lesson 6

Putting it all together!


**Challenge time**

Python Programming
Learning & Skills Objectives
 To understand how to use consolidate IF statements and learn the practical
use of sequencing IF statements to achieve a differentiated outcome.

 To understand how to use more complex modules in your program.

 I can add multiple IF statements to achieve a differentiated outcome.

 I can assign data to variables anywhere in a program and output those


variables when I want.

Keywords
Consolidate, sequencing, differentiated, assign
Lesson Success Criteria

Remembering Level 4
 I have improved my maths quiz based on feedback that I
received at the end of last lesson.
Understanding
 I can add multiple IF statements to my program which
allows my program to achieve different outcomes.
Applying  I can confidently assign data to variables anywhere in
a program and output those when and where desired.
Analyzing
Level 5
 I have completed ALL of the tasks in today’s lesson
Evaluating INDEPENDENTLY.
 I have used the random module to create random math
questions for my player.
Creating  I have added more complex elements to my game such
as elements to stop my game from crashing.
Last lesson ...

You updated a program called – ‘MathsQuiz.py’

Your Maths Quiz should now ...

t 5
a s Should store the
t l e m e
a n s e a g a player’s name
e
v st i o H a v n
a
H ue u ct i o
q introd
Tell the playe
Should inc r if they
rease the s got the quest
by 1 if righ c o r e ion
t and decre r ight or wrong
by 1 if wro a s e
ng.
The
ScoreFinal
is 5 out of 5Score Feedback
Mini Task
Rank: Total Genius one
Score is 4 out of 5

Rank: Maths Wizard


Score is 3 out of 5
 Today you are going to alter
Rank: Intermediate your code so that at the end
of your game, the message
Score is 2 out of 5 that your player gets depends
on their final score.
Rank: Beginner
 Edit your program now so

Score is 1 out of 5
that it gives the user a ‘rank’
according to their score (it will
Rank: Noob fall into one of these ranks).
Example ...
If the final score (after 5 questions) is 1 out of 5, the final score message will read:

[name], you scored 1 out of 5. Your rank is NOOB


or ...
If the final score (after 5 questions) is 2 out of 5, the final score message will read:

[name], you scored 2 out of 5. Your rank is BEGINNNER


or ...
If the final score (after 5 questions) is 5 out of 5, the final score message will read:

[name], you scored 5 out of 5. Your rank is TOTAL


GENIUS
Mini task one

Screenshot your code


Challenge Task

This is a really nice quiz that we’ve created so


far ... however, maybe we could improve it even
further?

Wouldn’t it be better if the questions were


randomly generated instead of being pre-planned?
That way the questions would be different each time!

We can do this using something we’ve already


covered earlier in the topic.
random.randint(1,10)

Python has a module that allows it to generate a random


number called random.

If we wanted a random number, we can use the


random.randint function.

First we need to import random so we can use the


random.randint function.

Then we can assign a random number to a variable like


this:
number1 = random.randint(1,10)
What does it mean?

import random
number1 = random.randint(1,10)
 This line imports the random module so that we can access randint
which will generate our random number.

 This is our variable name.

 This is the function randint which we use to generate a number.

 This means that we want a random number between 1 and 10. You
can change this to whatever you want, e.g.
random.randint(10,20) would give you a random number
between 10 and 20.
Mini Task Two
random.randint(1,10)
Open MathsQuiz.py in SCRIPT mode.

Copy the following code


as a sixth question in
your Maths Quiz.

Test that it works


correctly!

Extension – Can you comment the above code to explain what it is doing?
Mini Task Two

Screenshot your code


Today’s Task
If you can, do all these programs in SCRIPT mode
(i.e. go to FILE, NEW WINDOW…then press F5 to run)
Task: Amend your Maths Quiz program so that it now does the following:

a) All questions are randomly generated and there is a mixture of +, - and *.


• Probably best not to use / (divide as the questions are hard!).

b) How else could you personalise the game?


• Why not add an extra bonus round if somebody gets a perfect score
(all questions right).
• Why not add in a cheat that enables a player to score massively high
for entering a certain name (e.g. cheatmode).
• Why not allow the player to choose what range of numbers will be
randomly generated? At the moment you set it as
random.randint(1,10). Hint random.randint(x,y) ... think
about using variables instead?!

c) What else could you do?


• Be sure to comment on important code!
Today’s Task

Screenshot your code

You might also like