Feb-27-2019, 06:02 AM
Hello, my class just began functions() and defining them but I'm stuck rn.
When I run this part of code, it yields a "decide" is not defined. I'm not sure what to do as to fix this. Also, I'm confused as to what the parenthesis next to a function should contain, what could and should be added inside the parenthesis?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
def greeting(): print ( "Hello, welcome to the Calculator App" ) def menu(): decide = input ( "1 for Addition, 2 for Subtraction, 3 for Multiplication, 4 for Division" ) def num(): num1 = input ( "Enter first value" ) num2 = input ( "Enter second value" ) def calc(): if decide = = "1" : ans = num1 + num2 print (ans) if decide = = "2" : ans2 = num1 - num2 print (ans2) if decide = = "3" : ans3 = num1 * num2 print (ans3) if decide = = "4" : ans4 = num1 / num2 print (ans4) greeting() menu() num() calc() |