TechBeamersTechBeamers
  • Learn ProgrammingLearn Programming
    • Python Programming
      • Python Basic
      • Python OOP
      • Python Pandas
      • Python PIP
      • Python Advanced
      • Python Selenium
    • Python Examples
    • Selenium Tutorials
      • Selenium with Java
      • Selenium with Python
    • Software Testing Tutorials
    • Java Programming
      • Java Basic
      • Java Flow Control
      • Java OOP
    • C Programming
    • Linux Commands
    • MySQL Commands
    • Agile in Software
    • AngularJS Guides
    • Android Tutorials
  • Interview PrepInterview Prep
    • SQL Interview Questions
    • Testing Interview Q&A
    • Python Interview Q&A
    • Selenium Interview Q&A
    • C Sharp Interview Q&A
    • PHP Interview Questions
    • Java Interview Questions
    • Web Development Q&A
  • Self AssessmentSelf Assessment
    • Python Test
    • Java Online Test
    • Selenium Quiz
    • Testing Quiz
    • HTML CSS Quiz
    • Shell Script Test
    • C/C++ Coding Test
Search
  • Python Multiline String
  • Python Multiline Comment
  • Python Iterate String
  • Python Dictionary
  • Python Lists
  • Python List Contains
  • Page Object Model
  • TestNG Annotations
  • Python Function Quiz
  • Python String Quiz
  • Python OOP Test
  • Java Spring Test
  • Java Collection Quiz
  • JavaScript Skill Test
  • Selenium Skill Test
  • Selenium Python Quiz
  • Shell Scripting Test
  • Latest Python Q&A
  • CSharp Coding Q&A
  • SQL Query Question
  • Top Selenium Q&A
  • Top QA Questions
  • Latest Testing Q&A
  • REST API Questions
  • Linux Interview Q&A
  • Shell Script Questions
© 2024 TechBeamers. All Rights Reserved.
Reading: Python Functions Quiz Part-1
Font ResizerAa
TechBeamersTechBeamers
Font ResizerAa
  • Python
  • SQL
  • C
  • Java
  • Testing
  • Selenium
  • Agile Concepts Simplified
  • Linux
  • MySQL
  • Python Quizzes
  • Java Quiz
  • Testing Quiz
  • Shell Script Quiz
  • WebDev Interview
  • Python Basic
  • Python Examples
  • Python Advanced
  • Python OOP
  • Python Selenium
  • General Tech
Search
  • Programming Tutorials
    • Python Tutorial
    • Python Examples
    • Java Tutorial
    • C Tutorial
    • MySQL Tutorial
    • Selenium Tutorial
    • Testing Tutorial
  • Top Interview Q&A
    • SQL Interview
    • Web Dev Interview
  • Best Coding Quiz
    • Python Quizzes
    • Java Quiz
    • Testing Quiz
    • ShellScript Quiz
Follow US
© 2024 TechBeamers. All Rights Reserved.
Python QuizzesPython Tutorials

Python Functions Quiz Part-1

Last updated: Mar 02, 2024 4:49 pm
By Meenakshi Agarwal
Share
9 Min Read
Python Functions Quiz Part-1 for Beginner Programmers
Python Functions Quiz Part-1 for Beginner Programmers
SHARE
Basic Level Python ExercisesPython Exercises on StringsPython Function Quiz-2
Python Exercises on LoopsPython Exercises on Data StructurePython File I/O Quiz
Python Exercises on List | Tuple | DictPython Exercises on Data ClassesPython Threading Quiz
Python Exercises for Beginners

If you want to test your comfort level with Python functions, check out this quiz. Functions, along with classes, exceptions, and file handling, are essential ingredients of the Python programming ecosystem. Our quiz covers 20 basic questions on Python functions and is an excellent tool for beginners to practice and reinforce concepts.

