So, here is my script:
#Imports
import decimal
#variables
neweq = "neweq"
on = 1
#loop
while on > 0:
#equasion function
def eq ():
global b
b = input("Please enter an equation (Example: 10*(3*a)==4*(7*a), or 3.0/7.0). Unfortunately however, you can only use the variable 'a'. Also, you can type 'exit' to quit: ")
print ""
print ""
print ""
print ""
b = float(b)
b = '%.3f'%(b)
if (b==exit):
print ""
print ""
print ""
print ""
print ""
print ""
print ""
print ""
exit ("Thank you for using me :)")
#input funcution
def inp ():
a = input("Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: ")
if (a==exit):
print ""
print ""
print ""
print ""
print ""
print ""
print ""
print ""
print ""
exit ("Thank you for using me :)")
if (a == neweq):
print ""
print ""
a = 0
eq ()
inp()
if (b==a):
print ""
print "Yes, the answer is", a
print ""
print ""
eq ()
else:
print ""
print "No, the answer is not", a
print ""
print ""
print "test line", b
inp ()
#function calls
eq()
inp ()
The problem?
Please enter an equation (Example: 10*(3*a)==4*(7*a), or 3.0/7.0). Unfortunately however, you can only use the variable 'a'. Also, you can type 'exit' to quit: 2.0/4.0
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: 1/2
No, the answer is not 0
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: 102.0
No, the answer is not 102.0
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: 1.0/2.0
No, the answer is not 0.5
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: .500
No, the answer is not 0.5
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: 0
No, the answer is not 0
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: 4.0/2.0
No, the answer is not 2.0
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: 2.0/4.0
No, the answer is not 0.5
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion: 0.500
No, the answer is not 0.5
test line 0.500
Enter numeral (Example: 1, or 1.5) to proceed, 'exit' to quit, or 'neweq' to enter a new equasion:
It should be returning 'yes, the answer is 0.5', however, it is not. Same with several other equasions. I can't figure out what is wrong with it, however, my suspicion is that it is the b = '%.3f'%(b)
and that's where I needed help.
Thank you!