خرید بک لینک

Vote count: 0

Partially as a school project and partially to help my own understanding, I have been working on a program in python that, given what variables are known and unknown, as well as other contextual clues, can do simple physics calculations using Sympy and math imports.

However, I've run into a problem. I'm currently trying to program the equations for 1 dimensional motion with constant acceleration. There are 4 equations and 5 variables, and in each equation, one of four variables isn't used at all.

The equation in question is Vf^2 = Vo^2 + 2*a*x, where Vf is final velocity, Vo is initial velocity, a is acceleration, and x is displacement. My program can solve the equation, but only if the variable to be solved for is Vf. If I try to solve for any of the other variables, python throws an error: TypeError: can't convert expression to float. I've written a non gui program that did the same thing before and it works. I can't figure out why this doesn't. Code below, sorry if I've made some newbie mistake.

       if unusedvar1dk == 't':
            if solvefor_1dk.get() == 'vfx':
                vfx = solvefor1dk = math.sqrt((vox * vox) + 2 * ax * x)
            elif solvefor_1dk.get() == 'vox':
                vox = Symbol(solvefor_1dk.get())
                vfx = math.sqrt((vox * vox) + 2 * ax * x)
                solvefor1dk = solve(vfx - knownvfx)
            elif solvefor_1dk.get() == 'ax':
                ax = Symbol(solvefor_1dk.get())
                vfx = math.sqrt((vox * vox) + 2 * ax * x)
                solvefor1dk = solve(vfx - knownvfx)
            elif solvefor_1dk.get() == 'x':
                x = Symbol(solvefor_1dk.get())
                vfx = math.sqrt((vox * vox) + 2 * ax * x)
                solvefor1dk = solve(vfx - knownvfx)
        ttk.Label(answerframe, text=solvefor_1dk.get()).grid(row=2, column=1, sticky=W)
        ttk.Label(answerframe, text="=").grid(row=2, column=1)
        ttk.Label(answerframe, text=solvefor1dk).grid(row=2, column=2, sticky=W)

asked 1 min ago

برچسب: نویسنده: استخدام کار تاريخ: دوشنبه 13 ارديبهشت 1395 ساعت: 0:18

صفحه بندی