Skip to content
Related Articles

Related Articles

Improve Article

Ask(), Wait() and Answer() Block in Scratch Programming

  • Last Updated : 07 Aug, 2021
Geek Week

Scratch is a high level visual programming language tool that interacts with users through diagrams and blocks that have the basics of a program inbuilt in it. Scratch is used to make interactive programs especially for kids using the block kind of interfaces so that they can easily learn languages and it is free to use. In scratch, ask() and wait, the wait blocks are the block that senses the input and shows the output as per the input typed (i.e., the answer block).

ask() and wait block

The ask() and wait block is sensing and a stack block. It is a single block that first asks the question to the user and then waits for the input from the user. Or in other words, in ask() and wait block, the ask() block makes any sprite (actor of the scene) to display questions. The programmer can change the question to whatever they wish to ask the user. Simultaneously, an input field appears on the bottom of the screen where the user can type the input or answer the question and the answer/input is stored in the answer block. The answer block is always updated to the recent input. The wait block is to wait for the input of the user. If the question is asked by the sprite then the question will display in the bubble and if the question is asked by the stage or hidden sprite, then the question will display above the input block. You can find ask() and wait block in the sensing block.

Let us understand the working of the wait block with the help of a simple project. In this project we make a sprite asking the name of the user. 

Procedure:



Step 1: Go to the costumes section and choose any sprite of your choice.

Step 2: Click on event block and choose 1st control block denoting the start of the program(drag it to center).

Step 3: Go to sensing block, and drag the ask() and wait block below the above step.

Step 4: Now, run the program.

Below is the implementation of the procedure:

answer block

It is a sensing and reporting block. The main purpose of the answer block is to store the answer(that was typed by the user in the input field) and, if needed, it can also display it on the screen. The answer block consists of the most recent input typed by the user and erases any previous inputs typed by the user. You can find the answer block in the sensing block.



Let us understand the working of the wait block with the help of a simple project. In this project we make a sprite ask the user how much degree the sprite must turn and then turn the sprite to that much degree.

Procedure

Step 1: Click on event block and choose 1st control block denoting start of the program(drag it to center).

Step 2: Go to sensing block, and drag the ask and wait block below the above step, change the question from “whats your name” to “how much degree the cat must move?”

Step 3: Go to motion block and select “turn O degree”

Step 4: Go to sensing block, drag the answer block and place it inside O of turn degree block

Step 5: Now run the program

Below is the implementation of the procedure:



wait block

It is a control and stack block. As the name suggests, this block is used to wait for n number of seconds, where n is any integer. It is the most commonly used block and is generally used when a sprite must wait for another action or is used in the time-critical programs. You can find a wait block in the control block.

Let us understand the working of the wait block with the help of a simple project. In this project we make a sprite say “hello” after 2 seconds of the start of the program

Procedure

Step 1: Click on event block and choose 1st control block denoting the start of the program(drag it to center)

Step 2: Go to control block and drag wait for 2 second below the above step

Step 3: Go to looks block and drag the “say hello” block below the wait block

Step 4: Now run the program

Below is the implementation of the procedure:

Attention reader! All those who say programming isn’t for kids, just haven’t met the right mentors yet. Join the  Demo Class for First Step to Coding Coursespecifically designed for students of class 8 to 12. 

The students will get to learn more about the world of programming in these free classes which will definitely help them in making a wise career choice in the future.

My Personal Notes arrow_drop_up
Recommended Articles
Page :