1 of 19

Objective: Students will use conditionals to ask questions and respond one way if the answer is correct, and a different way if the answer is wrong.

Expected Outcome:

Students will be able to:

  • add sprites
  • code conditionals to ask and answer questions
  • code the sprite to move toward a goal if answers are correct
  • code a conditional to check if goal is reached and then end the game

Objectives/Outcome

Quiz Game

Prerequisites:

Students should have foundational understanding of:

  • adding sprites
  • basic movement blocks
  • say blocks

Vocabulary

Conditionals

Algorithm

Event

A sprite asks questions. If you get the answer correct, it moves towards a reward.

2 of 19

Step-by-Step

Go to Clever

Open Code HS

Select the Quiz Game

3 of 19

Project Sample

4 of 19

conditional

conditional

  • commands that only run under certain conditions
  • an action that occurs based on whether a condition is true or false

5 of 19

What are Conditionals?

New Blocks - Conditionals

If the condition is true, the blocks held inside it will run. If the condition is false, the blocks held inside will be ignored. The condition is only checked once.

Use one of the many diamond shaped sensing blocks or operators to fill in the condition of the “if” statement.

This conditional is an if/then/else conditional. When the script runs it will check if the condition is met. If the condition is true, the first section of code will run. If the condition is false, the “else” section will run

A common error with conditionals is not understanding that the condition is only checked once. To make the program repeatedly check a condition, it needs to be in some kind of loop.

Conditional blocks are used to check to see if a condition is true or false. If it is true, then an action will happen. Block are only checked once (unless contained in a forever loop). They can be used to compare values, check for input (i.e. mouse click/color sensing), control objects, etc.

6 of 19

What are some of the code blocks I need?

Quiz Game

Decompose

Add sprite

Code a conditional to check the answer.

Make sprite move toward a goal if the answer is correct.

Make sprite ask a question.

Add more questions.

Note: Not all blocks that might be used are shown here. There are multiple ways to code this project.

Code a conditional to check if goal is reached.

HINT: right click a stack of code and select “Duplicate” to speed up your coding.

7 of 19

Student Paced Option

Recommended: Share this slide deck with students so they can work at their own pace. They can do Split Screen mode and view code samples on the side

(put tutorial slide deck in slideshow mode)

8 of 19

Tutorials

Optional: Printable Cards

9 of 19

Step-by-Step

1. Add a sprite.

2. Add a background.

10 of 19

Step-by-Step

3. Create an algorithm to make the sprite ask a question and wait for the user to input an answer.

11 of 19

Step-by-Step

4. Code a conditional to perform one action IF the answer is correct, ELSE do a different action.

12 of 19

Step-by-Step

5. Add another sprite to represents a goal/reward.

13 of 19

Step-by-Step

6. Add to the original algorithm so the sprite moves toward the goal if the answer is correct.

14 of 19

Step-by-Step

7. Create a separate algorithm with a conditional to check if the goal is reached. Include a celebration if the goal is reached.

8. Add more questions.

15 of 19

Extension

Variables and random operators to generate questions

Extension (Advanced)

16 of 19

Revise

Can you add a scorekeeping variable?

Can you make the sprite give instructions for the game?

Can you add animation to the sprite as it moves toward the goal?

Quiz Game - Extensions

Can you add a more elaborate celebration?

Debug

Does everything work the way you want it to?

Is there anything you want to change?

score

5

Can you make the questions random? (see sample code slide 7)

17 of 19

CODE BLOCKS

When flag clicked

ask

if/else

move

say

if/then

if touching/then

SKILLS

VOCABULARY

Conditionals

Algorithm

Event

Vocabulary

Code Blocks

Skills

  • Create an algorithm
  • Use conditionals to ask/answer questions
  • Make a sprite move
  • Use conditionals with sensing blocks to control events

Standards

STANDARDS

CS 3AP-3b Create programs that include sequences, events, loops, and conditionals

CS 3AP-4a Break down (deconstruct) algorithms and list the steps needed to solve a problem into a sequence of tasks and sub-tasks.

CS 3AP-5e Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended.

Math Standard 3.OA.7 Fluently multiply and divide.

18 of 19

Additional Resources

Quiz Game

19 of 19

Slidesgo

THANKS

Sources:

scratch.mit.edu

thenounproject.com

freepik.com

code.org

CREDITS: This presentation template was created by Slidesgo, including icons by Flaticon, infographics & images by Freepik