立即学习:https://edu.csdn.net/course/play/26676/338784?utm_source=blogtoedu
if 语句
if bool条件:
(ture) 等式
else: 下面的代码
if bool 条件:
等式
elif bool 条件:
等式
else :
等式
import random
random.randint(1,10) 随机生成1到10的整数
import random
import math
r=random.randint(1,10)
if r>math.pi:
mj=(float(r)/2)*(float(r)/2)*math.pi
zc=float(r)*math.pi
else :
mj=float(r)**2*math.pi
zc=2*float(r)*math.pi
print ('随机生成的数为:',r)
print('周长为:',zc)
print('面积为', mj)