0


Python第三周练习:三次方格式化、星号三角形、凯撒密码

三次方格式化:

a = eval(input())
print("{:-^20}".format(pow(a,3)))

星号三角形:

n = eval(input())
for i in range(1,n+1,2):
print("{0:^{1}}".format('*'*i, n))

凯撒密码:

s = input()
t = ""
for c in s:
if 'a' <= c <= 'z':
t += chr( ord('a') + ((ord(c)-ord('a')) + 3 )%26 )
elif 'A' <= c <= 'Z':
t += chr( ord('A') + ((ord(c)-ord('A')) + 3 )%26 )
else:
t += c
print(t)

标签: python

本文转载自: https://blog.csdn.net/qq_50967559/article/details/119001840
版权归原作者 撒子娜 所有, 如有侵权,请联系我们删除。

“Python第三周练习:三次方格式化、星号三角形、凯撒密码”的评论:

还没有评论