Persoal calculator bug

I tried to create a calculator on one of your tasks because I’m on a chromebook and my idea isn’t working can someone tell me the problem

import math

add_total = 0
extra_add_total = 0

print "Welcome to the python claculator"
print """Please enter the number of the operation you want to calculate:

1) Add numbers
2) Subtract numbers
3) Multiply numbers
4) Divide numbers
5) Mixed operations
6) Find the power of a number
7) Find the square root of a number
8) Find the root of a number
9) Turn a number into binary form
10) Turn a binary into number form"""

def reask_question():
   answer = raw_input("Please insert a number between 1-10 only: ")
   if answer == "1":
     addition(add_total, extra_add_total)
   elif answer == 2:
     pass
   elif answer == 3:
     pass
   elif answer == 4:
     pass
   elif answer == 5:
     pass
   elif answer == 6:
     pass
   elif answer == 7:
     pass
   elif answer == 8:
     pass
   elif answer == 9:
     pass
   elif answer == 10:
     pass
   else:
     reask_question()

def ask_question():
  answer = raw_input(": ")
  if answer == "1":
    addition(add_total, extra_add_total)
  elif answer == 2:
    pass
  elif answer == 3:
    pass
  elif answer == 4:
    pass
  elif answer == 5:
    pass
  elif answer == 6:
    pass
  elif answer == 7:
    pass
  elif answer == 8:
    pass
  elif answer == 9:
    pass
  elif answer == 10:
    pass
  else:
    reask_question()
 
def post_operation_ask():
  post_ask = raw_input("Do you want to solve another operation? y/n: ")
  if post_ask == y:
    ask_question(add_total, extra_add_total)
  else:
    print "Thank you for using the python calculator"

def extra_addition(var_1, var_2):
  add_f = raw_input("Please input the extra number, input n if your done: ")
  if add_f == "n":
    print var_1 + var_2
  else:
    extra_addition_antibugger(var_1, add_f)
    extra_addition(var_1, var_2)
def extra_addition_antibugger(var, x):
  var += int(x)

def addition(var_1, var_2):
  add_i = 0
  add_x = raw_input("""Please enter the amount of numbers in your operation: """)
  while add_i < int(add_x):
    add_y = raw_input("please input " + str(add_i + 1) + " number: ")
    var_1 += int(add_y)
    add_i += 1
  add_c = raw_input("Do you want to add more numbers to your operation? y/n: ")
  if add_c == "y":
    extra_addition(var_2, var_1)
  else:
    print var_1
 
ask_question()

If you’re debugging something, the error code and the details of what happened, what you tried and what you expected are useful.

1 Like

there are no errors but it is printing the wrong answer

The calculation itself is wrong? You’ll probably need one or more print statements to break down what is happening inside your function to work out what is or is not happening when it should be.

Looking at your code it appears that there a number of functions which don’t actually use a return statement. Whilst it’s not a requirement to return anything calling these functions from within one another might not work as you expect or you might wind up makingt things harder for yourself than needs be.

3 Likes

thank you, I solved the problem now, I was overthinking