Python Programming Tutorial – 17 – Flexible Number of Arguments

[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –


Posted

in

by

Tags:

Comments

35 responses to “Python Programming Tutorial – 17 – Flexible Number of Arguments”

  1. Viraj Singh Avatar

    I'm a vegetarian and I'm gonna ate tuna.

  2. n2ahii ar01 Avatar

    how could you stay till 3 am weird but seems like albert anstine

  3. Origin Anonymous Avatar

    Can somebody explain to me this again! what are arguments in this context??? I know I sound really dumb sorry

  4. Milind Sonawane Avatar

    If anyone of you is wondering, *args works fine even when different types of arguments are passed within the same function call. For example

    def numbers (*args):
    for arg in args:
    print(arg)

    numbers(1, 2, 3) #case1
    numbers("alpha", "beta", "gamma") #case2
    numbers("one", 2, 3.0) #case3

    The output in this case is
    #case1
    1
    2
    3
    #case2
    alpha
    beta
    gamma
    #case3
    one
    2
    3.0

  5. Ayy Lmao Avatar

    Why += but not only +
    I am talking about this line
    total += a
    This is kinda confusing

  6. But It's The Cotton Hat Avatar

    At 2:56 you used commas, but can't you use + signs, x signs, / signs etc.?

  7. bharadwaj ramaraju Avatar

    def sum(*args):
    total = 0
    for x in args:
    total+=x
    print (total)

    sum(10,20,30,40)

    output :
    10
    30
    60
    100

    why I am getting kind of arithmetic progression. I just need to see total SUM !!

    What's wrong ??!

  8. Sampath pavan kumar Avatar

    isn't the print statement inside for loop?How to identify whether a statement is inside the loop?

  9. Supa Dupa Hilton Avatar

    Ok, so if you set 'for n in range' to 1001, with the 'magic number' value set to 256 (or less) the program works fine. As soon as you increase it to 257 (or more) it immediately fails.  Why??

  10. אליהו פולק Avatar

    What's the matter is about the tuna? (-:
    Awesome channel!

  11. zyx P Avatar

    what does += mean?

  12. Chirag Rathi Avatar

    what is the code for taking input(of adding) from user instead of giving in the code itself

  13. Supa Dupa Hilton Avatar

    I noticed the numeric results change if you take the print statement, and line it up under 'total += a'. …really weird.

  14. borislav todorov Avatar

    3 am tutorials… thank you so much 🙂

  15. Ashwin Jain Avatar

    is args a list or what

  16. Akash Chauhan Avatar

    I have a doubt that in the argument that is *args is a forming a array or a any data storing structure cause you going through that to access the value . so i am a kind of doubt is it a array or something else

  17. M. Ali Akbulut Avatar

    def add_numbers(*args):
    total=0
    for a in args:
    total += a
    return total

    sum=add_numbers(3,30)
    print("result is",sum,)

  18. Sumit Yadav Avatar

    Videos are great, but it would be more helpful if you record video in presentation mode

  19. Mohd Asad Avatar

    I m not able to understand the logic of total like that, could you please explain me ?

  20. Alex King Avatar

    Adding is the easy part, how do I do subtraction??

  21. Danny Morck Jensen Avatar

    Great videos and much appreciated. Humor and perfect lengths. My kind of style Thx 🙂

  22. Nikhil Alex Avatar

    dont u sleep dude? your system time shows 3:45 am????
    "programmers wont sleep right" they just went offline 😛

  23. Szabolcs Sindel Avatar

    Hi,

    can you help me?

    def avarage(*args):

    dividend = 0
    for a in args:
    dividend += a
    divisor = len(args)
    answer = dividend/divisor
    print(answer)
    avarage(int(input))

    i am getting error… if i use avarage(10,20) , i get 15.
    how can i add user input?

  24. Satadhi Halder Avatar

    watching this tutorial exactly at 3:40 AM !!!!:p

  25. Challenged Studios Avatar

    Why does my console go blank sometimes?

  26. Peter Zhao Avatar

    what does "+=" mean ?

  27. Srineesh Salur Avatar

    +thenewboston hey bucky if i type in this code i could add the numbers but the numbers keep pooping in each time i add an anothe number for example if i want to add add 3 and 5 it would show me the output as 3 and 8 pls help me in this regard
    def explaining_arguments(*args):
    car = 0
    for e in args:
    car +=e
    print(car)
    explaining_arguments(3,5)

    output:3
    8

  28. tsikendyoy Avatar

    what if you want to ask the user for what they want to add?

  29. Czif Avatar

    Tuna always RULES 😀

  30. Batman Avatar

    celsius to fahrenheit converter by using args

    def cel_fahr(*cel):
    for x in cel:
    fahr=x*9/5+32
    print(fahr)

  31. CNVideos Avatar

    2:00 You have a giraffe in your house?

  32. C Flux Avatar

    why are my results coming out like this?

    ('Bucky', 'ate', 'tuna')
    ('Sally', 'farts', 'gently')
    ('Bucky', 'is', 'awesome')

    anytime i try to pass the arguements that require me to use a variable, it ends up coming out like this?

    besides that, great tutorials!

  33. peace angel Avatar

    Nice python tutorials thanks a lot.

  34. Yu Liang Avatar

    AM 3:49,you are so cool

Leave a Reply

Your email address will not be published. Required fields are marked *