I am trying to evaluate a formula, np
is numpy
:
Ds = pow(10,5)
D = np.linspace(0, pow(10,6), 100)
alpha=1.44
beta=0.44
A=alpha*(D/Ds)
L=1.65
buf2=L/4.343
buf=pow(-(alpha*[D/Ds]),beta)
value=exp(buf)
and then I will plot this data but I get:
buf=pow(-(alpha*[D/Ds]),beta)
TypeError: can't multiply sequence by non-int of type 'float'
How can I overcome this?
Change:
buf=pow(-(alpha*[D/Ds]),beta)
to:
buf=pow(-(alpha*(D/Ds)),beta)
This:
[D/Ds]
gives you list with one element.
But this:
alpha * (D/Ds)
computes the divisions before the multiplication with alpha
.
You can multiply a list by an integer:
>>> [1] * 4
[1, 1, 1, 1]
but not by a float:
[1] * 4.0
TypeError: can't multiply sequence by non-int of type 'float'
since you cannot have partial elements in a list.
Parenthesis can be used for grouping in the mathematical calculations:
>>> (1 + 2) * 4
12
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With