Contents
Q-1. What type of value does a Python function return by default?Q-2. Which of the following does a Python function include in its header?Q-3. Which type of scheme does a Python function use to enclose its arguments?Q-4. Which of the below keywords is used to begin a function in Python?Q-5. Where does a Python function keep its parameters and local variables?Q-6.  Which of the given scenario functions won’t return any value?Q-7.  Which of the given options fit correctly in the function body?Q-8.  What is the output of the following Python code?Q-9.  What will the Python function return in the below code?Q-10. Which of the following is a valid statement in Python?Q-11. What is the output of the following Python code?Q-12. What does the function in the below Python code return?Q-13. What is the output of the following Python coding snippet? It is modifying a static variable.Q-14. What is the output of the following Python coding snippet? It is modifying a global variable.Q-15. What will the below Python function return? It has default values set for its parameters.Q-16. What is the output of the following Python code? Will it behave differently from the previous question?Q-17. This Python script is playing around with the parameters. Try to understand how and answer.Q-18. Which of the following is a correct Python function header?Q-19. What does the following Python code print?Q-20. What does the following Python script using the lambda operator return?More Food for Thoughts

Test Your Python Function Knowledge with Beginner Level Quiz – Part I

Python Functions Quiz Part-1 for Beginner Programmers
Python Functions Quiz Part-1

In Python, every entity that holds or references data or metadata is an object, including functions.

This unique ability enables programmers to fully leverage the potential of functions.

To excel in Python programming, it’s essential to know how to optimize your code.

Take the Python functions quiz below and see how you score on this test.

Q-1. What type of value does a Python function return by default?

  • A. None
  • B. int
  • C. double
  • D. public
  • E. null
Hover here to view the answer!
Answer. A

Q-2. Which of the following does a Python function include in its header?

  • A. function name
  • B. function name and parameter list
  • C. parameter list
  • D. return value
Hover here to view the answer!
Answer. B

Q-3. Which type of scheme does a Python function use to enclose its arguments?

  • A. brackets
  • B. parentheses
  • C. curly braces
  • D. quotation marks
Hover here to view the answer!
Answer. B

Q-4. Which of the below keywords is used to begin a function in Python?

  • A. fun
  • B. define
  • C. def
  • D. function
Hover here to view the answer!
Answer. C

Q-5. Where does a Python function keep its parameters and local variables?

  • A. a heap
  • B. storage area
  • C. a stack
  • D. an array
Hover here to view the answer!
Answer. C

Q-6.  Which of the given scenario functions won’t 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 a lowercase.
Hover here to view the answer!
Answer. A

Q-7.  Which of the given options fit correctly in the function body?

def f(number):
  # Missing function body
print(f(5))
  • A. return “number”
  • B. print(number)
  • C. print(“number”)
  • D. return number
Hover here to view the answer!
Answer. D

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

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
Hover here to view the answer!
Answer. B

Q-9.  What will the Python function return in the below code?

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
Hover here to view the answer!
Answer. D

Q-10. Which of the following is a valid statement in Python?

  • A. function invocation
  • B. pass-by-value
  • C. pass by reference
  • D. pass by name
Hover here to view the answer!
Answer. B

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

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
Hover here to view the answer!
Answer. E

Q-12. What does the function in the below Python code return?

num = 1
def func():
    num = 3
    print(num)

func()
print(num)
  • A. 1 3
  • B. 3 1
  • C. 1 1
  • D. 3 3
Hover here to view the answer!
Answer. B

Q-13. What is the output of the following Python coding snippet? It is modifying a static variable.

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’ is referenced before the assignment.
  • D. 1 1
  • E. 4 4
Hover here to view the answer!
Answer. C

Q-14. What is the output of the following Python coding snippet? It is modifying a global variable.

num = 1
def func():
    global num
    num = num + 3
    print(num)

func()
print(num)
  • A. 1 4
  • B. 4 1
  • C. 1 1
  • D. 4 4
Hover here to view the answer!
Answer. D

Q-15. What will the below Python function return? It has default values set for its parameters.

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

test()
  • A. 1 3
  • B. 3 1
  • C. 1 1
  • D. 3 3
Hover here to view the answer!
Answer. D

Q-16. What is the output of the following Python code? Will it behave differently from the previous question?

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

test(2, 1)
  • A. 1 3
  • B. 2 3
  • C. 3 2
  • D. 3 3
Hover here to view the answer!
Answer. C

Q-17. This Python script is playing around with the parameters. Try to understand how and answer.

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. 3 2
  • D. 3 3
Hover here to view the answer!
Answer. D

Q-18. Which of the following is a correct Python function header?

  • 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):
Hover here to view the answer!
Answer. C

