Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help unwinding assignment
#2
Not surprised that you don't understand it since it doesn't make any sense.

This is True if tNow > 0 and tNow < 2, else it is False
(0.0 < tNow < 2.0)
That result is multipled by Iin which is a float. When multiplying a boolean by a float, True = 1 and False = 0, so this is either Iin or 0.0 depending on the value of tNow.
(0.0 < tNow < 2.0) * Iin
Now for the makes no sense part. 0 * 0 == 0 and 1 * 0 == 0, so this is always zero.
(tNow >= 2.0 or tNow < 0) * 0
Which means these are equivalent:
Iss = (0.0 < tNow < 2.0) * Iin + (tNow >= 2.0 or tNow < 0) * 0
Iss = (0.0 < tNow < 2.0) * Iin
Which I think is easier to understand as:
Iss = Iin if (0.0 < tNow < 2.0) else 0
Reply


Messages In This Thread
Help unwinding assignment - by JamesBrown - Aug-04-2022, 05:38 PM
RE: Help unwinding assignment - by deanhystad - Aug-04-2022, 06:16 PM
RE: Help unwinding assignment - by JamesBrown - Aug-05-2022, 05:10 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020