Python Functions Quiz Part-1 for Beginners

Check out this post, if you wish to test your comfort level with Python functions. They are one of the key ingredients of the Python programming ecosystem just like classes, exceptions, and file handling.

In this quiz, we’ve covered 20 basic questions on the Python functions. If you are a beginner, then this quiz could be a good medium to rehearse the concepts learned.

Most probably, you would know that every entity that holds or references to data or metadata is an object in Python.

And Functions in Python are also objects. This unique ability enables the programmers to leverage the full potential of functions.

If you want to excel in Python programming, then you must know how to optimize the code. We host a detailed guide on this blog that can help you learn optimization. Attempt the quiz and come back to read the below post.

Now, go through the below quiz and see how you score in this test.

Python Functions Quiz Part-1 for Beginners.

Python Functions Quiz Part-1 for Beginner Programmers

Python Functions Quiz Part-1

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

Click here to view the answer.
Answer. A

 

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

Click here to view the answer.
Answer. B

 

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

Click here to view the answer.
Answer. B

 

Q-4. Which of the following keywords marks the beginning of function block?

A. fun
B. define
C. def
D. function

Click here to view the answer.
Answer. C

 

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

Click here to view the answer.
Answer. C

 

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.

Click here to view the answer.
Answer. A

 

Q-7.  Which of the following statements correctly represent the function body in the given code snippet?

A. return “number”
B. print(number)
C. print(“number”)
D. return number
 

Click here to view the answer.
Answer. D

 

Q-8.  What is the output of the following code snippet?

A. Welcome
     Viewers
B. Welcome
    ViewersViewersViewers
C. Welcome
    Viewers,Viewers,Viewers
D. Welcome

Click here to view the answer.
Answer. B

 

Q-9.  What is the output of the following code snippet?

A. HelloHelloHelloHelloHello
B. HelloHelloHelloHello
C. invalid call
D. infinite loop

Click here to view the answer.
Answer. D

 

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

Click here to view the answer.
Answer. B

 

Q-11. What is the output of the following code snippet?

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

Click here to view the answer.
Answer. E

 

Q-12. What is the output of the following code snippet?

A. 1 3
B. 3 1
C. The program has a runtime error because x is not defined.
D. 1 1
E. 3 3

Click here to view the answer.
Answer. B

 

Q-13. What is the output of the following code snippet?

A. 1 4
B. 4 1
C. The program has a runtime error because local variable ‘num’ referenced before assignment.
D. 1 1
E. 4 4

Click here to view the answer.
Answer. C

 

Q-14. What is the output of the following code snippet?

A. 1 4
B. 4 1
C. The program has a runtime error because local variable ‘num’ referenced before assignment.
D. 1 1
E. 4 4

Click here to view the answer.
Answer. E

 

Q-15. What is the output of the following code snippet?

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

Click here to view the answer.
Answer. E

 

Q-16. What is the output of the following code snippet?

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

Click here to view the answer.
Answer. D

 

Q-17. What is the output of the following code snippet?

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

Click here to view the answer.
Answer. E

 

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):

Click here to view the answer.
Answer. C

 

Q-19. What is the output of the following code snippet?

A. 6
B. 222
C. 8
D. None of the above

Click here to view the answer.
Answer. C

 

Q-20. What is the output of the following code snippet?

A. 27
    81
    343
B. 6
    9
    12
C. 9
    27
    81
D. 8
    27
    64

Click here to view the answer.
Answer. C

 

Summary – Python functions quiz part-1 for Beginners.

We hope that you’d enjoyed going through the above Python functions quiz part-1. We host a no. of other quizzes on various programming topics in Python. You can follow the below section to find out the one that interests you the most.

Soon, we’ll also come up with a 2nd part of the quiz on Python functions. Till then, continue reading and keep learning.

Thanks,

TechBeamers.

Leave a Reply


*