Module 6
Creating your first function
Defining a function with def.
Giving code a name
You define a function with the def keyword, followed by the name, parentheses, and a colon. The body is indented.
Python
def greet():
print("Hello, scientist!")
greet()
greet()→ Hello, scientist!
Hello, scientist!
The function does nothing until you call it. You can call it as many times as you want.
Your task
Define a function
- Define a function greet() that prints Hello. Call it.