[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Python Programming Tutorial – 18 – Unpacking Arguments
by
Tags:
Comments
43 responses to “Python Programming Tutorial – 18 – Unpacking Arguments”
-
BUcky goto sleep its about to 4:00 am 😀
-
data=[10,20]
def calculaHP(age, applesEaten, cigsSmoked=19):
HP=100-age +3.5*applesEaten -2*cigsSmoked
print(HP)
calculaHP(*data)
OUTPUT = 122.0
#You can see it inserts the data nicely and the default is used for cigsSmoked in the lack of the last datum.
#===========================================================data=[10,20,19]
def calculaHP(age, applesEaten, cigsSmoked=5):
HP=100-age +3.5*applesEaten -2*cigsSmoked
print(HP)
calculaHP(*data)
OUTPUT = 122.0
#Still inserts the data nicely, overlapping the default value of cigsSmoked.
#==========================================================data=[10,19]
def calculaHP(age, applesEaten=20, cigsSmoked):
HP=100-age +3.5*applesEaten -2*cigsSmoked
print(HP)
calculaHP(*data)
OUTPUT = SyntaxError: non-default argument follows default argument
#So it doesn't understand that the data are for the non default parameters? -
could you please tell me how have you found these formulas for heath calculator and boys dating age and all?
-
Thanks a lot very informative ….
-
def funkcja (x,y)
wektor = [2,3]
funkcja(*wektor) – wstawiamy listę, która po kolei zapełnia argumenty -
life has no mercy: i died long time ago 🙁
-
I used to smoke a pack ciggarets a day. And now I vape. Very useful information this is.
-
What if there is a mismatch in list size and function argument size ?
-
2:13 I will subscribe for that
-
This was really cool.
-
im gonna live to be 111 years old yay
-
This seriously has to be one of the best python courses. I'm new to learning python and I'm just trying to cover the basics. Out of around 4 different courses I'm taking, this has been the best in explanation. Thanks!
-
I am so confused that shouldn’t the first outcome of “0, 1, 2” be 99.5?help me please
-
Thank you !! Especially for your valuable time. 🙂
-
Wow, you're going to call your viewers idiots for choosing to do something unhealthy? Tell me something that your mother chooses to do that is unhealthy, so that I may call her an idiot too. I'm not a smoker, but you self-righteous non-smokers look so hypocritical when you say narrow-minded comments like that.
-
If you smoke cigarette, you're an idiot! – Bucky Roberts
-
according to this formula my result was: -14
-
Please come back on youtube, we miss you a lot.
-
i use to smoke. still cant stand self righteous non smokers.
-
it needs to be added one more argument named 'sleeping time' since it's 4 am still recording video
-
what if list has too many arguments? ie buckys_data = [1, 2 ,3, 4]
-
Little does he know he is slowly poisoning himself with cyanide… Mwahahahaha!!!
-
Don't cigarettes do more bad than apples do good?
-
quit smoking years ago, best decision ever
-
Any more idiots here or its only me ?
-
The tutorial before this one was about flexible number of arguments passed to a function. We could see there that when we declare a function with * and variable in brackets its possible to have any number of entry values. In this tutorial we see that its possible to pass each item of a list into a function when we call it (also with an *). Is it possible to combine this two things?
Like:
def hc(*args):
total = 0
for a in args:
total += amylist = [1, 2, 3]
hc(*mylist)
-
Considering this was made back in 2014 I doubt this guy will see this, but this has been bothering me for a while now. Why does he write strings with underscores? I thought it was generally accepted that strings should beWrittenLikeThis.
I mean, fuck, what do I know? There's a reason I'm watching HIM give ME tutorials and not the other way around, but I just thought I'd ask.
-
I smoke a lot
-
i smoke weed
-
4 smokers
-
Nice video! Thanks a lot!
-
Instead use round brackets
def sex_calclulator(age,how_many,masturbation):
compiler=(100-age)+(how_many)*3-(masturbation)*1.5
print(compiler)ajay_data=sex_calclulator(21,0,3)
-
I've created a calculator, the user should be able to input any number of input values also the operation e.g. calculate(*args, ''add') . Is it possible!
-
what if we add 4 value in the liste
-
At the very beggining of this series you said best tutorials ever :). So far i haven't learnt how to save my projects or is it even possible to save them as .exe? Can anyone help me?
-
never touch cigarettes in your life guys, i'm tellin ya. it is so hard to stop. i still have problems not smoking when i am out with smokers.
-
20 apples a week keeps the bugs away
-
According to this, my score is 85.5.
-
i have both 2.7 and 3.4 in my system but
my pycharm has python 2.7 in its external libraries,not the 3.4
How can i add 3.4 in it? -
1 Dislike for been too much of a Nerd
-
Aw, thought that asterisk indicated a pointer, well in a way it does, but not in the way I wanted. Btw, I only smoke after sex, oh wait, did you mean cigarettes?
-
I smoke once in a while.
-
1 dislike from a smoker
Leave a Reply