wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

PPL (Quiz 5) Procedures and Functions

Total questions: 25

Worksheet time: 14mins

Name
Class
Date
1.

What is the main difference between a function and a procedure?

a)

Functions return a value, while procedures do not.

b)

Procedures return a value, while functions do not.

c)

Functions are only used in Python, while procedures exist in all languages.

d)

There is no difference between functions and procedures.

2.

In which of the following scenarios is a procedure more appropriate than a function?

a)

Calculating the total price of a shopping cart.

b)

Checking the balance of a bank account.

c)

Transferring money between two accounts.

d)

Converting Celsius to Fahrenheit.

3.

Which of the following is a correct example of a function in Python?

a)

def greet(): print("Hello")

b)

def add(a, b): return a + b

c)

def display(): pass

d)

Both A and B

4.

What is "pass by value" in parameter passing?

a)

The function receives a copy of the variable.

b)

The function modifies the original variable.

c)

The function cannot accept parameters.

d)

The function only works with integers.

5.

What is "pass by reference" in parameter passing?

a)

The function gets a copy of the variable.

b)

The function modifies the original variable.

c)

The function creates a new variable.

d)

The function only accepts strings.

6.

Which type of variable is only accessible inside the function where it is declared?

a)

Global variable

b)

Local variable

c)

Static variable

d)

Reference variable

7.

What will be the output of this code? x = 5 def myFunc(): x = 10 print(x) myFunc() print(x)

a)

10 10

b)

5 5

c)

10 5

d)

Error

8.

What does recursion mean in programming?

a)

A function calling itself

b)

A function calling another function

c)

A function that does not return a value

d)

A function without parameters

9.

Which of the following is a real-world example of recursion?

a)

Printing a receipt

b)

Finding the shortest path in Google Maps

c)

Adding two numbers

d)

Transferring money in a bank

10.

What happens if a recursive function does not have a base case?

a)

It runs forever, causing infinite recursion.

b)

It stops after one call.

c)

It returns an error before execution.

d)

It converts into a loop.

11.

A function can return multiple values.

a)

True

b)

False

12.

The "scope" of a variable determines how long it exists in memory.

a)

True

b)

False

13.

In Python, global variables can be modified inside a function without using global.

a)

True

b)

False

14.

Static variables retain their value between function calls.

a)

True

b)

False

15.

Recursion can always be replaced by loops.

a)

True

b)

False

16.

A programming concept where a function calls itself to solve a smaller instance of a problem.

(Type your answer in ALL SMALL LETTERS)

(a)  

17.

The part of a program where a variable is accessible.

(Type your answer in ALL SMALL LETTERS)

(a)  

18.

The period during which a variable exists in memory before being destroyed.

(a)   of a variable.

(Type your answer in ALL SMALL LETTERS)

19.

The method of passing arguments where the function receives only a copy of the variable.

(Type your answer in ALL SMALL LETTERS)

(a)  

20.

The method of passing arguments where the function modifies the original variable.

(Type your answer in ALL SMALL LETTERS)

(a)  

21.

A reusable block of code that returns a value after execution.

(Type your answer in ALL SMALL LETTERS)

(a)  

22.

A reusable block of code that performs an action but does not return a value.

(Type your answer in ALL SMALL LETTERS)

(a)  

23.

The special condition in a recursive function that prevents infinite recursion.

(Type your answer in ALL SMALL LETTERS)

(a)  

24.

The keyword in Python used to modify a global variable inside a function.

(Type your answer in ALL SMALL LETTERS)

(a)  

25.

A variable that retains its value between function calls in some programming languages.

(Type your answer in ALL SMALL LETTERS)

(a)