Python default arguments are awesome!

8 Views
Published
#python #tutorial #course

00:00:00 default arguments
00:03:16 exercise

# ----- EXAMPLE -----
def net_price(list_price, discount=0, tax=0.05):
return list_price * (1 - discount) * (1 - tax)

# print(net_price(500))
# print(net_price(500, 0.1))
# print(net_price(500, 0.1, 0))

# ----- EXERCISE -----
import time

def count(end, start=0):
for x in range(start, end+1):
print(x)
time.sleep(1)
print("DONE!")

# count(10)
# count(30, 15)
Category
Bro Code
Tags
Python tutorial for beginners, python course
Be the first to comment