Programming is all about automating repetitive tasks. What better way to do this than to encapsulate multiple lines of code into a single line of code. Functions allow you to contain multiple lines of code to execute a repeatable action. This tutorial will cover the following learning objectives:
def hello_message():
print("Hello, World!")
hello_message()
OUTPUT: "Hello, World"!
def hello_message(name):
print(f'Hello, {name}!')
hello_message('Greg')
OUTPUT: "Hello, Greg!"
def create_username(first_name, last_name, age):
username = f'{first_name}{last_name}{age}'
return username
create_username('Thomas', 'Smith', 23)
OUTPUT: "ThomasSmith23"
print(f"You owe ${amount:.2f}")
print(character)
Congratulations! You just completed the Functions Tutorial! To help test your knowledge, let's
practice creating some Functions.
**It's highly recommended that you
complete the exercise outlined in the previous tutorial before beginning this exercise.**
Have any issues with the above exercise? Post your question on Discord!