NEW
Font size
WorksheetsWG:CO:U3L17: Wrap Up Mouse Input Programming
Total questions: 45
Worksheet time: 23mins
What does the `onEvent()` function do in programming?
It runs code when a specific event happens (e.g., button click, key press, screen change).
It creates a new button on the screen.
It deletes an event from the program.
It pauses the program until an event occurs.
Which of the following is an example of using the `onEvent()` function?
`onEvent("submitButton", "click", function() { checkAnswer(); });`
`createButton("submitButton");`
`deleteEvent("submitButton");`
`pauseEvent("submitButton");`
When should you use the `onEvent()` function in your app?
When your app needs to respond to a button press, screen tap, or slider move.
When your app needs to create a new button.
When your app needs to delete an event.
When your app needs to pause all events.
What is the purpose of the "click" parameter in the `onEvent()` function?
It specifies the type of event to listen for, such as a button click.
It creates a new button in the app.
It deletes the event listener from the app.
It pauses the app until the button is clicked.
What does the `getText()` function do?
It displays text on the screen.
It reads text typed by the user into a text input box.
It changes the color of the text.
It deletes text from a text input box.
Which of the following is an example use of the `getText()` function?
var name = getText("nameInput"); setText("greetingLabel", "Hello " + name + "!");
var name = setText("nameInput"); getText("greetingLabel", "Hello " + name + "!");
var name = "Hello " + name + "!"; setText("greetingLabel", name);
var name = "nameInput"; setText("greetingLabel", name);
When should you use the `getText()` function?
When you need to display a message on the screen.
When you need to read typed input like names, answers, or messages.
When you need to change the color of a label.
When you need to delete a text input box.
What is the purpose of the following code snippet? `var name = getText("nameInput"); setText("greetingLabel", "Hello " + name + "!");`
To display a greeting message using the user's typed name.
To delete the user's name from the input box.
To change the color of the greeting label.
To clear the text input box after the user types their name.
What does the `getNumber()` function do?
It reads a number typed by the user and converts it into a numeric value.
It displays a number on the screen.
It generates a random number.
It converts text into uppercase letters.
Which of the following is an example use of the `getNumber()` function?
var age = getNumber("ageInput");
var name = getText("nameInput");
var score = randomNumber(1, 100);
var result = setText("resultLabel", "Hello!");
What is the purpose of using `getNumber()` in the example provided?
To allow the user to enter a number and use it in a calculation.
To display a message to the user.
To generate a random number for the user.
To convert a string into uppercase letters.
In the example, what will the `setText()` function display if the user enters 12 as their age?
Next year you will be 13
Next year you will be 12
Next year you will be 14
Next year you will be 11
When should you use the `getNumber()` function?
Anytime you need math with values the user enters.
Anytime you need to display text to the user.
Anytime you need to generate a random number.
Anytime you need to convert text into lowercase.
What happens when the user clicks a button in a program?
The program reacts to the click.
The program shuts down.
The program restarts.
The program does nothing.
In the example provided, what happens when the user clicks the "Start" button?
The program moves to the next screen.
The program closes the application.
The program displays an error message.
The program restarts the current screen.
What is the purpose of the `onEvent` function in the given code snippet?
To define what happens when a specific event occurs.
To create a new button in the program.
To stop the program from running.
To delete the current screen.
In the code snippet, what does `setScreen("gameScreen")` do?
It changes the current screen to "gameScreen."
It creates a new screen called "gameScreen."
It deletes the "gameScreen."
It pauses the program on the "gameScreen."
What does the program do when text is typed into a text input box?
It ignores the text.
It reacts to the text.
It deletes the text.
It changes the text to uppercase.
What is the correct syntax to get the text from a text input box named "nameInput"?
var name = getText("nameInput");
var name = setText("nameInput");
var name = inputText("nameInput");
var name = getInput("nameInput");
What is an example of how the program reacts to text input in the given context?
The app displays an error message.
The app greets the user after they type their name.
The app closes automatically.
The app changes the background color.
What does the program use to read numbers typed by the user for calculations?
getNumber()
getText()
getInput()
getString()
In the example provided, what is the purpose of the variable "age"?
To store a number input by the user
To store a text input by the user
To calculate the total score
To display the user's name
Which of the following is an example of what the app can calculate?
Age, score, or totals
Names, addresses, or phone numbers
Colors, shapes, or sizes
Dates, times, or locations
What is the primary purpose of a slider in an interactive application?
To display text
To choose a value by dragging
To play a sound
To open a new window
Which of the following is an example of using a slider in an application?
Changing the background color
Adjusting the volume
Displaying an image
Playing a video
What is the purpose of the `onEvent` function in the given code snippet?
To create a new slider
To handle an event when the slider is dragged
To delete the slider
To change the color of the slider
In the code snippet, what does the `setText` function do?
It changes the slider's position
It updates the text of the label with the slider's value
It deletes the slider
It creates a new slider
Which of the following is NOT an example of using a slider?
Adjusting brightness
Changing the size of an object
Selecting a date
Adjusting volume
What happens when a user selects an option from a dropdown menu in a program?
The computer ignores the selection.
The computer reacts based on the user's choice.
The dropdown menu disappears permanently.
The program crashes.
In the code snippet provided, what does the `onEvent` function do?
It changes the text of the dropdown menu.
It listens for a change in the dropdown menu and executes a function.
It creates a new dropdown menu.
It deletes the dropdown menu.
What property is being set in the code snippet when the dropdown menu changes?
The text of the dropdown menu.
The background color of the square.
The size of the dropdown menu.
The position of the square.
What is the purpose of the `getText("colorDropdown")` function in the code?
To retrieve the selected value from the dropdown menu.
To change the color of the dropdown menu.
To delete the dropdown menu.
To create a new dropdown menu.
What is an example of how a dropdown menu can be used in a program?
To let the user pick a color, level, or category.
To display a list of images.
To create a new program.
To delete a file.
What does the `onEvent` function in the provided code detect?
Mouse clicks
Key presses
Screen taps
Page scrolls
Which event type is used in the code to detect when a key is pressed on the keyboard?
"click"
"keydown"
"keypress"
"keyup"
What is an example of a program that uses key press detection?
A game that moves a character with arrow keys
A program that displays images
A calculator application
A weather forecasting app
In the code snippet, what does `console.log(event.key)` do?
Logs the key pressed by the user to the console
Displays an alert on the screen
Changes the background color of the screen
Stops the program from running
What does the computer do when the user moves the mouse over something?
It shuts down.
It reacts to the movement.
It changes the screen resolution.
It opens a new program.
Which event is used in the code to detect when the mouse is moved over an element?
click
mouseover
keydown
mousemove
What is the purpose of the `setText` function in the given code?
To change the color of the text.
To display a message or update text content.
To move the mouse pointer.
To close the program.
What is an example of a reaction when the mouse is moved over an element?
Highlighting buttons or showing tooltips.
Opening a new tab in the browser.
Changing the background color of the webpage.
Playing a sound.
What is the purpose of the "onEvent" function in the given code snippet?
To create a new box on the screen.
To detect touch events on a touchscreen and execute a function.
To log all events happening on the screen.
To change the color of the box when clicked.
What does the "touchstart" event in the code signify?
It triggers when a user starts touching the screen.
It triggers when a user stops touching the screen.
It triggers when a user drags an object on the screen.
It triggers when a user double-taps the screen.
Which of the following is an example of an application that uses touch events?
A calculator app.
A weather forecasting app.
An app where the user drags objects on the screen.
A text editor app.
What will the console display when the "box" element is touched in the given code?
Box clicked!
Touched the box!
Event detected!
Touch event started!
