By now, you have probably found out that it's not very fun to write the same code over and over again. Not only is it not fun, it's difficult to scroll through and understand, and a huge pain in the tail if something needs to be changed.
If you have code that frequently needs to be run, you can define a function for it like this:
```python
def say_hi():
print("Hello")
# do some things
say_hi()
```
However, we haven't done much for ourselves because `say_hi()` isn't much different than `print("Hello")`.
The real magic is when you create a function to handle some logic so you don't have to do it other places. Notice how this returns a value that can be used later:
```python
def fahrenheit_to_celsius(fahrenheit):
return (fahrenheit - 32) * 5 / 9
result = fahrenheit_to_celsius(67)
print(result)
```
> [!INFO] 📕 Vocab Break!
> When you define a function like `fahrenheit_to_celsius(fahrenheit)`, `fahrenheit` is a **parameter**
> When you use the function like `fahrenheit_to_celsius(67)`, `67` is an **argument**
Parameters can also have default values:
```python
def say_hi(name = "friend"):
print("Hello, " + name)
say_hi("Ben") # Hello, Ben
say_hi() # Hello, friend
```
Functions can have multiple parameters:
```python
def say_hi(first_name, last_name):
print("Hello, " + first_name + " " + last_name)
say_hi("Ben", "Hoff")
# OR
say_hi(last_name = "Hoff", first_name = "Ben")
```
Finally, here's an idea that could lead to a bad habit. Try to avoid doing this, but it will be helpful for us right now
```python
def input_pin():
user_input = int( input("What's your pin? ") )
if user_input == 1234:
print("Nice! You're in!")
else:
print("Uh oh, try again")
input_pin()
input_pin()
```
---
## Instructions
Use what you have learned about functions to create a function that asks your *Buzzfeed Quiz* questions for you.