QUESTION IMAGE
Question
args is used for positional arguments, *kwargs is used for keyword arguments
args is used for keyword arguments, *kwargs is used for positional arguments
args is used for strings, *kwargs is used for numbers
there is no difference
question 10
what is the purpose of a try - except block in python?
to define a function
to handle potential errors in code
to create a loop
to print a value to the console
In Python, the try - except block is specifically designed to handle exceptions (errors) that might occur during the execution of the code within the try block. If an error happens in the try block, the program flow jumps to the corresponding except block, allowing for graceful error handling instead of the program crashing.
- The
defkeyword is used to define a function, not thetry - exceptblock. - Loops are created using constructs like
fororwhile, nottry - except. - Printing a value to the console is done using the
print()function, nottry - except.
Snap & solve any problem in the app
Get step-by-step solutions on Sovi AI
Photo-based solutions with guided steps
Explore more problems and detailed explanations
To handle potential errors in code