QUESTION IMAGE
Question
question 1
1 pts
what is the purpose of a function in python?
to organize code and make it more reusable
to perform a specific task
to reduce code duplication
all of the above
question 2
1 pts
what keyword is used to define a function in python?
define
func
def
function
Brief Explanations
- Question 1:
- Functions in Python help organize code, making it more modular and easier to understand. Reusability means you can call the same function multiple times with different inputs. Performing a specific task is the core job of a function - it encapsulates a set of operations. Reducing code duplication is achieved as instead of writing the same code block multiple times, you write a function once and call it. So all the listed options are valid purposes of a Python function.
- Question 2:
- In Python, the
defkeyword is used to define a function. For example,def my_function():starts the definition of a function namedmy_function.defineis not a Python keyword for function definition,funcis not a standard keyword for this purpose, andfunctionis not the keyword used (though in some other languages like JavaScript,functionis used for function definition).
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
- Question 1: All of the above
- Question 2: def