import math

print "Select unknown variable"
print "a, b, or c"
print

equation=input("> ")

if equation == a:
	b=input("Enter b: ")
	c=input("Enter c: ")
	a=math.sqrt(c ** 2 - b ** 2)
	print "a= ",a

**i get the following traceback
Traceback (most recent call last):
File "C:\Python27\My Programs\pt.py", line 7, in <module>
equation=input("> ")
File "<string>", line 1, in <module>
NameError: name 'a' is not defined

they say a is not defined but i dont see why i have to if im using "==", and im using python 2.7

>>> equation = 5
>>> if equation == a:
...     print 'something'
...     
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
NameError: name 'a' is not defined
>>> a = 5
>>> if equation == a:
...     print 'something'
...     
something
>>>

Python always read from line-1 line-2... if you not use function/class that has to be called.
So in your code it dos not find a,before you compare(==) equation with a.

i see but this is the direction i want to go with the code, so i cant make equation = to something

import math

print "Select unknown variable"
print "a, b, or c"
print

equation = input("> ")

if equation == a:
	b=int(input("Enter b: "))
	c=int(input("Enter c: "))
	a=math.sqrt(c ** 2 - b ** 2)
	print "a= ",a
if equation == b:
	a=int(input("Enter a: "))
	c=int(input("Enter c: "))
	b=math.sqrt(c ** 2 - a ** 2)
	print "b= ",b
if equation == c:
	a=int(input("Enter a: "))
	b=int(input("Enter b: "))
	c=math.sqrt(a ** 2 + b ** 2)
	print "c= ",c

You should use raw_input, and compare to string value 'a'.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.