How To Use Functions In Python (Python Tutorial #3)

33
17

This entire series in a playlist:
Keep in touch on Facebook:
Subscribe to my newsletter:
Support me on Patreon:

Tips:
1. Follow along as I explain to make sure you understand everything
2. Ideally, work with a friend so you can help each other when you’re stuck
3. If you want to learn faster than I talk, I’d recommend 1.25x or 1.5x speed 🙂
4. Check the outline in the comment section below if you want to skip around.
5. Download the sample files here to follow along (they are Jupyter Notebook files):
6. To make sure you don’t miss my future tutorial videos, sign up to my newsletter:
7. Have fun! If anything is unclear, please let me know in a comment.

Keep in touch on Facebook:
Subscribe to my newsletter:
Support me on Patreon:

Source: cuocdoidanghien.com

View More: Cuocdoidanghien Education

33 COMMENTS

  1. Below is an outline of this video.
    0:41: How to use sample files
    1:41: Using comments
    2:21: What’s a function? – Example 1
    4:57: What’s a function? – Example 2
    7:09: A function that takes multiple arguments
    7:58: What’s a function? – 2 more examples
    10:30: Creating a BMI calculator

    Also, a few tips:
    1. Here is the playlist for this series: https://www.youtube.com/watch?v=Z1Yd7upQsXY&list=PLBZBJbE_rGRWeh5mIBhD-hhDwSEDxogDg
    2. Follow along as I explain to make sure you understand everything
    3. Ideally, work with a friend so you can help each other when you’re stuck
    4. If you want to learn faster than I talk, I’d recommend 1.25x or 1.5x speed 🙂
    5. Check the outline in the comment section below if you want to skip around.
    6. Download the sample files here to follow along (they are Jupyter Notebook files): https://www.csdojo.io/python3
    7. To make sure you don’t miss my future tutorial videos, sign up to my newsletter: https://www.csdojo.io/news
    8. Have fun! If anything is unclear, please let me know in a comment.

  2. In the function, headers are called parameters and then calling the functions any value-added will be called arguments. Thank you.

  3. My answer is:
    # Convert miles to km
    def convert(miles):
    km = 1.6 * miles
    print(km)
    .
    .
    If we call the above function:

    km = convert(50)
    Answer: 80.0
    .
    Can this answer be accepted too? Bcoz my answer is different from YK's one…I've downloaded the sample file from his website

  4. mine is simple 😀
    def convert(miles):
    print("miles: ")
    print(miles)
    return 1.6*miles

    km = convert(10)

    print(km)

    boom 16km

  5. I really enjoyed to have taken this course considering my first approach to this language program.
    your explantation are very clear and easy to understand. keep up with your amazing tutorial and looking forward to be a programmer !!!

  6. I wrote the bmi calculator just like you did and checked it over like 1000 times but I still get different results. I inputed the same numbers as you yet still got different bmis can you explain?

  7. # def works for any parameter under the braces and executes the command return for displaying the end value after the parameter  would be enacte by the defined functions

  8. #Equal to sign means assign a value , "def" which is Define , means assigning Commands to a variable, thats the diffrence

  9. Hi, Thames for the great lessons. I follow the examples you are showing on Jupyter but when I run the code it sometimes give me errors although the code is correct (I just recreate what you are teaching on these lessons). When I run it over and over again without changing any code, it passes and gives me the correct output. When I still do not pass through, I simply delete the cells with errors and rewrite them the same to get the output. Isn’t it strange? Do you know about such problem in jupyter?

  10. This is great man, im writing my own functions with ease!!! Did the last KM convert problem in less than 1 min. Really awesome, thanks you

  11. Hi, If we want to create a user define a function for our calculation in which when it calls it takes values from users and on that values they perform calculation and providing the related output??

  12. I'm teaching myself how to code ion python. i'm totally new to this and these are great video's i'm learning allot. thanks allot :))

  13. I made this is this good or is there a better way to do this?

    def percent_off_calculator(original_price, percentage_off):

    overall_percentage = original_price / 100 * ((percentage_off – 100) * -1)

    return overall_percentage

    result1 = percent_off_calculator(original_price1, percentage_off1)

    original_price1 = 350 # Original price of the item.

    percentage_off1 = 99.5 # Discount percentage off of it.

    print(result1) # You have to click Shift + Enter twice to make it work.

    This makes a percentage off calculator for discounts

  14. def convert(miles):

    conversion = 1.6 * miles

    return(conversion)

    distance_km = convert(8)

    print(distance_km)

    got back 12.8

LEAVE A REPLY

Please enter your comment!
Please enter your name here