重量计算。月球上物体的体重是在地球上的16.5%,假如你在地球上每年增长0.5Kg,编写程序输出未来10年你在地球和月球上的体重状况。
w = float(input('你的体重:')) #键盘输入你的体重
for i in range(10): #for循环
w = w + 0.5 #地球上每年增长0.5
moonw = w * 0.165 #月球是地球体重的0.165倍
print("第{}年时,在地球的体重是{:.2f},在月球的体重是{:.2f}"\
.format(i+1,w,moonw)) #print的位置和for是一样的,不然就不算进入循环
current_weight = float(input('当前体重kg:'))
for i in range(1,11):
current_weight += 0.5
moon_weight = current_weight*16.5/100
print('第{:d}年,地球体重{:.2f}kg,月球体重{:.2f}kg'.format(
i,current_weight,moon_weight
))
a = eval(input())
for i in range(1,11):
print("year:{},earth:{},moon:{}".format(i,a,a*0.165))