Python keyword arguments are awesome! 🗝️

preview_player
Показать описание
#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)
Рекомендации по теме
Комментарии
Автор

# 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

phone_num = get_phone(country=1, area=123, first=456, last=7890)
print(phone_num)

BroCodez
Автор

thanx to bro code, in just 5 days, I learnt enough of python to top my school in computer science exam in my high school junior year. bro is a blessing from the lord

johnrhodes
Автор

thank you for making these videos! you are helping to so much people.

heal
Автор

Easy and simple explanation, thank you bro!

orazovdidar
Автор

Explanation and examples are way clearer and better than what my Uni Professor gives us! Great Job!

deralkekc
Автор

spongebob squarpants =)))) god, I love his lessons, the best time I had was learning his 12 hour python lessons, I really make the most out of it it took nearly two months. now i just love o hear his voice, cause h e is going into the root of things, the best teacher i have seen in youtube, hands down

xzex
Автор

Bro, thanks to your tutorials I landed a nice job, what the hell? Thanks!

AtamrarisTibia
Автор

Bro you are the best of the best. Thanks a million.

zabehullahalizadeh
Автор

Cool video. Thank you. I also release a video about the development

softwaredeveloperblog
Автор

There is one problem with this program. If your last 4 digits is something like 0123, the zero causes the following syntax error: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers. Has anybody else run into this problem. Hopefully, in future vids this will be brought up. All - in - all, these are very good lessons. Thanks Bro Code for all the efforts you've put into these vids.

hshafe
Автор

Keyword arguments: Preceded by a keyword (the name of the argument at the time of defining the function)
e.g. when something is print(), the default value for that is end="\n" which we can alter by something enclosed in quotes.
Similarly with sep

def greeting(greeting, title, first, last):
return f"{greeting} {title} {first} {last}"
print(greeting("Hello", first="Bro", last="Code", title="Mr."))

Hello Mr. Bro Code


def greeting(greeting, title, first, last):
return f"{greeting} {title} {first} {last}"
print(greeting("Hello", last="Code", title="Mr.", first="Bro"))

Hello Mr. Bro Code


def greeting(greeting, title, first, last):
return f"{greeting} {title} {first} {last}"
print(greeting("Hello", "Mr.", last="Code", first="Bro"))

Hello Mr. Bro Code

abdulhannan-
Автор

Hey bro when will you start uploading react js videos?

zephyrgaming
Автор

I'm still wondering what I can do with Python

mohamedcoufi
Автор

Bro .y school educational system is so messed up that we are using qbasic in school

Just_google_