-3

Could any please help me convert this to python? I don't how to translate the conditional operators from C++ into python?

Math.easeInExpo = function (t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
justachap
  • 183
  • 1
  • 4
  • 12

3 Answers3

1
def easeInExpo( t, b, c, d ):
    return b if t == 0 else c * pow( 2, 10 * (t/d - 1) ) + b
wallacer
  • 11,227
  • 3
  • 22
  • 44
0

Use if / else:

return b if t == 0 else c * pow(2, 10 * (t/d - 1)) +b
Paul Evans
  • 26,111
  • 3
  • 30
  • 50
0
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;

is equivalent to:

if (t == 0)
{
    return b;
}
else
{
    return c * Math.pow(2, 10 * (t/d - 1)) + b;
}

Hopefully that's enough to get you started.

vaultah
  • 36,713
  • 12
  • 105
  • 132
David S.
  • 498
  • 3
  • 5