Python Forum
NameError x not defined
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NameError x not defined
#1
Hello, my class just began functions() and defining them but I'm stuck rn.

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()
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?
Reply


Messages In This Thread
NameError x not defined - by Bruizeh - Feb-27-2019, 06:02 AM
RE: NameError x not defined - by Larz60+ - Feb-27-2019, 06:08 AM
RE: NameError x not defined - by Bruizeh - Feb-27-2019, 06:28 AM
RE: NameError x not defined - by ichabod801 - Feb-27-2019, 06:34 AM
RE: NameError x not defined - by Bruizeh - Feb-27-2019, 06:38 AM
RE: NameError x not defined - by Larz60+ - Feb-27-2019, 10:59 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation NameError: name 'score' is not defined - Help? MrKnd94 13 4,840 Mar-06-2023, 10:54 PM
Last Post: deanhystad
  How to correct the NameError: name 'xx' is not defined? vokoyo 5 11,470 Feb-17-2021, 05:55 AM
Last Post: delonbest
  NameError: name 'os' is not defined, & load_files(sys.argv[1]) AryaIC 3 4,815 Nov-07-2020, 07:45 PM
Last Post: jefsummers
  Error in code NameError: name ' ' is not defined ppman00 11 6,508 Sep-18-2020, 05:22 AM
Last Post: ndc85430
  NameError: name 'print_string' is not defined jamie_01 2 2,106 Jun-11-2020, 05:27 AM
Last Post: buran
  "NameError: name 'catName1' is not defined tofif 3 5,746 Jun-24-2019, 06:05 AM
Last Post: perfringo
  NameError: name 'mailbox_list' is not defined pythonnewb 2 4,814 Aug-06-2017, 09:31 PM
Last Post: pythonnewb

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020