0% found this document useful (0 votes)
45 views10 pages

Python Functions Quiz for Beginners

This document is a quiz designed for beginner programmers to test their knowledge of Python functions. It contains 20 multiple-choice questions covering topics such as function return values, function headers, and output of code snippets. Each question provides several answer options related to Python programming concepts.

Uploaded by

Nikhil Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views10 pages

Python Functions Quiz for Beginners

This document is a quiz designed for beginner programmers to test their knowledge of Python functions. It contains 20 multiple-choice questions covering topics such as function return values, function headers, and output of code snippets. Each question provides several answer options related to Python programming concepts.

Uploaded by

Nikhil Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Functions Quiz Part-1

Python Functions Quiz Part-1 (Beginner Level)

Python Functions Quiz Part-1 for Beginner Programmers

Q-1. What Is The Default Return Value For A Function That Does Not Return Any Value Explicitly?

A. None

B. int

C. double

D. public

E. null

Q-2. Which Of The Following Items Are Present In The Function Header?

A. function name

B. function name and parameter list

C. parameter list

D. return value

Q-3. Which Of The Following Enclose The Input Parameters Or Arguments Of A Function?

A. brackets

B. parentheses

C. curly braces

D. quotation marks
Q-4. Which Of The Following Keywords Marks The Beginning Of The Function Block?

A. fun

B. define

C. def

D. function

Q-5. What Is The Name Given To That Area Of Memory, Where The System Stores The Parameters And
Local Variables Of A Function Call?

A. a heap

B. storage area

C. a stack

D. an array

Q-6. Which Of The Following Function Definition Does Not Return Any Value?

A. a function that prints integers from 1 to 100.

B. a function that returns a random integer from 1 to 100.

C. a function that checks whether the current second is an integer from 1 to 100.

D. a function that converts an uppercase letter to lowercase.


Q-7. Which Of The Following Statements Correctly Represent The Function Body In The Given Code
Snippet?

def f(number):

# Missing function body

print(f(5))

A. return “number”

B. print(number)

C. print(“number”)

D. return number

Q-8. What Is The Output Of The Following Code Snippet?

def func(message, num = 1):


print(message * num)

func('Welcome')

func('Viewers', 3)

A. Welcome

Viewers

B. Welcome

ViewersViewersViewers

C. Welcome

Viewers,Viewers,Viewers

D. Welcome

Q-9. What Is The Output Of The Following Code Snippet?

def myfunc(text, num):

while num > 0:

print(text)

num = num - 1

myfunc('Hello', 4)

A. HelloHelloHelloHelloHello

B. HelloHelloHelloHello

C. invalid call

D. infinite loop
Q-10. Which Of The Following Would You Relate To A Function Call Made With An Argument Passed As
Its Parameter?

A. function invocation

B. pass by value

C. pass by reference

D. pass by name

Q-11. What Is The Output Of The Following Code Snippet?

def func(x = 1, y = 2):

x=x+y

y += 1

print(x, y)

func(y = 2, x = 1)

A. 1 3

B. 2 3

C. The program has a runtime error because x and y are not defined.

D. 3 2

E. 3 3

Q-12. What Is The Output Of The Following Code Snippet?

num = 1

def func():
num = 3

print(num)

func()

print(num)

A. 1 3

B. 3 1

C. The program has a runtime error because x is not defined.

D. 1 1

E. 3 3

Q-13. What Is The Output Of The Following Code Snippet?

num = 1

def func():

num = num + 3

print(num)

func()

print(num)

A. 1 4

B. 4 1

C. The program has a runtime error because the local variable ‘num’ referenced before assignment.

D. 1 1

E. 4 4
Q-14. What Is The Output Of The Following Code Snippet?

num = 1

def func():

global num

num = num + 3

print(num)

func()

print(num)

A. 1 4

B. 4 1

C. The program has a runtime error because the local variable ‘num’ referenced before assignment.

D. 1 1

E. 4 4

Q-15. What Is The Output Of The Following Code Snippet?

def test(x = 1, y = 2):

x=x+y

y += 1

print(x, y)

test()

A. 1 3

B. 3 1
C. The program has a runtime error because x and y are not defined.

D. 1 1

E. 3 3

Q-16. What Is The Output Of The Following Code Snippet?

def test(x = 1, y = 2):

x=x+y

y += 1

print(x, y)

test(2, 1)

A. 1 3

B. 2 3

C. The program has a runtime error because x and y are not defined.

D. 3 2

E. 3 3

Q-17. What Is The Output Of The Following Code Snippet?

def test(x = 1, y = 2):

x=x+y

y += 1

print(x, y)
test(y = 2, x = 1)

A. 1 3

B. 2 3

C. The program has a runtime error because x and y are not defined.

D. 3 2

E. 3 3

Q-18. Which Of The Following Function Headers Is Correct?

A. def f(a = 1, b):

B. def f(a = 1, b, c = 2):

C. def f(a = 1, b = 1, c = 2):

D. def f(a = 1, b = 1, c = 2, d):

Q-19. What Is The Output Of The Following Code Snippet?

exp = lambda x: x ** 3

print(exp(2))

A. 6

B. 222

C. 8

D. None of the above


Q-20. What Is The Output Of The Following Code Snippet?

myList = [lambda x: x ** 2,

lambda x: x ** 3,

lambda x: x ** 4]

for f in myList:

print(f(3))

A. 27

81

343

B. 6

12

C. 9

27

81

D. 8

27

64

You might also like