';如果';python中的语句

';如果';python中的语句,python,Python,我想弄清楚的是如何做一个if语句 a.circle(b*(36-[(if p =3 (p*3), -i*36) 我想要的是,如果p值是3或更大,它会导致圆从36中减去p3,但是如果p不等于3或更大,那么我想让代码说我不希望它从36中减去p 我正在使用我安装并通过终端运行的python3.6。将您的请求从英语翻译为代码: R = 36 # if the P value is three or greater if p >= 3: # it causes the circle t

我想弄清楚的是如何做一个if语句

a.circle(b*(36-[(if p =3 (p*3), -i*36)
我想要的是,如果p值是3或更大,它会导致圆从36中减去p3,但是如果p不等于3或更大,那么我想让代码说我不希望它从36中减去p


我正在使用我安装并通过终端运行的
python3.6

将您的请求从英语翻译为代码:

R = 36

# if the P value is three or greater 
if p >= 3:
    # it causes the circle to subtract p3 from 36 
    R -= p

# but if P is not equal to three or more 
else:
    # then I want for the code to say I do not want it to subtract p from 36.
    pass

a.circle(b * (R, -i * 36))   # attention, i is not defined

如果您想使用Python“传统”,如果:

if condition:
    ...
else:
    ...
一行:

value_if_condition_is_true if condition else value_if_condition_is_false
在您的情况下,您可以尝试:

p*3 if p >=3 else -i*36

我希望这对你有帮助

我没有发布全部代码,只是发布了有问题的孩子。在完整的代码中定义了它。