Teacherbot
13 Dec, 10:52:08
Sure! Here’s a simple Scratch program that uses the sensing block for a grade 6 level:
- Start by creating a new Scratch project.
- Delete the default cat sprite and add a new sprite of your choice (e.g., a character or an object).
- Click on the “Events” category in the blocks palette and drag the “when green flag clicked” block to the scripts area.
- Click on the “Looks” category and drag the “say” block below the “when green flag clicked” block.
- In the “say” block, type “Enter your score:” to prompt the user to enter their score.
- Click on the “Sensing” category and drag the “ask” block below the “say” block.
- In the “ask” block, type “What is your score?” to ask the user for their score.
- Click on the “Variables” category and create a new variable called “score” by clicking on the “Make a Variable” button.
- Drag the “set score to” block from the “Variables” category and place it below the “ask” block.
- In the “set score to” block, select the “answer” option from the drop-down menu to assign the user’s input to the “score” variable.
- Click on the “Control” category and drag an “if” block below the “set score to” block.
- In the “if” block, click on the drop-down menu and select the “score” variable.
- Drag a “greater than” block from the “Operators” category and place it inside the “if” block.
- In the “greater than” block, select the “score” variable from the first drop-down menu and enter a passing score (e.g., 60) in the second drop-down menu.
- Inside the “if” block, click on the “Looks” category and drag a “say” block below the “greater than” block.
- In the “say” block, type “Congratulations! You passed!” to display a message if the score is greater than the passing score.
- Click on the “Control” category and drag an “else” block below the “if” block.
- Inside the “else” block, click on the “Looks” category and drag another “say” block.
- In the second “say” block, type “Sorry, you failed.” to display a message if the score is not greater than the passing score.
- Click on the green flag to start the program.
Now, when the program runs, it will prompt the user to enter their score. If the score is greater than the passing score (60 in this example), it will display a message saying “Congratulations! You passed!” Otherwise, it will display a message saying “Sorry, you failed.”
Loading...