python第二次练习
Str = input("") for i in Str: if ord("a") <= ord(i) <= ord("z"): print(chr(ord("a")+(ord(i)-ord("a")+3)%26),end=‘‘) elif ord("A") <= ord(i) <= ord("Z"): print(chr(ord("A")+(ord(i)-ord("A")+3)%26),end=‘‘) else: print(i, end=‘‘)
Str=input("") a=0 b=0 c=0 for i in Str: if i== ‘(‘: a+=1 elif i== ‘)‘: if a>0: a-=1 else: print("配对不成功") break elif i==‘[‘: b+=1 elif i==‘]‘: c+=1 else: if a!=0: print("配对不成功") elif b!=c: print("配对不成功") else: print("配对成功")
N = eval(input(""))/1000 dayup = pow(1+N,365) daydown = pow(1-N,365) compare = int(dayup/daydown) print("{:.2f},{:.2f},{}".format(dayup,daydown,compare))
n = eval(input()) N = abs(n) a = N + 10 b = N - 10 c = N * 10 if n < 0: a = -abs(a) b = -abs(b) c = -abs(c) else: a = abs(a) b = abs(b) c = abs(c) print(N, a , b, c)
def getSumofSquares(num): numStr=str(num) sum=0 for i in numStr: sum += int(i)**2 return sum def main(): n = input() sumofSqrs = eval(n) while sumofSqrs != 1 and sumofSqrs != 4: sumofSqrs = getSumofSquares(sumofSqrs) else: if sumofSqrs == 1: print("True") else: print("False") main()
n=input() for i in n: if ord("a") <= ord(i) <= ord("z"): print(chr(ord(‘z‘)-(ord(i)-ord(‘a‘))),end=‘‘) elif ord("A") <= ord(i) <= ord("Z"): print(chr(ord(‘Z‘)-(ord(i)-ord(‘A‘))),end=‘‘) else: print(i,end=‘‘)