wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Coding Adventure Part III Quiz-Return Keyword

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What is a function in programming?

a)

A type of comment in the code

b)

A set of instructions designed to perform a specific task

c)

A variable that stores data

d)

A loop that repeats a block of code

2.

What is the purpose of the return keyword in programming?

a)

To print a message on the screen

b)

To define a new function

c)

To stop the execution of the program

d)

To specify the value that a function should return to the caller

3.

What is the act of using a function in code called?

a)

Looping the function

b)

Executing the function

c)

Defining the function

d)

Calling the function

4.

What does a function implicitly return if no value is specified?

a)

Random number

b)

Error message

c)

Default value (often None)

d)

Boolean value

5.

What is the syntax for defining a function in programming?

a)

variable_name=()

b)

function_name()

c)

function_name=() ->

d)

function_name{}

6.

When does the computer execute a function in a program?

a)

When it reaches the end of the program

b)

When it is called

c)

When it is defined

d)

When it encounters an error

7.

What is the purpose of calling a function in code?

a)

To execute the specific task defined in the function

b)

To skip a block of code

c)

To print the function definition

d)

To create a new function

8.

What is the function call in the code 'gotoNearestHealth()'?

a)

gotoNearestHealth

b)

gotoHealth

c)

nearestHealth

d)

gotoNearest

9.

What does the return statement allow a function to do?

a)

Send the result back to the part of the program that called it

b)

Stop the function from executing

c)

Create a new function

d)

Print the result on the screen

10.

What is the value returned by the function autoStep=() -> return 20?

a)

20

b)

10

c)

0

d)

30

11.

What is the body of a function in programming?

a)

Loop structure

b)

Variable declaration

c)

Set of instructions that perform a specific task

d)

Print statement

12.

What is the function signature in programming?

a)

autoStep=() ->

b)

autoStep()

c)

step a

d)

return 20

13.

What happens when a function is called in a program?

a)

It deletes the function definition

b)

It stops the program execution

c)

It may perform operations and produce a result

d)

It creates a new function

14.

What is the purpose of defining a function in programming?

a)

To stop the program execution

b)

To create a new variable

c)

To print a message on the screen

d)

To specify what task the function will perform

15.

What is the value assigned to variable 'a' in the code 'a=autoStep()'?

a)

10

b)

0

c)

20

d)

30