# 习题2.1
value = eval(input('请输入温度值(不带单位):'))
unit = input('请输入单位:')
if unit in ['f', 'F']:
c = (value - 32)/1.8
print('转换后的温度是{}C'.format(int(c)))
elif unit in ['c', 'C']:
f = 1.8*value + 32
print('转换后的温度是{}F'.format(int(f)))
else:
print('格式输入错误!')
# 习题3.2
power = 1.0
study = 'y'
unstudy = 'n'
temp = 0
state = 'y'
for i in range(0, 365):
if state == study and (temp in [0,1,2]):
power *= 1
temp = (temp + 1)%7
elif state == study and (temp in [3,4,5,6]):
power *= 1.01
temp = (temp + 1)%7
elif state == unstudy:
temp = 0
else:
pass
print("连续学习365天后能力值为{:.2f}".format(power))
# 习题3.4
a = input()
b = a[::-1]
if a == b:
print("该数字是回文数!")
else:
print("该数字不是回文数!")
python天天向上续。尽管每天坚持,但人的能力发展并不是无限的,它符合特定模型。实例1的修改。改造实例代码1.1。回文数。
最新推荐文章于 2023-03-03 15:18:56 发布