Home Artificial Intelligence Python Capabilities Quiz – AICORR.COM

Python Capabilities Quiz – AICORR.COM

3
0


Welcome to the Python Capabilities Quiz!

Capabilities are a basic a part of Python that assist make code reusable, readable, and modular. This quiz will take a look at your data of Python capabilities, together with syntax, arguments, return values, scope, built-in capabilities, and extra.

Desk of Contents:

  • Python quizzes for novices collection

Capabilities Quiz


Quiz Questions

1. What’s the right technique to outline a perform in Python?
a) perform my_func():
b) def my_func:
c) def my_func():
d) create perform my_func()

2. What key phrase is used to exit a perform and return a price?
a) exit
b) cease
c) return
d) break

3. What would be the output of the next code?

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

print(add(2, 3))

a) 2 + 3
b) 5
c) None
d) Error

4. What would be the output of this code?

def my_func(x=5):
return x * 2

print(my_func())

a) 10
b) 5
c) None
d) Error

5. What’s the default return worth of a perform that doesn’t explicitly return a price?
a) 0
b) None
c) False
d) Empty String

6. Which of the next is NOT a legitimate perform identify?
a) def _my_func():
b) def 2nd_function():
c) def myFunc():
d) def func_123():

7. What’s the right technique to name a perform named greet?
a) name greet()
b) greet()
c) run greet()
d) execute greet()

8. What would be the output of this code?

def my_func(a, b=10):
return a + b

print(my_func(5))

a) 15
b) 10
c) 5
d) Error

9. What does the *args parameter permit in a perform?
a) Accepts a set variety of arguments
b) Accepts a number of positional arguments
c) Accepts a number of key phrase arguments
d) Permits a perform to return a number of values

10. What would be the output of this code?

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

print(multiply(3, 4))

a) 12
b) 6
c) 8
d) Error

11. What does **kwargs do in a perform?

a) Accepts a number of positional arguments
b) Accepts a number of key phrase arguments
c) Accepts a set variety of arguments
d) Throws an error if further arguments are handed

12. What would be the output of this perform name?

def instance(x, y=5):
return x + y

print(instance(3, y=7))

a) 10
b) 8
c) 15
d) Error

13. What’s a lambda perform?
a) A perform with a number of return values
b) A perform with no arguments
c) A small nameless perform
d) A perform that modifies world variables

14. What’s the output of this lambda perform?

sq. = lambda x: x * x
print(sq.(4))

a) 8
b) 16
c) 4
d) Error

15. What’s the right technique to move an arbitrary variety of key phrase arguments?
a) def func(**kwargs):
b) def func(*kwargs):
c) def func(***kwargs):
d) def func($kwargs):

16. Which assertion about Python capabilities is TRUE?
a) Capabilities should at all times return a price
b) A perform can modify world variables with out the world key phrase
c) Capabilities can have a number of return statements
d) Capabilities can not settle for a number of arguments

17. What would be the output of the next code?

def outer():
x = 10
def internal():
return x + 5
return internal()

print(outer())

a) 15
b) 10
c) 5
d) Error

18. What’s recursion in Python?
a) A perform calling itself
b) A perform returning a number of values
c) A perform modifying world variables
d) A perform taking no parameters

19. What is going to occur if a recursive perform doesn’t have a base case?
a) It can run indefinitely and trigger an error
b) It can return None
c) It can cease after 10 iterations
d) It can throw a syntax error

20. What does the world key phrase do in Python?
a) Declares a variable as immutable
b) Permits a perform to entry a worldwide variable
c) Restricts a perform from modifying a variable
d) Creates a neighborhood variable


How did you do? 🎯

  • 18-20 right → 🏆 Glorious! You’re a Python capabilities professional!
  • 14-17 right → 👍 Nice job! Maintain training.
  • 10-13 right → 🙂 Good, however there’s room for enchancment.
  • Beneath 10 → 🤔 No worries! Evaluation the ideas and take a look at once more.

by AICorr Staff

We’re proud to supply our intensive data to you, free of charge. The AICorr Staff places a number of effort in researching, testing, and writing the content material throughout the platform (aicorr.com). We hope that you simply be taught and progress ahead.

Previous articleCustomized Rest Aid – Cute Tech Devices
Next articleSaying the final availability of Llama 4 MaaS on Vertex AI

LEAVE A REPLY

Please enter your comment!
Please enter your name here