Q-19. What does the following Python code print?

exp = lambda x: x ** 3
print(exp(2))
  • A. 6
  • B. 222
  • C. 8
  • D. None of the above
Hover here to view the answer!
Answer. C

Q-20. What does the following Python script using the lambda operator return?

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
    9
    12
  • C. 9
    27
    81
  • D. 8
    27
    64
Hover here to view the answer!
Answer. C

Recap: Python Functions Quiz Part 1 – Beginner Level

We hope you enjoyed taking the Python Functions Quiz – Part 1. If you’re interested in exploring more programming topics in Python, check out our collection of quizzes in the section below.

More Food for Thoughts

  • Entry-Level Java Developer Quiz
  • Java Quiz on Exception Handling with 20 Questions
  • Entry-Level Python Developer Quiz
  • Python File Handling Quiz for Beginners
  • Python File Handling Quiz for Experienced
  • 30 Python List, Tuple, Dictionary Questions
  • Python Functions Quiz Part II
  • Automation Testing Quiz for Software Engineers
  • Linux Basic Question and Answers for Starters

Stay tuned for the upcoming Python tutorials and quizzes. Keep learning and expanding your knowledge.

Thank you,

TechBeamers.

You Might Also Like

How to Connect to PostgreSQL in Python

Generate Random IP Address (IPv4/IPv6) in Python

Python Remove Elements from a List

Selenium Python Extent Report Guide

10 Python Tricky Coding Exercises

Meenakshi Agarwal Avatar
By Meenakshi Agarwal
Follow:
Hi, I'm Meenakshi Agarwal. I have a Bachelor's degree in Computer Science and a Master's degree in Computer Applications. After spending over a decade in large MNCs, I gained extensive experience in programming, coding, software development, testing, and automation. Now, I share my knowledge through tutorials, quizzes, and interview questions on Python, Java, Selenium, SQL, and C# on my blog, TechBeamers.com.
Previous Article Python file handling quiz part-2 for Experienced Programmers Python File Handling Quiz for Experienced Programmers
Next Article Python Functions Quiz Part-2 for Experienced Programmers Python Functions Quiz Part-2

Popular Tutorials

SQL Interview Questions List
50 SQL Practice Questions for Good Results in Interview
SQL Interview Nov 01, 2016
Demo Websites You Need to Practice Selenium
7 Sites to Practice Selenium for Free in 2024
Selenium Tutorial Feb 08, 2016
SQL Exercises with Sample Table and Demo Data
SQL Exercises – Complex Queries
SQL Interview May 10, 2020
Java Coding Questions for Software Testers
15 Java Coding Questions for Testers
Selenium Tutorial Jun 17, 2016
30 Quick Python Programming Questions On List, Tuple & Dictionary
30 Python Programming Questions On List, Tuple, and Dictionary
Python Basic Python Tutorials Oct 07, 2016
//
Our tutorials are written by real people who’ve put in the time to research and test thoroughly. Whether you’re a beginner or a pro, our tutorials will guide you through everything you need to learn a programming language.

Top Coding Tips

  • PYTHON TIPS
  • PANDAS TIPSNew
  • DATA ANALYSIS TIPS
  • SELENIUM TIPS
  • C CODING TIPS
  • GDB DEBUG TIPS
  • SQL TIPS & TRICKS

Top Tutorials

  • PYTHON TUTORIAL FOR BEGINNERS
  • SELENIUM WEBDRIVER TUTORIAL
  • SELENIUM PYTHON TUTORIAL
  • SELENIUM DEMO WEBSITESHot
  • TESTNG TUTORIALS FOR BEGINNERS
  • PYTHON MULTITHREADING TUTORIAL
  • JAVA MULTITHREADING TUTORIAL

Sign Up for Our Newsletter

Subscribe to our newsletter to get our newest articles instantly!

Loading
TechBeamersTechBeamers
Follow US
© 2024 TechBeamers. All Rights Reserved.
  • About
  • Contact
  • Disclaimer
  • Privacy Policy
  • Terms of Use
TechBeamers Newsletter - Subscribe for Latest Updates
Join Us!

Subscribe to our newsletter and never miss the latest tech tutorials, quizzes, and tips.

Loading
Zero spam, Unsubscribe at any time.
x