Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X
I am trying to declare a variable based on a conditional, the following code is an idea that illustrates the intention:
import numpy as np
a = 23
b = 54
c = 60
Qs = if a < b:
Qs = 1
elif a < b < c:
Qs = 1.4*a
else:
Qs = 0.69*b
Best regards.
You're not declaring a varibale, but assigning it a value based upon a condition.
Two of many possible implementations:
Success!
Luc
Or, courtesy of Luc Meeks
Fred,
I'm afraid this is not correct. There's an else-if between the first and second condition. In this case, with the given a, b and c, the first two conditions are both true,
but the first must prevail, becasue of the else-if.
The 'return's in my program take care of this else-if. the if() function does it also, but the vector operations don't.
Maybe this mends it:
With that:
you get
and
Luc
Are you sure about the condition a<b ?
Shoudn't it rather be something like b<=a ?