Which of the following is the correct way to define a function in Python?

  • def my_function():
  • define_function my_function():
  • func my_function():
  • function my_function():
The correct way to define a function in Python is as follows: 'def my_function():'. The 'def' keyword is used to define a function, followed by the function name and parentheses.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *