[ad_1]
Facebook –
GitHub –
Google+ –
LinkedIn –
reddit –
Support –
thenewboston –
Twitter –
Python Programming Tutorial – 28 – Default Parameters
by
Tags:
Comments
37 responses to “Python Programming Tutorial – 28 – Default Parameters”
-
why do we add %s ? doesn't Python directly print strings ?
-
in python 3 replace print "%s %s" % (first, last) to print("%s %s" % (first,last))
-
Thanks brother, your tutorials are super helpful
-
Do I write return or print?
-
Ahhh….. It makes so much sense now… Thanks :]
-
lol this comment is still up here from 2 years ago
-
I mean that's why Google uses Python 2.
-
You missed tutorial check out Buckys Python tutorial Strings n Stuff (17/43) %s – It's basically custom string for replacing words
-
Python 3 is kinda buggy. (Thats why Google Python 2)
-
For some weird reason the views start kicking up again at tutorial 32.
-
Is it me or does it sound like bucky has been at the crack again? :/ (jokes)
-
I gonna make to it to the end. Count on it.
We're the true Bucky lovers! -
using % to show we have a string with missing variables.
before the % —- what the string is
after the % —-what the variables are -
whats the %s for ? it was not explained in the earlier tutorials, or maybe i missed it, can someone please explain thanks!
-
name isnt a variable like x which can be given a specific value. Since its a function you gotta go like this: name().
-
you gotta put the brackets (parentheses) in too i think
-
nothing comes when i wirte name?
-
Lots of brackets in later version:
def name(first, last):
print(("%s%s")%(first, last)) -
i spent almost an hour reading forums and this was exactly what i was looking for
-
Bucky, only you can feed minds with unforgettable knowledge.
-
I am using 2.7 and was getting errors before trying your version.Thanks
-
Bucky, I hope you never forget that all the time and effort you put into making these tutorials is sooo worth it. You're a teacher to an audience of knowledge hungry students forever thankful for your contribution. Then, we go out and create. Thank you.
-
if you are using python 3, then the name() function should have this line:
print ('{0} {1}'.format(first, last)) -
I tried to print * in diagonal fashion like this
*
**
***
****but i could'nt do it. the result for my code is print it in each row like :
*
*
*please help me out to do this.
-
In the case of the following, it works in the IDLE but when I try to save it as a .py it returns nothing. What have I missed? Thanks
def name(first,last):
print '%s %s' % (first,last)
name('bucky', 'roberts')print " "
def name(first='tom',last='smith'):
print '%s %s' % (first,last)
print name(first,last) -
The %s is a place holder for variables. So the answer to your question is, yes, but default parameters don't have anything to do with it. In other words, you don't need default params to use them. . .The %s is for strings, ie: words, and you would use %d for numbers.
-
s is coming from string
-
In Python, that's how string type variables are inserted into strings. It's explained in an earlier video in the series, although not quite as it was done in this video.
-
nostalgia kick ;-:
-
Now I'm completely new to Python, but I think I know why. You want the function to print a string, but if you just put print 'first, last', it would return the function as exactly 'first, last'. Using %s allows you to print a string that will change depending on what the value is. It's hard for me to explain, but I hope that helped.
-
Great !
-
I can tell you some of the things i have done already for practice. pm me
-
I need some practice….I start to forget things :(…
-
This tutorial video was kind of confusing. What are tuples?
-
28 tutorials in a day, oh god…
-
I've spent yesterday and today on these… Bucky is awesome, and I never comment on youtube videos. It's three years from when he did this video and I'm being helped. That's crazy.
-
In python 3.2.2
def name(first,last):
print('%s %s'%(first,last))
name('ali','ayşe')
ali ayşe
Leave a Reply