-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
  • 313
  • 1
  • 5
  • 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
  • 12,855
  • 3
  • 27
  • 45
0

Use if / else:

return b if t == 0 else c * pow(2, 10 * (t/d - 1)) +b
Paul Evans
  • 27,315
  • 3
  • 37
  • 54
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
  • 44,105
  • 12
  • 114
  • 143
David S.
  • 518
  • 3
  • 5