Calculator for finding mass
I’m not going to have a go at the big problem of “equation variable” (which might be better suited to Stack Overflow), but I do have some comments on your existing code:


Python uses the operator ** for powers; i.e., a ** b means “a to the power b”. You can use this to tidy up your constants at the top of the file:

c = 3.00 * 10 ** 8
E = mass * c ** 2


I think that’s easier to read, and makes it clear where they’re coming from.

I see no reason to define a c2 variable, especially when you use it inconsistently (sometimes you have c2, sometimes c * c.

The scipy.constants module contains lots of these constants built-in to high levels of precision, but that may be inappropriate for your work.
At the point when E is defined, the variable mass hasn’t been defined. In fact, I can’t find any mention of the variable in the script. What’s it doing here?
Something only happens if the user types exactly yes or no when asked “Show work?” You might be better off defining a list of “acceptable” responses which means the user wants their work shown.

For example:



yes_list = ['yes', 'y', 'true', 't', 'yep']
if input('Show work?').lower() in yes_list:
    show_input = True
else:
    show_input = False

Most of the code is duplicated: once in the branch of the if statement which shows the working, and again in the branch which doesn’t. You’d be better off defining a working_print function which only prints anything if the user wants it. Further, you can skip defining a show_input variable, and get it directly from the user input:



yes_list = ['yes', 'y', 'true', 't', 'yep']
if input('Show work?').lower() in yes_list:
    def working_print(x):
        print(x)
        return None
else:
    def working_print(x)
        return None


Then you can replace instances of print() which are optional with working_print(). For example, the branch



print('E=mc^2')
print('m=E/c^2')
print('Mass =', energy_val, '/', 'c^2')
print('Mass =', mass_val)


would become



working_print('E=mc^2')
working_print('m=E/c^2')
working_print('Mass =', energy_val, '/', 'c^2')
print('Mass =', mass_val)

You have lots of nested if statements of the form



elif p_val &gt; 0:
    if volume_val &gt; 0:
        # code goes here

elif something_else


I think you’d be better off combining the elif and the if into a single line, e.g. something like



if p_val &gt; 0 and volume_val &gt; 0
if min(p_val, volume_val) &gt; 0


It makes it easier to see what the conditions for each branch are. It also leaves you open to less unexpected bugs if none of the branches get run correctly.

And why p_val instead of density_val?
Add an else block at the end of the code which lets you know when it got there, even if it prints something as silly as “Uh oh, don’t know how I got here.” It makes life easier when debugging – you can tell whether none of your branches ran, or whether one of the branches ran but aren’t printing anything.
In several places, you’re checking that variables are positive where it doesn’t seem appropriate.

For example, consider the F = ma branch. Both force and acceleration are vectors, so it makes sense for them both to be negative (corresponding to force/acceleration in the opposite direction). When computing mass, all you require is that they both have the same sign. So your if statement should become

if force_val * acceleration_val &gt; 0


Velocity is also a vector, so it can be signed, and I see no reason why energy (or several other quantities) have to be non-zero.
There’s a great app called Pythonista for iOS which can edit and run Python scripts. (It doesn’t do Python 3, but your script is sufficiently simple that converting to run on 2.x shouldn’t cause any problems.) I don’t know enough about other platforms to suggest anything else.