Python TypeError: unsupported operand type(s) for ^: 'float' and 'int'


I wrote a simple program which approximates the evaluation of a definite integral using numerical integration. However, I am stumped when it comes to why I am getting the error in the title. Keep in mind that I haven’t touched python in one and a half years so it might be something incredibly obvious that I’m missing, however I’d still be grateful if you could help me 🙂 Here is the code:

import math
def f(x):
    return f

lbound=int(input("Input lower bound for the integral"))
ubound=int(input("Input upper bound for the integral"))
n=int(input("Input number of intervals"))
for i in range(1,n):

print (integral)

Here is the full error report IDLE gives me when trying to run the code:

Traceback (most recent call last):
  File "C:Users******", line 13, in <module>
  File "C:Users******", line 3, in f
TypeError: unsupported operand type(s) for ^: 'float' and 'int'
Asked By: Aris Pap



Python’s exponentiation operator is **, not ^. ^ is bitwise XOR.

Answered By: ilyas patanam
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.