wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

WG:CO:U3L17: Wrap Up Mouse Input Programming

Total questions: 45

Worksheet time: 23mins

Name
Class
Date
1.

What does the `onEvent()` function do in programming?

a)

It runs code when a specific event happens (e.g., button click, key press, screen change).

b)

It creates a new button on the screen.

c)

It deletes an event from the program.

d)

It pauses the program until an event occurs.

2.

Which of the following is an example of using the `onEvent()` function?

a)

`onEvent("submitButton", "click", function() { checkAnswer(); });`

b)

`createButton("submitButton");`

c)

`deleteEvent("submitButton");`

d)

`pauseEvent("submitButton");`

3.

When should you use the `onEvent()` function in your app?

a)

When your app needs to respond to a button press, screen tap, or slider move.

b)

When your app needs to create a new button.

c)

When your app needs to delete an event.

d)

When your app needs to pause all events.

4.

What is the purpose of the "click" parameter in the `onEvent()` function?

a)

It specifies the type of event to listen for, such as a button click.

b)

It creates a new button in the app.

c)

It deletes the event listener from the app.

d)

It pauses the app until the button is clicked.

5.

What does the `getText()` function do?

a)

It displays text on the screen.

b)

It reads text typed by the user into a text input box.

c)

It changes the color of the text.

d)

It deletes text from a text input box.

6.

Which of the following is an example use of the `getText()` function?

a)

var name = getText("nameInput"); setText("greetingLabel", "Hello " + name + "!");

b)

var name = setText("nameInput"); getText("greetingLabel", "Hello " + name + "!");

c)

var name = "Hello " + name + "!"; setText("greetingLabel", name);

d)

var name = "nameInput"; setText("greetingLabel", name);

7.

When should you use the `getText()` function?

a)

When you need to display a message on the screen.

b)

When you need to read typed input like names, answers, or messages.

c)

When you need to change the color of a label.

d)

When you need to delete a text input box.

8.

What is the purpose of the following code snippet? `var name = getText("nameInput"); setText("greetingLabel", "Hello " + name + "!");`

a)

To display a greeting message using the user's typed name.

b)

To delete the user's name from the input box.

c)

To change the color of the greeting label.

d)

To clear the text input box after the user types their name.

9.

What does the `getNumber()` function do?

a)

It reads a number typed by the user and converts it into a numeric value.

b)

It displays a number on the screen.

c)

It generates a random number.

d)

It converts text into uppercase letters.

10.

Which of the following is an example use of the `getNumber()` function?

a)

var age = getNumber("ageInput");

b)

var name = getText("nameInput");

c)

var score = randomNumber(1, 100);

d)

var result = setText("resultLabel", "Hello!");

11.

What is the purpose of using `getNumber()` in the example provided?

a)

To allow the user to enter a number and use it in a calculation.

b)

To display a message to the user.

c)

To generate a random number for the user.

d)

To convert a string into uppercase letters.

12.

In the example, what will the `setText()` function display if the user enters 12 as their age?

a)

Next year you will be 13

b)

Next year you will be 12

c)

Next year you will be 14

d)

Next year you will be 11

13.

When should you use the `getNumber()` function?

a)

Anytime you need math with values the user enters.

b)

Anytime you need to display text to the user.

c)

Anytime you need to generate a random number.

d)

Anytime you need to convert text into lowercase.

14.

What happens when the user clicks a button in a program?

a)

The program reacts to the click.

b)

The program shuts down.

c)

The program restarts.

d)

The program does nothing.

15.

In the example provided, what happens when the user clicks the "Start" button?

a)

The program moves to the next screen.

b)

The program closes the application.

c)

The program displays an error message.

d)

The program restarts the current screen.

16.

What is the purpose of the `onEvent` function in the given code snippet?

a)

To define what happens when a specific event occurs.

b)

To create a new button in the program.

c)

To stop the program from running.

d)

To delete the current screen.

17.

In the code snippet, what does `setScreen("gameScreen")` do?

a)

It changes the current screen to "gameScreen."

b)

It creates a new screen called "gameScreen."

c)

It deletes the "gameScreen."

d)

It pauses the program on the "gameScreen."

18.

What does the program do when text is typed into a text input box?

a)

It ignores the text.

b)

It reacts to the text.

c)

It deletes the text.

d)

It changes the text to uppercase.

19.

What is the correct syntax to get the text from a text input box named "nameInput"?

a)

var name = getText("nameInput");

b)

var name = setText("nameInput");

c)

var name = inputText("nameInput");

d)

var name = getInput("nameInput");

20.

What is an example of how the program reacts to text input in the given context?

a)

The app displays an error message.

b)

The app greets the user after they type their name.

c)

The app closes automatically.

