#月用电量50千瓦时(含50千瓦时)以内的,电价为0.53元/千瓦时;超过50千瓦时的,#超出部分的用电量,电价上调0.05元/千瓦时。#输出格式:#在一行中输出该用户应支付的电费(元),结果保留两位小数,格式如:“cost = 应付电费值”;#若用电量小于0,则输出"Invalid Value!"。
x=int(input())if x <0:print('Invalid Value!')elif x <=50:print('cost = %.2f'%(0.53*x))else:print('cost = %.2f'%(0.53*50+0.58*(x-50)))
n =eval(input())#参考答案if n <0:print("Invalid Value!")elif n <=50:
cost = n *0.53print(f"cost = {cost:.2f}")else:
cost =50*0.53+(n -50)*0.58print(f"cost = {cost:.2f}")
tmp =input()#参考答案if tmp[-1]=='c':
c =eval(tmp[:-1])/2.54print('{:.2f}inch'.format(c))elif tmp[-2:]=='cm':
c =eval(tmp[:-2])/2.54print('{:.2f}inch'.format(c))elif tmp[-1]=='i':
i =eval(tmp[:-1])*2.54print('{:.2f}cm'.format(i))elif tmp[-4:]=='inch':
i =eval(tmp[:-4])*2.54print('{:.2f}cm'.format(i))else:print('输入错误')
8.拍七游戏
x=int(input())#2021/01/25for i inrange(1,x+1):if i %7==0or i %10==7or i //10==7or(i//10)%10==7:print(i)
n =int(input())#参考答案for i inrange(7, n+1):if i %7==0:print(i)else:
stri=str(i)if'7'in stri:print(i)
9.模拟对象移动
for i inrange(1000):
x =input()if x =='e'or x =='E':print("你向东走了一步")elif x =='w'or x =='W':print("你向西走了一步")elif x =='n'or x =='N':print("你向北走了一步")elif x =='s'or x =='S':print("你向南走了一步")elif x =='q'or x =='Q':print("你不想玩了")
exit()else:print("你走错了方向")continue