Note that there are some explanatory texts on larger screens.

plurals
  1. POMy first program
    primarykey
    data
    text
    <p>I've been doing a lot lessons on Code Academy, but I get frustrated since some of the compilers reject answers that return the same results. So, I decided to breakaway for a bit and create my own program with the tools that I have learned which is a calculator. It doesn't run correctly. When it is at the menu the if/elif/else statements do not work. The program seems to ignore the input . So, here is my first program code...</p> <pre><code>import math user_choice=("&gt;&gt;") def add(): print "What two numbers would you like to add?" a= int(raw_input(user_choice)) b= int(raw_input(user_choice)) c= a + b print c def sub(): print "What two numbers would you like to subtract?" a=int(raw_input(user_choice)) b=int(raw_input(user_choice)) c=a-b print c def mult(): print "What two numbers would you like to multiply?" a=int(raw_input(user_choice)) b=int(raw_input(user_choice)) c= a*b print c def div(): print "What two numbers would you like to divide?" a=int(raw_input(user_choice)) b=int(raw_input(user_choice)) c=a/b print c def exp(): print "What number would you like to power?" a=int(raw_input(user_choice)) print "By what number would you like it to be powered to?" b=int(raw_input(user_choice)) c= math.pow(a,b) print c def square(): print "What number would you like to square root?" a=int(raw_input(user_choice)) b=math.sqrt(a) print b print "+---------------------------+" print "| Welcome to my basic |" print "| calculator! |" print "| |" print "|What would you like to do? |" print "| |" print "|1: Addition |" print "|2: Subtraction |" print "|3: Multiplication |" print "|4: Division |" print "|5: Exponents |" print "|6: Square Root |" print "|7: Quit |" print "| |" print "+---------------------------+" if int(raw_input(user_choice)) == "1": add() elif int(raw_input(user_choice)) == "2": sub() elif int(raw_input(user_choice)) == "3": mult() elif int(raw_input(user_choice)) == "4": div() elif int(raw_input(user_choice)) == "5": exp() elif int(raw_input(user_choice)) == "6": square() elif int(raw_input(user_choice)) == "7": exit() else: print "Sorry, I didn't understand your entry.Try entering a value 1-7" </code></pre> <p>there is no "if error" code yet, but I am just adamant about getting it to work. All of the functions work. Just can't get the options to work. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload