Python第二周作业

inp=input()
l=len(inp)

for i in range(l):
    if ord('A') <=ord(inp[i])<=ord('Z'):
        onew=ord('A')+((ord(inp[i])-ord('A'))+3)%26
    elif ord('a') <=ord(inp[i])<=ord('z'):
        onew=ord('a')+((ord(inp[i])-ord('a')) + 3 )%26
    else:
        onew=ord(inp[i])
    new=chr(onew)
    print(new,end='')
凯撒密码B
str=input("")
left=0
for i in str:
    if i == "(":
        left += 1
    elif i == ")":
        if left > 0:
            left -= 1
        else:
            print("配对不成功")
            break
else:
    if left != 0:
        print("配对不成功")
    else:
        print("配对成功")
括号配对检测
a=eval(input(""))
b=pow((1.0+0.001*a),364)
c=pow((1.0-0.001*a),364)
d=int(b//c)
print("{:.2f}, {:.2f}, {}".format(b,c,d))
天天向上的力量B
N=eval(input())
a=abs(N)
if N<0:
    b=-abs(a+10)
    c=-abs(a-10)
    d=-abs(a*10)
else:
    b=abs(a+10)
    c=abs(a-10)
    d=abs(a*10)
print(a,int(b),int(c),int(d),end="")
同符号数学运算
n=eval(input())

while n!=1 and n!=4:

    num=list(str(n))

    n=0

    for i in num:

        n+=int(i)**2

if n==1:

    print("True")

else:

    print("False")
快乐的数字
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='')
字符串反码A
a=eval(input())
b=eval(input())
print(round(a*b,2))
计算矩形面积
a=eval((input()))
print("{:.3f}".format(a))
格式化输出
s=input()

def str_reverse1(s):

    return s[::-1]

if __name__ == '__main__':

    rs = str_reverse1(s)

    print(rs)
字符串逆序输出
a = int(input()) 
b = 1     
for i in range(1, a+1):  
    b = b*i  
print("{}".format(b)) 
照猫画虎求阶乘

 

posted @ 2020-03-25 07:48  叶落知秋max  阅读(294)  评论(0编辑  收藏  举报