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.

source

#### 26 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. def convert(miles):
km= 0.621*miles
print(km)
convert(2)

3. My Professor thinks he's the real shit in Python by creating videos that are 5 hours long just to explain one concept!!!! Now, this is called a real teaching video!!!! short and informative!!!

4. ching chong my brudda

5. assalamekeloh my brother allah will reward you abundantly!

6. i am struggling to take multiple inputs from the user and using it in a function. Help!

def func_1(x,y):
return 2*x*y

x,y = input("enter values separated by comma").split(",")

print(func_1(x,y))

7. the answer is

def convert(miles):

km = 1.6 * miles

print(km)

8. def convert (miles):
return 1.6 * miles
Km = convert(1)
Print (km)
#just an idea if I got it well!!

9. tried dividing by 0 using this, just got 0 error. lol

10. X = 2*5
Print (x)
Output 10😁

11. Damn my family's overweight

12. circlejerker throat stomper

Ok, I figured out the problem at the end

km1 = 43

km2 = 123

km3 = 230

def convert_miles(miles):

km = miles * 1.6

return km

result1 = convert_miles(km1)

result2 = convert_miles(km2)

result3 = convert_miles(km3)

print(result1)

print(result2)

print(result3)

13. Grammarium Developers

def converter(m):

return 1.6 * m

print(converter(10))

14. Dude, thank you so much! My brain died when the guy from the other tutorial was explaining lol.

15. Quick question: why do we return a function?

This has been suuchh a help! Great support for my college class:) I do believe the level is a little challenging for someone who hasn't ever been in contact with python/other computer programmings..but maybe its just me. Thaaannk-youu!

16. I dont know why it says name1 is not defined any help

17. name = "YG"

weight_kg = 90

height_m = 2

bmi = weight_kg / (height_m ** 2)

print(bmi)

if bmi < 25:

print(name)

print("is NOT overweight")

else:

print(name)

print("is overweight")

name = "YG's sister"

weight_kg = 70

height_m = 1.8

bmi = weight_kg / (height_m ** 2)

print(bmi)

if bmi < 25:

print(name)

print("is NOT overweight")

else:

print(name)

print("is overweight")

name = "YG's brother"

weight_kg = 60

height_m = 2.5

bmi = weight_kg / (height_m ** 2)

print(bmi)

if bmi < 25:

print(name)

print("is NOT overweight")

else:

print(name)

print("is overweight")

18. I'm a Python beginner, so excuse any silly questions. But would I be correct in saying that variables in the brackets in the function are called parameters, whereas when you call the function, the numbers in the brackets are called arguments?

19. When you run print(result1), print(result2), and print(result3), why doesn't it print the bmi information along with the return values?

20. I'm skipping school to learn coding from this guy and i gotta say it's worth it.. this dude is way better than all of my teachers

21. did the exersize in first try yeahhh.

22. can you pls make videos on tkinter & kivy

23. I guess I’m slow to understand it

24. says weight_kg not defined, help

25. This is my code:

# Developer notes:

# The calculator does not allow the input of 'Str' or 'Float'

# This function calculates miles into km

def convert(miles):

km = 1.6 * miles

if miles > 1 or miles < 1:

return str(miles) + ' miles is ' + str(round(km, 2)) + ' km.n'

else:

return str(miles) + ' mile is ' + str(round(km, 2)) + ' km.n'

print('nThe calculator does not accept 'Str' or 'Float'.n')

# Asks for input and prints the results

while True:

km = convert(int(input()))

print(km)