# 习题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("该数字不是回文数!")
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
文章由极客之音整理,本文链接:https://www.bmabk.com/index.php/post/84797.html