[Tutor] TypeError: unsupported operand type(s)

SATYABRATA DATTA iamsatyabrata428 at gmail.com
Sun Mar 22 16:19:04 EDT 2020


The main thing I have to do to take only the meaningful values for my
problem and which are only those which satisfies Delta>=0 (I want to skip
the negative Deltas). How to write that in my code

On Sun, 22 Mar, 2020, 8:40 PM SATYABRATA DATTA, <iamsatyabrata428 at gmail.com>
wrote:

> def x1(ap,dp,ph,e1,e2,e3,e4,e5,y):
>     if Delta(ap,dp,ph,e1,e2,e3,e4,e5,y) >= 0:
>         return 2*(b(ap,dp,ph,e1,e2,e3,e4,e5,y)**3) -
> 9*a*b(ap,dp,ph,e1,e2,e3,e4,e5,y)*c(ap,dp,ph,e1,e2,e3,e4,e5,y) +
> 27*(a**2)*d(ap,dp,ph,e1,e2,e3,e4,e5,y)
>     else:
>         return None
> def y1(ap,dp,ph,e1,e2,e3,e4,e5,y):
>     if Delta(ap,dp,ph,e1,e2,e3,e4,e5,y) >= 0:
>         return 3*np.sqrt(3)*a*np.sqrt(Delta(ap,dp,ph,e1,e2,e3,e4,e5,y))
>     else:
>         return None
>
> This is creating a problem
>
>     return
> np.sqrt(x1(ap,dp,ph,e1,e2,e3,e4,e5,y)**2+y1(ap,dp,ph,e1,e2,e3,e4,e5,y)**2)
> TypeError: unsupported operand type(s) for ** or pow(): 'NoneType' and
> 'int'
>
>
> I think the main problem is due to the condition for Delta>=0 which
> returns a None value for some input dataset but I only need the Delta>=0
> condition values
>


More information about the Tutor mailing list