wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Functions and Python Quiz

Total questions: 1

Worksheet time: 10mins

Name
Class
Date
1-15.
1.

What are functions in Python?

a)

A. A way to organize code and split it into tasks

b)

B. A way to confuse programmers

c)

C. A way to generate random numbers

d)

D. A way to delete variables

2.

How do you define a function in Python?

a)

D. Using the 'function' statement

b)

A. Using the 'function' keyword

c)

B. Using the 'define' keyword

d)

C. Using the 'def' keyword

3.

What is the purpose of parameters in a function?

a)

C. To assign values when calling the function

b)

A. To confuse the programmer

c)

B. To store global variables

d)

D. To delete the function

4.

What does the 'return' statement do in a function?

a)

D. Generates random numbers

b)

C. Prints a message

c)

B. Deletes the function

d)

A. Ends the function and returns a value

5.

How do you call a function in Python?

a)

C. By using the function name

b)

B. By using the 'run' keyword

c)

D. By using the 'execute' keyword

d)

A. By using the 'call' keyword

6.

What is the outcome of the 'eat cookies' function mentioned in the text?

a)

B. Becoming less hungry

b)

A. Getting energized

c)

C. Appreciating the taste

d)

D. All of the above

7.

What is the outcome of the 'multiply' function mentioned in the text?

a)

C. A * B

b)

B. A - B

c)

D. A / B

d)

A. A + B

8.

What is the purpose of local variables in a function?

a)

B. To store global variables

b)

D. To delete the function

c)

C. To be accessible only inside the function

d)

A. To confuse the programmer

9.

What is the purpose of using parameters instead of variables in a function?

a)

A. To confuse the programmer

b)

C. To assign values when calling the function

c)

D. To delete the function

d)

B. To store global variables

10.

What is the purpose of the 'generate_rgb' function mentioned in the text?

a)

C. To delete variables

b)

D. To confuse programmers

c)

B. To generate random colors

d)

A. To generate random numbers

11.

What is the purpose of the 'generate_color' function mentioned in the text?

a)

C. To delete variables

b)

B. To generate random colors

c)

A. To generate random numbers

d)

D. To confuse programmers

12.

What is the primary goal of functions in Python?

a)

C. To generate random numbers

b)

B. To organize code and split it into tasks

c)

A. To confuse programmers

d)

D. To delete variables

13.

What is the purpose of the 'about_me' function mentioned in the text?

a)

B. To organize personal information

b)

C. To generate random numbers

c)

A. To confuse programmers

d)

D. To delete variables

14.

What is the purpose of the 'generate' function mentioned in the text?

a)

A. To organize code and split it into tasks

b)

B. To generate random colors

c)

D. To confuse programmers

d)

C. To delete variables

15.

What is the purpose of the 'generate_color' function in changing text color?

a)

B. To generate random colors

b)

A. To generate random numbers

c)

D. To confuse programmers

d)

C. To delete variables