๐Ÿ“– Beginning Python Programming /
Module: Defining Functions

Defining functions

๐Ÿ“– Beginning Python Programming / Defining Functions / Defining functions

Function parameters

def percent(x, y=100):
    return x / y * 100

print( percent(3,10))
# 30.0

print( percent(1,3))
# 33.3333333333

print( round(percent(1,3), 2))
# 33.33

print( percent(y=10,x=2))
# 20.0

print( percent(30))
#30.0