How do you define a function in Python?
Experience Level: Junior
Tags: Python
Answer
To define a Python function, use keyword def.
Example:
def say_hello():
print("Hello, I am here.")
Related Python job interview questions
What is a convention to name a private method in Python?
Python JuniorHow do you communicate via code what argument types and what return value type a function has?
Python JuniorHow can you display all modules that are currently loaded in your Python program?
Python JuniorWhat happens if you import a same module in Python twice and the module contains code print("hello")?
Python JuniorHow do you find out in what folder is the Python imported module stored?
Python Junior