1

I'm work with Python

it's simple (1.1*x)+(b+(b*0.1))=a this equation is what I want to solve.

I'm so newbie in this world so I having a problem with it

"a" and "b" is come with

int(input('factor a : '))

int(input('factor b : '))

How can I script this to make an calculator

Nuka
  • 11
  • 1
  • 1
    There are many libraries and packages available that can help with this - asking for recommedations is not what StackOverflow is for though. Pick something you think might do the job, try to get it to work and ask about specific problems with that here. – Grismar Aug 01 '22 at 02:03
  • 2
    would you be solving for x? if so, you'll have to restructure the equation so it becomes `x = ....`. then with `a` and `b`, you can find x. – jkr Aug 01 '22 at 02:03
  • Since `(b+(b*0.1))` is equal to `(1.1*b)`, what you have is `x = a/1.1 - b`, which is pretty easy to do. – Tim Roberts Aug 01 '22 at 02:04
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Aug 01 '22 at 08:38

2 Answers2

1

I don't know what values ​​you would set the X to but you would just add the part of the equation and assemble it already in this code.

import math
a = int(input('factor a : '))
b = int(input('factor b : '))

print((b+(b*0.1))/a)
HendrickV9
  • 21
  • 2
1

Depending on the kind of project that you have in mind you can use symbolic mathematics program to gather flexibility. Here an example with sympy and a live shell to test it without installations.

from sympy import symbols, Eq, solve

# declare the symbols
x, a, b = symbols('x a b')

# set up the equation
eq = Eq((1.1*x)+(b+(b*0.1)), a)

# solve it (for hard ones there are several types of solvers)
sol = solve(eq, x)

# fix the free variables
extra_pars = {a.name: input('a:'), b.name: input('b')}

# replace into the expression
new_sol = sol[0].subs(extra_pars)
print(new_sol)
cards
  • 3,936
  • 1
  • 7
  • 25