# 3.1
earth, moon = 0.0, 0.0
for i in range(1, 11):
earth = earth + 0.5
moon = earth * 0.165
print("未来{:2.0f}年,你在地球上体重增长{:.1f},在月球上体重增长{:.2f}。".format(i, earth, moon))
# 3.2
up = 1.0
for i in range(1, 366):
j = i % 7
if j in [4, 5, 6, 0]:
up = up * (1 + 0.01)
print("连续学习365天后能力值是{:.2f}".format(up))
# 3.3
week, up = 1, 1.0
rest = eval(input("请输入固定多少天休息一天:"))
for i in range(1, 366):
if i % (rest + 1) in [0]:
week = 0
else:
if week in range(4, 8):
up = up * (1 + 0.01)
week = week % 7 + 1
else:
week = week % 7 + 1
print("固定{}天休息一天,365天后的能力值是{:.2f}".format(rest, up))
# 3.4
n = input("请输入5位数字:")
if len(n) == 5:
if n == n[::-1]:
print("这个数字是回文")
else:
print("这个数字不是回文")
else:
print("输入格式错误")
# 3.5
a = '+ '
b = '- '*4
c = '| '
d = ' '*12
for i in range(11):
if i % 5 == 0:
print("{}{}{}{}{}".format(a, b, a, b, a))
else:
print("{}{}{}{}{}".format(c, d, c, d, c))
# 3.6
import time
scale = 3
print("------执行开始------")
for i in range(scale + 1):
a = '·' * i
if i == scale:
b = 'Done!'
else:
b = ''
print("\rstarting {} {}".format(a, b), end='')
time.sleep(0.5)
print("\n------执行结束------")
# 3.7
while True:
for i in ["/", "-", "|", "\\", "|"]:
print("%s\r" % i, end='')
# 3.8
from tqdm import tqdm
from time import sleep
for i in tqdm(range(1, 100)):
sleep(0.01)