Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

2. Ask a Question

Transcript

In this video, you will learn how to make the sprite as the user a question.

To start the Two Truths & A Lie game, the sprite needs to say three different things.

Two truths and one lie.

Click on the android sprite.

Then, click on the looks menu.

Drag a say block.

Type the letter A and a statement about yourself that is either a truth or a lie.

In this example, the sprite says one true statement.

Test the block by clicking on it.

Great.

Drag out a second say block and snap it under the first.

You just built a block stack.

Type the letter B, then enter a truth or a lie about yourself in this second block.

Remember, use two truth and one lie in this project.

This example uses a truth in the second block.

Test the whole stack by clicking on it.

When you click on a block stack like this, it's called running the code.

The sprite says both items.

Drag a third say block and snap it at the bottom of the block stack.

Write the letter C and your final item in this block.

In the example, the third block has the lie.

For the lie, try to think of something that even your friend might not know about you.

Click on the block stack to test it.

The code runs in the order of the stack, top to bottom.

The sprite tells the first truth, then the second truth, then the lie.

Great.

Next, ask the user which item they think is the lie.

Select an ask block from the Sensing menu.

Change the text in the ask block to ask something like which do you think is the lie?

Type A, B, or C.

Click the ask block to test it and see how it works.

Computer scientists like you explore and test new code all the time to find out how it works.

The ask block makes the sprite say the question, then shows a text bar where the user can type their response.

The ask block makes the sprite wait until the user responds before running any more code.

Snap the ask block to the bottom of the block stack.

Now it's your turn.

Use three say blocks to make the sprite tell two truths and one lie about you.

Use the ask block to make the sprite ask the user which statement is the lie.

arrow_backward Back
Next arrow_forward
Instructions
  • Use 3 "say" blocks to make the sprite tell 2 truths and 1 lie.
  • Use the "ask" block to make the sprite ask the user which one is the lie.