#6 - Python Functions
By Ifeanyi Omeata
Published
•1 min read
I
Hi, I am a Software Developer of 3-4 years specialising in React, Javascript, Node, NextJS, Express, Python, Django, Fast API, SQL and a few other technology stack, with a good background in Networking and Cloud Infrastructure. I am working to become a DevOps Solutions Engineer and happily married to my long time girlfriend.
Topics:
1. Functions
2. Functions - Named Notation
3. Functions - Return keyword
1. Functions
>>Return to Menu
A function is a code block that only executes when it is invoked. Parameters are data that can be passed into a function. As a result, a function can return data.
def greeting(name,age=28):
print("Hello " + name + ", you are " + str(age) + "!")
print(f"Hello {name}, you are {age}!")
name = input("Enter your name: ")
greeting(name,35)
greeting("Mary")

2. Functions - Named Notation
>>Return to Menu
def greeting(name, age=28, color="red"):
#Greets user with “name” from “input box” and “age”, if unavailable, default age is used
print(f"Hello {name.capitalize()}, you will be {age+1} next birthday!")
print(f"We hear you like the color {color.lower()}!")
greeting(age=30, name="mike",color="Red")

3. Functions - Return keyword
>>Return to Menu
#No returned value
def value_added_tax_1(amount):
tax = amount * 0.25
total_amount = amount * 1.25
print(value_added_tax_1(100))
#Returned value
def value_added_tax_2(amount):
tax = amount * 0.25
total_amount = amount * 1.25
return tax, total_amount
print(value_added_tax_2(100))

#End
Hope you enjoyed this! :) Follow me for more contents...
Get in Touch:
www.ifeanyiomeata.com
contact@ifeanyiomeata.com
Youtube: https://www.youtube.com/c/IfeanyiOmeata
Linkedin: https://www.linkedin.com/in/omeatai/
Twitter: https://twitter.com/iomeata
Github: https://github.com/omeatai/
Stackoverflow: https://stackoverflow.com/users/2689166/omeatai
Hashnode: https://hashnode.com/@omeatai
Medium: https://medium.com/@omeatai
© 2022






