Habiba Akter
Habiba Akter

Reputation: 3

Interpolation value can't be multiplied, show Nonetype

I have a written a interpolation function. but when I called the function, it works perfectly. but when the obtained value is multiplied, it shows TypeError: unsupported operand type(s) for *: 'NoneType' and 'int'

from scipy.interpolate import interp1d

def repair(hour):
    x = [300,600,900,1200,1500,1800,2100,2400,2700,3000,3300,3600,3900,4200,4500,4800,5100,5400,5700,6000]
    y = [0,1,2,4,6,9,12,16,20,25,30,36,42,49,56,64,72,81,90,100]

    x_interip = interp1d(x,y)
    r = x_interip(hour)
    print(r)

p = repair(400)
c = p*100
print(c)

this is my code, I dont know where is wrong. I am a basic learner.

Upvotes: 0

Views: 102

Answers (1)

Ganesh Tata
Ganesh Tata

Reputation: 1195

The error arises because your function does not return anything. Add return r to the end of the function. Otherwise, the value of p will be None and the error arises from multiplying p (which is None, hence the type is NoneType) to 100 (int type).

Upvotes: 1

Related Questions