How to Make (Define) a Function in Python

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024

Комментарии • 16

  • @DataDaft
    @DataDaft  3 года назад +7

    # Define functions with def
    def function_name(function_argument_1, function_argument_2):

    # Function body
    multiplied = function_argument_1 * function_argument_2

    # Return value - What comes out of the function
    return multiplied
    # Call the function on some inputs after it has been defined:
    function_name(5, 10)
    # Set a default function argument value with =
    def combine_strings(word1 = "Hello", word2 = "World", sep = " "):

    return word1 + sep + word2
    combine_strings()
    combine_strings("Data", "Daft", sep = "")
    # Use the output of one function call as input to another:
    combine_strings(combine_strings("Data", "Daft", sep = ""), "Rules!")

  • @scottcuthbert8324
    @scottcuthbert8324 3 месяца назад +1

    That was extremely helpful, I'm currently studying IT and was stuck with this in the textbook, this makes more sense I'll subscribe to your channel as your explanation was well structured.

  • @darth009976
    @darth009976 10 месяцев назад +7

    thanks. I didn't need a guy to read the pages for me tho. I was expecting you would show "how to make a function" instead of reading this document.

  • @worriedaim
    @worriedaim 2 месяца назад +1

    Great explanation, made it much easier to understand!

  • @ryanmanchikanti5265
    @ryanmanchikanti5265 3 года назад +3

    Please make a video on yield I don't understand how it works, would really appreciate it

  • @jojonorris8047
    @jojonorris8047 Месяц назад

    That was a good lesson. 💪🖥️👨‍💻👩‍💻

  • @nontheyet
    @nontheyet 4 месяца назад

    Thank you very much this video helped me. i'll come back to this comment when i get accepted into WTC

  • @sujith4386
    @sujith4386 4 месяца назад

    hi, im new to python, i want to calculate ittrative calculation , using def function..do u have any related video relateed to that

  • @Superstar-nl5tl
    @Superstar-nl5tl 3 месяца назад

    for hello world isn't it easier to just use print ('Hello, World!') ? why use a function to do this?

  • @shaheenshani2016
    @shaheenshani2016 16 дней назад

    nice efforts

  • @connorprance6903
    @connorprance6903 11 месяцев назад

    Thank you!

  • @nourasupercutie9896
    @nourasupercutie9896 8 месяцев назад

    thank you

  • @RealUnamid
    @RealUnamid 7 месяцев назад +1

    nuevo sub