PYnative

Python Programming

  • Learn Python
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises
  • Quizzes
  • Code Editor
Home » Python » Quizzes » Python Functions Quiz

Python Functions Quiz

Updated on: August 26, 2025 | 40 Comments

Mastering functions and modules is crucial for writing clean, efficient, and scalable Python code. This Python Functions Quiz is designed to test your understanding of two fundamental Python concepts: Functions and Modules.

From defining functions, understanding variable scope and function arguments to importing and utilizing modules, these Multiple Choice Questions (MCQs) will help solidify your knowledge and highlight areas for improvement.

  • The quiz contains 25 questions. There is no time limit.
  • You will get 1 point for each correct answer. Solve 15 correctly to pass the test
  • Read Python functions and Python function arguments for any help.

Also, See:

  • Python Functions Exercise.
  • 15 Python Quizzes: each focusing on a specific topic

1. What is the primary purpose of the if __name__ == "__main__": block in a Python script?

 
 
 
 

2. The os.path module in Python is primarily used for:

 
 
 
 

3. What will be the output of the following Python code?

numbers = [1, 2, 3, 4, 5]
squared_numbers = list(map(lambda x: x*x, numbers))
print(squared_numbers)
 
 
 

4. What is the output of the following code?

def outer_fun(a, b):
    def inner_fun(c, d):
        return c + d
    return inner_fun(a, b)

res = outer_fun(5, 10)
print(res)
 
 
 

5. Which function from the random module would you use to get a random integer between 1 and 10 (including 1 and 10)?

 
 
 
 

6. Select Correct Function

Which random module function would you use to get a random integer within a specific range (inclusive of both ends)?

 
 
 
 

7. What is the output of the following display() function call

def display(**kwargs):
    for i in kwargs.values():
        print(i)

display(emp="Kelly", salary=9000)
 
 
 
 

8. What is the output of the following display() function call

def display(**kwargs):
    for i in kwargs:
        print(i)

display(emp="Kelly", salary=9000)
 
 
 
 

9. What will be the output of the following Python code?

def calculate_sum(*args):
    total = 0
    for num in args:
        total += num
    return total

print(calculate_sum(1, 2, 3, 4))
print(calculate_sum())
 
 
 
 

10. What is a “default argument” in a Python function?

 
 
 
 

11. Choose the correct declaration for fun1().

To enable the successful execution of the below two fun1() function call, choose the correct declaration for fun1().

fun1(25, 75, 55)
fun1(10, 20)
 
 
 
 

12. Which sys module function/attribute is commonly used to exit a Python script programmatically?

 
 
 
 

13. What is the output of the following function call

def fun1(name, age=20):
    print(name, age)

fun1('Emma', 25)
 
 
 

14. What will be the output of the following Python code?

def do_nothing():
    pass

result = do_nothing()
print(result)
 
 
 
 

15. Which of the following best describes a Python lambda function?

 
 
 
 

16. Select which True for Python function

 
 
 
 

17. Select which is True for Python function

 
 
 
 

18. What is a Python decorator primarily used for?

 
 
 
 

19. Which of the following is the correct way to import only the pi constant from the math module?

 
 
 
 

20. What will be the output of the following Python code?

list1 = [1, 2, 3]

def append_item(a_list, item):
    a_list.append(item)

append_item(list1, 4)
print(list1)
 
 
 
 

21. Which of the following modules is NOT part of Python’s standard library (meaning you usually need to install it separately)?

 
 
 
 

22. What will be the output of the following Python code?

def multiply(a, b):
    return a * b

def apply_operation(func, x, y):
    return func(x, y)

result = apply_operation(multiply, 5, 3)
print(result)
 
 
 
 

23. How would you get the current date and time using the datetime module?

 
 
 

24. What will be the output of the following Python code?

count = 0

def increment():
    global count
    count += 1

increment()
print(count)
 
 
 
 

25. Select all correct function calls

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

def fun1(name, age):
    print(name, age)
 
 
 

Loading ... Loading …

Loading

Filed Under: Python, Python Basics, Python Quizzes

Did you find this page helpful? Let others know about it. Sharing helps me continue to create free Python resources.

TweetF  sharein  shareP  Pin

About Vishal

Image

I’m Vishal Hule, the Founder of PYnative.com. As a Python developer, I enjoy assisting students, developers, and learners. Follow me on Twitter.

Related Tutorial Topics:

Python Python Basics Python Quizzes

All Coding Exercises:

C Exercises
C++ Exercises
Python Exercises

Python Exercises and Quizzes

Free coding exercises and quizzes cover Python basics, data structure, data analytics, and more.

  • 15+ Topic-specific Exercises and Quizzes
  • Each Exercise contains 25+ questions
  • Each Quiz contains 25 MCQ
Exercises
Quizzes

Loading comments... Please wait.

In: Python Python Basics Python Quizzes
TweetF  sharein  shareP  Pin

  Python Quizzes

  • 15 Python Quizzes
  • Python Online MCQ Test
  • Basic Quiz For Beginners
  • Variables and Data Types Quiz
  • Functions Quiz
  • if else and loops Quiz
  • Numbers Quiz
  • String Quiz
  • List Quiz
  • Set Quiz
  • Dictionary Quiz
  • Tuple Quiz
  • Operators and Expression Quiz
  • Input and Output Quiz
  • Multithreading and Multiprocessing Quiz
  • File Handling Quiz
  • Random Data Generation Quiz

 Explore Python

  • Python Tutorials
  • Python Exercises
  • Python Quizzes
  • Python Interview Q&A
  • Python Programs

All Python Topics

Python Basics Python Exercises Python Quizzes Python Interview Python File Handling Python OOP Python Date and Time Python Random Python Regex Python Pandas Python Databases Python MySQL Python PostgreSQL Python SQLite Python JSON

About PYnative

PYnative.com is for Python lovers. Here, You can get Tutorials, Exercises, and Quizzes to practice and improve your Python skills.

Follow Us

To get New Python Tutorials, Exercises, and Quizzes

  • Twitter
  • Facebook
  • Sitemap

Explore Python

  • Learn Python
  • Python Basics
  • Python Databases
  • Python Exercises
  • Python Quizzes
  • Online Python Code Editor
  • Python Tricks

Coding Exercises

  • C Exercises
  • C++ Exercises
  • Python Exercises

Legal Stuff

  • About Us
  • Contact Us

We use cookies to improve your experience. While using PYnative, you agree to have read and accepted our:

  • Terms Of Use
  • Privacy Policy
  • Cookie Policy

Copyright © 2018–2025 pynative.com

Advertisement