码迷,mamicode.com
首页 > 编程语言 > 详细

python第二次练习

时间:2020-05-01 19:03:40      阅读:60      评论:0      收藏:0      [点我收藏+]

标签:alt   print   eva   orm   put   and   pytho   code   end   

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=‘‘)

技术图片

python第二次练习

标签:alt   print   eva   orm   put   and   pytho   code   end   

原文地址:https://www.cnblogs.com/ssh-4016/p/12813905.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!