• 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)) 
    照猫画虎求阶乘
  • 相关阅读:
    HDU 2842 (递推+矩阵快速幂)
    HDU 2838 (DP+树状数组维护带权排序)
    HDU 2836 (离散化DP+区间优化)
    HDU 2831 (贪心)
    HDU 2818 (矢量并查集)
    HDU 2822 (BFS+优先队列)
    HDU 3090 (贪心)
    HDU 3089 (快速约瑟夫环)
    XCOJ 1103 (LCA+树链最大子段和)
    HDU 3078 (LCA+树链第K大)
  • 原文地址:https://www.cnblogs.com/yeluozhiqiumax/p/12563771.html
Copyright © 2020-2023  润新知