Python keyword arguments are awesome! 🗝️

#python #tutorial #course 00:00:00 example 1 00:03:20 example 2 00:04:36 exercise 00:06:19 conclusion # keyword arguments = arguments prefixed with the names of parameters # order of the arguments doesn’t matter # helps with readability # ----- EXAMPLE 1 ----- def hello(greeting, title, first, last): print(f“{greeting} {title}{first} {last}“) hello(“Hello“, title=“Mr.“, last=“John“, first=“James“) # ----- EXAMPLE 2 ----- for number in range(1, 11): print(number, end=“ “) print(“1“, “2“, “3“, “4“, “5“, sep=“-“) # ----- EXERCISE ----- def get_phone(country, area, first, last): return f“{country}-{area}-{first}-{last}“ phone_num = get_phone(country=1, area=123, first=456, last=7890) print(phone_num)
Back to Top