# ----- *ARGS Example 1 ----- def add(*nums): total = 0 for num in nums: total += num return total print(add(1, 2, 3, 4)) # ----- *ARGS Example 2 ----- def display_name(*args): print(f"Hello", end=" ") for arg in args: print(arg, end=" ") display_name("Dr.", "Spongebob", "Harold", "Squarepants", "III") # ----- **KWARGS ----- def print_address(**kwargs): for value in kwargs.values(): print(value, end=" ") print_address(street="123 Fake St.", pobox="P.O Box 777", city="Detroit", state="MI", zip="54321") # ----- EXERCISE ----- def shipping_label(*args, **kwargs): for arg in args: print(arg, end=" ") print() if "apt" in kwargs: print(f"{kwargs.get('street')} {kwargs.get('apt')}") elif "pobox" in kwargs: print(f"{kwargs.get('street')}") print(f"{kwargs.get('pobox')}") else: print(f"{kwargs.get('street')}") print(f"{kwargs.get('city')}, {kwargs.get('state')} {kwargs.get('zip')}") shipping_label("Dr.", "Spongebob", "Squarepants", street="123 Fake St.", pobox="PO box #1001", city="Detroit", state="MI", zip="54321")
@simeonehdhdyxhxy
Жыл бұрын
yesirr
@gamePlays9699
Жыл бұрын
def add(*args): return type(args) print(add())
@Synceditxboxoffice
Жыл бұрын
brother if you are ethical hacker try to start a series of writing own scripts for CTF
@DeanJohnson-s8x
11 ай бұрын
for the chairty statement.
@gavinjoes.j5830
10 ай бұрын
Thank you bro 😊
@photoshopdepth
Жыл бұрын
It's actually insane how effective you are in teaching these concept.. you're in another league dude. Please keep these coming.
@0e0
9 ай бұрын
truly great
@zabehullahalizadeh2310
Жыл бұрын
Bro please don't stop the playlist of python. Every one of your python videos worth millions.
@nonoobott8602
Жыл бұрын
By far the most explicit video on kwargs and args I've come across. Thanks so much for sharing
@doJLife
Жыл бұрын
the way he keeps it soo simple, understandable and even fun "Dr. Spongebob Harold Squarepants" 😂 i love it.
@oszi7058
Жыл бұрын
NIce actually someone is using their reach just at random to help other ppl! that's so nice!
@emmanuelsharp7031
Жыл бұрын
The way you teach this stuff, even a baby can understand... thanks man. really appreciate
@RainnFTWj
Жыл бұрын
Great video as always, Bro Code. However, using the if statements there seems unnecessary as the get() method has a second parameter that sets a default value if the key doesn't exist. For example: kwargs.get('apt', '') The default value is set as '' here which wouldn't show up as anything in the output.
@juankorsia7909
Жыл бұрын
Amazing explication about it. Right now I undertand it. Thanks a lot!!!
@ken_tx
8 ай бұрын
You made this easy to understand. Probably the best video I’ve seen on this topic. Thank you!
@robertschmidt8624
Жыл бұрын
THANK YOU!! I finally understand *args and **kwargs after at least a year of studying Python. I still have immense respect for my previous instructor, but this video finally gives Me the level of understand I need to write MY own codes. Thank You again.!! Rob
@jankempynck3745
10 ай бұрын
This is the best explanation or *args & **kwargs, that I ever have heard and seen. Congratulations !!!
@chriskeo392
Жыл бұрын
Quick and concise Sniper precision Let's get a Sqlalchemy video. Building models and using existing models etc
@b00i00d
Жыл бұрын
most complete coverage of the subject - thanks!
@MK-vu4qt
9 ай бұрын
What a great explanation! I love you Bro! You're the best. Thank you so much 🙏
@marymary8195
Жыл бұрын
thank you so much for these tutorials!
@chernoboogaloo
5 ай бұрын
Comment for engagement purposes, good video, I really love the channel
@subinkv6849
5 ай бұрын
You are the real coding bro💗
@pankela8883
Жыл бұрын
Thank you so much I really needed this, how did I miss on something this important
@DeejayRobert
9 ай бұрын
The bro man is excellent.
@murfdaddydolla
Жыл бұрын
Insanely good explanation! Thanks bro!
@jasper5016
6 ай бұрын
You are the hope!!
@jcdragneel
Жыл бұрын
Thank you Bro. Taking intro to Scripting right now, every so often the reading material DOES NOT hit the mark for me. Glad you always seem to have something about what I am stuck on, cause I for the life of me could not get what the nonsense the reading material was trying to tell me. Pretty sure I will have to keep coming back to review the video with each prompt I need to code into, but still THank you for the video.
@Cyborgcupine
10 ай бұрын
I paused the video and entered state Michigan, unpaused and two seconds later you did as well :O
@d.h.y
Жыл бұрын
Your video is in totally another class !!!
@송예은-h7b
7 ай бұрын
Thanks! This was a real nice explanation:)
@fredperry492
9 ай бұрын
Awesome thanks
@5coffeebreak2
6 ай бұрын
Thanks, very useful, simple and clear
@datpham2482
10 ай бұрын
I'm here just to check how args and kwargs are pronounced, but I find this lesson awesome ultimately!
@MystikPrae
Жыл бұрын
Lots of love from nepal, bro
@yaekobbonke5704
Жыл бұрын
Easily understood. Thank you sirr
@excelinaccounting8094
4 ай бұрын
Love it❤
@akashcode
Жыл бұрын
Thank you very much bro code. I am from India...❤❤
@WANGLAO-yr8wl
9 ай бұрын
Great Job! Very Clear!
@LupaSeal
Жыл бұрын
Amazing as usual, would be amazing if you can build PHP training course, cannot find a good one to at the level that you teach!
@Aerish369
Жыл бұрын
Thank you
@christianihechi
5 ай бұрын
Thank you!!!
@bekturasanbekov1979
Жыл бұрын
thx 4 vid bro !
@simeonehdhdyxhxy
Жыл бұрын
best coder ever
@zappozzz
10 ай бұрын
You do great videos.
@3minutesbibletruth
Жыл бұрын
Thank you boss for your good work
@mccauleybacalla2228
8 ай бұрын
ththank you so much
@hakim6933
Жыл бұрын
Bro! you're the man!
@Trebrehq
Жыл бұрын
i dont understand how i learned c++ before python and my brains still working
@deadlinedis1949
11 ай бұрын
thanks
@jathebest2835
Жыл бұрын
Thanks, Bro!😎👍
@TorabekRaufov-p8x
11 күн бұрын
bro is the best
@michaelteferi-o6g
9 ай бұрын
Nice video but, i seem that *args are simple in adding but i found it a little bit complex when i write a code for multiplying so if u can show us 1 example in multiply *args please
@happypig8690
9 ай бұрын
def multiply(*factors): product = 1 for factor in factors: product *= factor return product
@someMF_XD
4 ай бұрын
All hail Dr. Spongebob Harold Squarepants III !!
@arushsinghal4490
Жыл бұрын
loved it
@kohukesfr3840
Жыл бұрын
good video :D
@dreddskitv
10 ай бұрын
👍👍👍
@rinrin8455
Жыл бұрын
thank you so much
@kofiramseyarthur4391
Жыл бұрын
Dr. Bro Code III Django series please
@wandersonhelmer1810
Жыл бұрын
I'd love to see a PHP series
@DspycesRecords
Жыл бұрын
Thanks Bro👍👍
@jokeguy5946
Жыл бұрын
Bro is posting faster than speed of light
@jonydude2645
Жыл бұрын
Thank you Bro, u r real Chad
@MarjorieRoseMasilang
3 ай бұрын
♥
@ab123-j7v
Жыл бұрын
you are awesome!
@Samgenkk
Жыл бұрын
Thanks bro
@zabehullahalizadeh2310
Жыл бұрын
You are like the creator of python Bro.
@kenhaley4
10 ай бұрын
At 12:44 a simpler solution would be to just print(f"{kwargs.get('street')} {kwargs.get('apt') or ''}") (That's two single quotes after the word "or"). This would replace 'None' with an empty string, which is what you want.
@dj_arimakousei
2 ай бұрын
print outside outloop isn't add the new line , i can't see it when you execute code
@casualgamer817
Жыл бұрын
LK 1:41 / 14:53 Python *ARGS & **KWARGS are awesome
@DarkSoulGaming7
Жыл бұрын
Ilysm !!!!
@michaeljimenez9203
Жыл бұрын
hi bro code, i love your videos, how many years did it take you to get to the point to where you are at? It is a lot to learn i am a cs student first year thansk for the info
@riddleiddle
6 ай бұрын
I am confused with **kwargs example, are any of those values associated with each other? It seems like they're not key:value pairs, just individual strings
@TB5425-v8q
5 күн бұрын
My "print(add(1,2,3))" only prints the first value one, not the total, what could the problem be??
@phantomf41
Жыл бұрын
Hey bro, can you make a simple code in python that can print out dates in a sequence that skips several days after a specific number an then repeats? Lets say for example print 5 dates in a range a=5(prints 5 numbers or dates) and b=3(skips next 3) so the output dates should print out like 0,1,2,3,4,8,9,10,11,12,16,17,18,19,20. I want to see how you can do this with your simple and detailed explanation.
@yashindian4233
11 ай бұрын
a = 5 # Number of dates to print b = 3 # Number of days to skip after printing # Initialize the current date current_date = 0 # Loop to generate and print the sequence of dates for _ in range(a): print(current_date) # Update the current date to the next date after skipping 'b' days current_date += 1 # Check if we need to skip 'b' days if _ % (a + b) >= a: current_date += b
@xidayoung
10 ай бұрын
As a non-native English speaker: With this first video I saw from you, you convinced me to subscribe to your channel.
@CheatersCalcc
Жыл бұрын
I love you bro:)
@al-cadaalachannel3194
Жыл бұрын
Thanks bro . Where do I get python book?
@ASHLEYZACHARYCTIGLAO
Жыл бұрын
HELLO GUYS CAN YOU MAKE A PROGRAM THAT SHUFFLES EVERY INPUT LETTER OR NUMBER AND OUTPUTS EVERY POSSIBILITY WITHOUT USING ANY RANDOM OR SHUFFLE FUNCTION. (PERMUTATIONS)
@Pawlo370
11 ай бұрын
instead "pass" you can type "..."
@pinaka4492
Жыл бұрын
bro please make a Django series
@ZuRqi
Жыл бұрын
In which playlist can we find them from the beginning?
@Pawlo370
11 ай бұрын
11:20 in python 3.12 we can
@superquran4512
Жыл бұрын
@Bro Code, I have a small program that needs debugging could you kindly help me please? I learnt a lot from your videos but this seems to be a little too much for me to solve. how can i contact you personally please? Thanks in advance buddy :)
@simonvanek3389
Жыл бұрын
git tutorial when?
@saipavan77
Жыл бұрын
Do you like SpongeBob and squarepants literally you put it in every video 😂
@BroCodez
Жыл бұрын
I try and think of characters almost everybody knows of
@saipavan77
Жыл бұрын
@@BroCodez yes thats engaging
@alfonzokgakole8001
Жыл бұрын
Why don't u use vscode
@Marleos
Жыл бұрын
What IDE do you use bro?
@fabioeliasreisritter8827
Жыл бұрын
I think he's using pycharm my dude
@Marleos
Жыл бұрын
@@fabioeliasreisritter8827 Thank you :)
@fabioeliasreisritter8827
Жыл бұрын
@@Marleos You're welcome bro
@tamilrasam3450
Жыл бұрын
pycharm
@j.j.l3758
Жыл бұрын
is there a reason why your python videos don't use the self. keyword? my class uses it and I get confused with it.
@theoriginalneckbeard
4 ай бұрын
May be a bit late, but: in this video he is working with a function, not with a method inside a class. "self" is only used inside classes when you create a method, its a placeholder for the name of the object you create with the help of your class, which serves as a blueprint. A function is a method not bound to a class or an object, a method is a function bound to a class or an object. Its basically the same idea, but the naming varies depending on the context in which the concept is used.
@j.j.l3758
4 ай бұрын
Oh thx 🙏
@casualgamer817
Жыл бұрын
📦
@Runie2607
Жыл бұрын
I've been contributing to a repo recently and in there functions' arguments they have `/` and `*` as follows ``` def function(arg1, arg2, /, *, kwarg1=1, kwarg2=2): pass ``` Can someone explain what `/` and `*` doing in the function arguments??? I've tried googling it but `*args` and `**kwargs` keep popping up
@stonestone9001
Жыл бұрын
Single asterisk as used in function declaration allows variable number of arguments passed from calling environment. Inside the function it behaves as a tuple.
@Runie2607
Жыл бұрын
@@stonestone9001 Do you know what the '/' is doing???
@stonestone9001
Жыл бұрын
@@Runie2607 From what I have known, / means divide. For example: x=(8/4) print(x) result will be 2 cause x=(8/4) =2
Пікірлер: 110