python的几个小程序,还是作业(笑)

python版本:3.8.5 64-bit
IDE:VScode(别和我说vscode不算IDE)

重量计算

weight=eval(input("请输入体重:"))
earthweight=(weight+0.5*10)
moonweight=earthweight*0.165
print("在地球十年后体重:{:.2f}".format(earthweight))
print("再月球十年后体重:{:.2f}".format(moonweight))

天天向上续1

import math
power = 1.0
for i in range(365):
    if i % 7 in [0,1,2]:
        power = power *1
    else:
        power = power *(1 + 0.01)
print("能力值:{:.2f}".format(power)

天天向上续2.1

import math
power = 1.0
for i in range(365):
    if i % 10 in [0]:
        power = power *1
    else:
        power = power *(1 + 0.01)
print("能力值:{:.2f}".format(power))

天天向上续2.2

import math
power = 1.0
for i in range(365):
    if i % 15 in [0]:
        power = power *1
    else:
        power = power *(1 + 0.01)
print("能力值:{:.2f}".format(power))

回文数判断

s=input("请输入5位数字:")
a=len(s)
i=0
while i<=(a/2):
    if s[i]==s[-(i+1)]:
        count=1             
        i+=1
    else:
        count=0
        break
if count==1:
    print("该数字为回文")
else:
    print("该数字不是回文")

田字格输出

for i in range(1,12):
    if i %5==1:
        print("{0} - - - - {0} - - - - {0}".format("+", "+", "+"))
    else:
        print("{0:10s}{0:10s}{0}".format("|","|","|"))
最后修改:2020 年 09 月 27 日 01 : 23 PM
如果觉得我的文章对你有用,请随意赞赏