Python Programming Tutorial – 27 – Building Functions

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


Posted

in

by

Comments

50 responses to “Python Programming Tutorial – 27 – Building Functions”

  1. Zog Avatar

    How can I get this to work on 2.7.13?

  2. Raptr3x Avatar

    Is it possible while calling the function to put an input so the user can input what he wants for (in this case) x?

  3. Fredri Hej Avatar

    A calculator

    s=—-Your—-Number-
    y=—Your—-Number—
    answer=(s + y)
    print (answer)

  4. Rainer Bode Avatar

    great explanation ,,,

  5. Maxim Chahal Avatar

    dude it's not workin for me I can create a subroutine but it wont let me use it

  6. Muz Khan Avatar

    Thanks a lot man, I'm using Python 3.4 but I got it anyways. Very helpful, good explanation too.

  7. nijal shakya Avatar

    this really helped me out thanks a lot man

  8. Rishi Desai Avatar

    instead of return at the end of the function, why don't you right print instead. 

  9. CA Technologies Avatar

    I think def function would be useful for building quiz, exams site. I defined a function to tell me correct! when I wrote my wife name for the question that says 'who is standing beside me?'. And when I write a different name, to tell me, 'Oops, try again.'

  10. bobjoneswof Avatar

    why wont mine work

        def whatsup(x):
            return "Whats up" + x

    print(whatsup('tony'))

  11. Lukeee Avatar

    mine's not working , im working with python 3.3:

    def whatsup(x):
        return  'whatsup ' + x
        
        
    print whatsup('tony')
    ———————————————————————————————
        print whatsup('tony')
                    ^
    SyntaxError: invalid syntax

    Please help!

  12. ripperx444 Avatar

    Dude you are really helping me out with all these videos ..thanks a lot man

  13. Josefine J Avatar

    I don't know about python 2, but in python 3 you can actually just call your function by entering it's name and press enter… like: function('your x-value') and then press enter

  14. ريم الجابر Avatar

    Python 3+ 
    print ( whatsup ( 'tony' ) )

  15. Phix Phixation Avatar

    Sounds like his neighbours are having a party.

  16. Michael IV Avatar

    Thank you, this helped a lot 🙂

  17. howto Avatar

    first you have to
    >>>def f(y): # press enter
    return y +10 #press enter 2 times
    >>> print f(44) # this will work

  18. William Morera Avatar

    your missing an "x" def whatsup(x)

  19. William Morera Avatar

    x=""
    def whatsup (x):
    x=input ("enter your name: ")
    return "whats up "+ x
    print (whatsup(x))

  20. elegantCommunist Avatar

    >>> def f(y):
    return y+10
    print(f(44))
    Can someone tell me where i'm going wrong here?

  21. tek87 Avatar

    variable = raw_input()
    function(variable)

  22. Devin Sherrer Avatar

    How do I let the user input in my functions?

  23. Devin Sherrer Avatar

    How do I let the user input in my functions?

  24. Parth Parpyani Avatar

    Sorry, I want to edit the 1st line in my comment below, the code is
    def whatsup(x):
    it still doenst work.

  25. Parth Parpyani Avatar

    Why does it work?
    My code:
    def whatsup():
    return ('whats up' + x)
    print (whatsup('tony'))

  26. tomtomjiji Avatar

    Add a colon at the end

  27. joehhhL1771 Avatar

    at 1:20 how did you enter down without making a new line of input(my best way of saying without having the '>>>' at the start of the line) in python shell???

  28. oe spelarn Avatar

    Try this 😛
    def CountTo(count):
    x = 1
    while x <= count:
    print x
    x += 1
    And then you can type in CountTo(So high you want to count!)

  29. Adrian Lopez Avatar

    I actually found out why. I didn't watch the tutorial this time as well as before, and I hit enter only once when I should have hit it twice to end the command.

  30. frederich liu Avatar

    check which version u're working with, if version 3+ ,u may need to use like this:print( here's what he typed after)

  31. Adrian Lopez Avatar

    Why do I keep getting an invalid syntax on "print"?

  32. AlexanderMccarthey87 Avatar

    It's about to get a lot harder.

  33. AlexanderMccarthey87 Avatar

    I don't think there's a better way to learn python. I just wish he would make another one for python3x. People say there's not a lot of difference, but there's still a good amount especially when working with integers and strings.

  34. Sourish Banerjee Avatar

    Actually, for 3.3, use print(whatsup('tony')) cuz print is now a method in python!

  35. Master Ruseman Avatar

    dis python shit is too easy mayne

  36. Eerie Spooks Avatar

    very very helpful thanks so much very funny and informative

  37. TheRicardo9105 Avatar

    hey for 3.3 instead of typing print whatsup('tony') just type whatsup('tony')

  38. Edis Mehmedovic Avatar

    Maybe you're not using the same version .. he is using 2.6

  39. Aaron D'Souza Avatar

    Technically, yes, you are right. But some people, myself included, who are not from the U.S. say brackets (meaning round brackets) as the term for parentheses. So they can be, in fact, the same thing depending on where you come from.

  40. Shams Avatar

    how about having more than one parameter in the function!!

  41. santhosh kumar Avatar

    userdefined functions superb video

  42. Mo7mad Amir Avatar

    file > New Window >
    def whatsup(x):return 'whatsup'+x
    print (whatsup('Tony'))

    save as

    run

  43. Michael Billings Avatar

    That is because you need a comma so its return ("what's up", +x)

  44. ETaroonie Avatar

    just use brackets "return ("what's up" + x) 🙂

Leave a Reply

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