PYnative

Python Programming

  • Learn Python ▼
    • Python Tutorials
    • Python Basics
    • Python Interview Q&As
  • Exercises ▼
    • Python Exercises
    • C++ Exercises
    • C Programming Exercises
    • Java Exercises
    • C# Exercises
  • Quizzes
  • Online Compilers▼
    • Online Python Code Editor
    • Online C Compiler
    • Online C++ Compiler
    • Online Java Compiler
    • Online C# Compiler
Home » Python » Quizzes » Python Functions Quiz

Python Functions Quiz

Updated on: August 26, 2025 | 43 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 output of the following function call

def add(a, b):
  return a + b
  a = 20
  b = 30
  return a + b

result = add(5, 10)
print(result)
 
 
 
 

2. Select Correct Function

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

 
 
 
 

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

 
 
 
 

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

count = 0

def increment():
    global count
    count += 1

increment()
print(count)
 
 
 
 

5. 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())
 
 
 
 

6. What is the output of the add() function call

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

result = add(3, 2)
print(result)
 
 
 
 

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

def do_nothing():
    pass

result = do_nothing()
print(result)
 
 
 
 

8. What is a Python decorator primarily used for?

 
 
 
 

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

x = 5

def update_x():
    global x
    x = 10

update_x()
print(x)
 
 
 
 

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

 
 
 
 

11. 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)
 
 
 

12. 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)
 
 
 
 

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

 
 
 
 

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

 
 
 
 

15. 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)
 
 
 
 

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

 
 
 

17. What is the output of the following display_person() function call

def display_person(*args):
    for i in args:
        print(i)

display_person(name="Emma", age="25")
 
 
 

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

 
 
 
 

19. One of the main benefits of using modules in Python is:

 
 
 
 

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

 
 
 
 

21. Select which True for Python function

 
 
 
 

22. Select which is True for Python function

 
 
 
 

23. 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)
 
 
 

24. 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)
 
 
 
 

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

 
 
 
 

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
Java Exercises
C# 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
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
  • Java Exercises
  • C# 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–2026 pynative.com

Advertisement
Advertisement