GCSE Python programming 10 - Functions & Modules

preview_player
Показать описание
Learn more about subroutines by taking a closer look at functions and procedures.
Рекомендации по теме
Комментарии
Автор

I'm enjoying this quite a lot now, I am setting my self challenges, I managed to create a BMI calculator by myself just from your lessons on subroutines. I wish I had know this channel much before I found it, cause I would have been so well prepared for the test.


# Subroutine(Function)
def Calculate(Weight1, Height2):
BMI =
return BMI

def BMICalc():
Number1 = float(input("Type Your weight: "))
Number2 = float(input("Type Your Height: "))
Answer = Calculate(Number1, Number2)
return Answer

#Main program

y = BMICalc()
print(y)

idontknowwhattonamethish
Автор

I copied the code at 4:55 word for word, but it doesn't work.. it says "UnboundLocalError: local variable 'Num1' referenced before assignment" but the GetInput subroutine is at the top and Add is and the bottom, why is it an error?

modabinomar
Автор

i still dont uderstand the need for def

yahyagondal