d)

The app changes the background color.

21.

What does the program use to read numbers typed by the user for calculations?

a)

getNumber()

b)

getText()

c)

getInput()

d)

getString()

22.

In the example provided, what is the purpose of the variable "age"?

a)

To store a number input by the user

b)

To store a text input by the user

c)

To calculate the total score

d)

To display the user's name

23.

Which of the following is an example of what the app can calculate?

a)

Age, score, or totals

b)

Names, addresses, or phone numbers

c)

Colors, shapes, or sizes

d)

Dates, times, or locations

24.

What is the primary purpose of a slider in an interactive application?

a)

To display text

b)

To choose a value by dragging

c)

To play a sound

d)

To open a new window

25.

Which of the following is an example of using a slider in an application?

a)

Changing the background color

b)

Adjusting the volume

c)

Displaying an image

d)

Playing a video

26.

What is the purpose of the `onEvent` function in the given code snippet?

a)

To create a new slider

b)

To handle an event when the slider is dragged

c)

To delete the slider

d)

To change the color of the slider

27.

In the code snippet, what does the `setText` function do?

a)

It changes the slider's position

b)

It updates the text of the label with the slider's value

c)

It deletes the slider

d)

It creates a new slider

28.

Which of the following is NOT an example of using a slider?

a)

Adjusting brightness

b)

Changing the size of an object

c)

Selecting a date

d)

Adjusting volume

29.

What happens when a user selects an option from a dropdown menu in a program?

a)

The computer ignores the selection.

b)

The computer reacts based on the user's choice.

c)

The dropdown menu disappears permanently.

d)

The program crashes.

30.

In the code snippet provided, what does the `onEvent` function do?

a)

It changes the text of the dropdown menu.

b)

It listens for a change in the dropdown menu and executes a function.

c)

It creates a new dropdown menu.

d)

It deletes the dropdown menu.

31.

What property is being set in the code snippet when the dropdown menu changes?

a)

The text of the dropdown menu.

b)

The background color of the square.

c)

The size of the dropdown menu.

d)

The position of the square.

32.

What is the purpose of the `getText("colorDropdown")` function in the code?

a)

To retrieve the selected value from the dropdown menu.

b)

To change the color of the dropdown menu.

c)

To delete the dropdown menu.

d)

To create a new dropdown menu.

33.

What is an example of how a dropdown menu can be used in a program?

a)

To let the user pick a color, level, or category.

b)

To display a list of images.

c)

To create a new program.

d)

To delete a file.

34.

What does the `onEvent` function in the provided code detect?

a)

Mouse clicks

b)

Key presses

c)

Screen taps

d)

Page scrolls

35.

Which event type is used in the code to detect when a key is pressed on the keyboard?

a)

"click"

b)

"keydown"

c)

"keypress"

d)

"keyup"

36.

What is an example of a program that uses key press detection?

a)

A game that moves a character with arrow keys

b)

A program that displays images

c)

A calculator application

d)

A weather forecasting app

37.

In the code snippet, what does `console.log(event.key)` do?

a)

Logs the key pressed by the user to the console

b)

Displays an alert on the screen

c)

Changes the background color of the screen

d)

Stops the program from running

38.

What does the computer do when the user moves the mouse over something?

a)

It shuts down.

b)

It reacts to the movement.

c)

It changes the screen resolution.

d)

It opens a new program.

39.

Which event is used in the code to detect when the mouse is moved over an element?

a)

click

b)

mouseover

c)

keydown

d)

mousemove

40.

What is the purpose of the `setText` function in the given code?

a)

To change the color of the text.

b)

To display a message or update text content.

c)

To move the mouse pointer.

d)

To close the program.

41.

What is an example of a reaction when the mouse is moved over an element?

a)

Highlighting buttons or showing tooltips.

b)

Opening a new tab in the browser.

c)

Changing the background color of the webpage.

d)

Playing a sound.

42.

What is the purpose of the "onEvent" function in the given code snippet?

a)

To create a new box on the screen.

b)

To detect touch events on a touchscreen and execute a function.

c)

To log all events happening on the screen.

d)

To change the color of the box when clicked.

43.

What does the "touchstart" event in the code signify?

a)

It triggers when a user starts touching the screen.

b)

It triggers when a user stops touching the screen.

c)

It triggers when a user drags an object on the screen.

d)

It triggers when a user double-taps the screen.

44.

Which of the following is an example of an application that uses touch events?

a)

A calculator app.

b)

A weather forecasting app.

c)

An app where the user drags objects on the screen.

d)

A text editor app.

45.

What will the console display when the "box" element is touched in the given code?

a)

Box clicked!

b)

Touched the box!

c)

Event detected!

d)

Touch event started!