-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
  • 303
  • 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,095
  • 3
  • 24
  • 45
0

Use if / else:

return b if t == 0 else c * pow(2, 10 * (t/d - 1)) +b
Paul Evans
  • 26,798
  • 3
  • 34
  • 52
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
  • 40,483
  • 12
  • 109
  • 137
David S.
  • 518
  • 3
  • 5