转换C++?python中的条件运算符

转换C++?python中的条件运算符,python,c++,Python,C++,有人能帮我把它转换成python吗?我不知道如何将条件运算符从C++翻译成Python?< /P> Math.easeInExpo = function (t, b, c, d) { return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; 使用if/else: 相当于: if (t == 0) { return b; } else { return c * Math.pow(2, 10 * (t/d - 1)) + b;

有人能帮我把它转换成python吗?我不知道如何将条件运算符从C++翻译成Python?< /P>
Math.easeInExpo = function (t, b, c, d) {
return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b;
使用if/else:

相当于:

if (t == 0)
{
    return b;
}
else
{
    return c * Math.pow(2, 10 * (t/d - 1)) + b;
}
希望这足以让您开始学习。

如果t==0,则返回b,否则返回c*Math.pow2,10*t/d-1+b,基于@frostnational的链接
def easeInExpo( t, b, c, d ):
    return b if t == 0 else c * pow( 2, 10 * (t/d - 1) ) + b
if (t == 0)
{
    return b;
}
else
{
    return c * Math.pow(2, 10 * (t/d - 1)) + b;
}
def easeInExpo( t, b, c, d ):
    return b if t == 0 else c * pow( 2, 10 * (t/d - 1) ) + b