But I'm trying to create this calculator using methods. But there seem to be a problem in the code which i can not grasp..
Could you take a look and see if you find any thing wrong ?
I have basically created the main part of the code, where it returns to start if the user chooses after doing a calculation. I added the if case for every option within the choice at the start.
from math import sqrt
def begin():
print("Welcome to PyCalculus ")
print("1. Addition")
print("2. Substraction")
print("3. Multiplication")
print("4. Division ")
print("5. Square Root")
decide = int(("Choose your type :"))
if decide == 1:
val1 = double(("First value: "))
val2 = double(("Second value: "))
val3 = (val1 + val2)
print ("The total value of " + val1 + val2 + "is " + val3)
elif decide == 2:
print("Coming")
elif decide == 3:
print("Coming")
elif decide == 4:
print("coming")
elif decide == 5:
print("coming")
else :
print ("Wrong value")
startIver()
begin()
def startIver ():
restartPro = input("Do you want to restart the program ? (Y/N)")
if restartPro == "Y":
begin();
else:
print ("Alright then, see you later.")
I hope that you can find what's wrong, cause i can not.. Python is somewhat different from java when it comes to this. Because it would work in java, and show the error if there was one, but it dose not here. Using Netbeans as IDE for both.
Thanks in advance.

New Topic/Question
Reply




MultiQuote





|