You are on page 1of 4

TUTORIAL 5

1. What is a function in Python, and why is it useful in programming?

2. Explain the concept of function parameters and arguments.

3. How do you define a function in Python? Provide an example.

4. Describe the purpose of the "return" statement in a function.

5. What are built-in functions, and give an example of one that Python provides?

6. Python function always returns a value. True or False?

7. Explain what happens when the following recursive function is called with the value
4 as an argument:

8. Explain what happens when the following recursive function is called with the value 4
as an argument:

As a result, this code will lead to an infinite recursion, and it will keep printing the value 4
indefinitely until the program is forcibly terminated.

9. Explain what happens when the following recursive function is called with the values "hello"
and 0 as arguments:

Fatin Nabila
TUTORIAL 5

10. Predict the output of the following code:

a) `8`

b) `0 1 4 9`

c) `24`

d) Hello, World!
NameError: name 'message' is not
defined

Fatin Nabila
TUTORIAL 5

e) 6
20

f) (8, 7)

g) "emp"
"salary"

h) "Emma 25".

i) 15

Fatin Nabila
TUTORIAL 5

j) 30.
error to print num

k) 15.
15.

11. Choose the correct function declaration of fun1() so that we can execute the following
function call successfully.

A: def fun1(**kwargs) D: def fun1(*data)


B: No, it is not possible in Python
C: def fun1(args*)
D: def fun1(*data)

12. Given the following function fun1(), select all the correct function calls.

Ans. Description fun1("Emma", age=23)


1. fun1(“Emma”, age=23) fun1(age=23, name="Emma")
2. fun1(age=23, name=”Emma”)
fun1(name=”Emma”,23)
fun1(age=23, “Emma”)

name to accept arbitrary arguments}

Fatin Nabila

You might also like