字符串操作练习:星座、凯撒密码、99乘法表、词频统计预处理

一.九九乘法表
for i in range(1,10,1): for j in range(1,i+1,1): print('%d*%d=%d'%(i,j,i*j),end='\t') print('\n')

  

二.中国GDP输出

a=float(input("please input money:"))
b=input("please input year:")
print("中华人民共和国国内生产总值(GDP){0:,.2f}亿元({1}年)".format(a,b))

 

 三.12星座

for i in range(12):
    print(chr(9800+i),end="/")

  

四.凯撒密码

sr1="abcdefghijklmnopqrstuvwxyz"
sr2=sr1.upper()
sr=sr1+sr1+sr2+sr2
st=input("please input:")
sR=""
for j in st:
    if j==" ":
        sR = sR +" "
        continue
    i=sr.find(j)
    if(i>-1):
        sR=sR+sr[i-3]
print(sR)

 

posted on 2017-09-18 17:11  39-郑选钦  阅读(140)  评论(0)    收藏  举报

导航