首页 > 其他 > 详细

作业选择

时间:2017-04-15 15:47:10      阅读:253      评论:0      收藏:0      [点我收藏+]

BMI
height,weight=eval(input("输入身高和体重:"))
bmi=weight/pow(height,2)
print("BMI数值为:{.2f}",format(bmi))
who,dom="",""
if bmi<18.5:
who="偏瘦"
elif bmi<25:
who="正常"
elif bmi<30:
who="偏胖"
else:
who="肥胖"
if bmi<18.5:
dom="偏瘦"
elif bmi<25:
dom="正常"
elif bmi<30:
dom="偏胖"
else:
dom="肥胖"

print("BMI指标为:国际‘{0}’,国内‘{1}’",format(who))

from random import random
from math import sqrt
from time import clock
darts = 10000
hits =0.0
clock()
for i in range(1,darts+1):
x,y = random(),random
dist=sqrt(x * 2+y * 2)
if dist <=1.0:
hits=hits+1
pi=4*(hits/darts)
print("PI值是{}.",format(pi))
print("运行时间是:{:5.5}s",format(clock()))

作业选择

原文:http://www.cnblogs.com/gouxiong/p/6714249.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!