It is a program that calculates a continuous uniform distribution. So for example I enter x^2, with a = 0, b = 1. The program would evaluate x^2 from 0 to 1. The coefficient 1/(b-a) is part of the rules of a continuous uniform distribution.
formula = input(
"What is the formula? Use x for variables.")
a = input("What is the value of a?")
b = input("What is the value of b?")
formula = formula.replace("^", "**")
coefficient = 1 / (float(b) - float(a))
coefficient = float(coefficient)
ans,err = quad(formula, a, b)
print(ans * coefficient)
It is telling me that it can't convert the formula from a string to a float. The problem is that the formula string has the variable 'x' in it. So even if I do float(formula) it gives me an error that it can't convert from string to float. Is there any way around this?