n = eval(input("请输入正整数:"))
print("{:*>15}".format(n))
a = [3,6,9]
b = eval(input()) #例如:[1,2,3]
c = []
for i in range(3):
c.append(a[i]+b[i])
print(c)
import random
random.seed(0)
s = 0
for i in range(5):
n = random.randint(1,97) # 产生随机数
s =s+n**2
print(s)
import turtle
turtle.pensize(2)
d = 0
for i in range(1,9):
turtle.fd(100)
d += 45
turtle.seth(d)
f=open("name.txt")
names=f.readlines()
f.close()
f=open("vote.txt")
votes=f.readlines()
f.close()
f=open("vote1.txt","w")
D={}
NUM=0
for vote in votes:
num = len(vote.split())
if num==1 and vote in names:
D[vote[:-1]]=D.get(vote[:-1],0)+1
NUM+=1
else:
f.write(vote)
f.close()
l=list(D.items())
l.sort(key=lambda s:s[1],reverse=True)
name=l[0][0]
score=l[0][1]
print("有效票数为:{} 当选村长村民为:{},票数为:{}".format(NUM,name,score))
import jieba
f = open('data.txt','r')
lines = f.readlines()
f.close()
f = open('out.txt','w')
for line in lines:
line=line.strip() #删除每行首尾可能出现的空格
wordList = jieba.lcut(line) #用结巴分词,对每行内容进行分词
f.writelines('\n'.join(wordList)) #将分词结果存到文件out.txt中
f.close()
import jieba
f = open('out.txt','r') #以读的方式打开文件
words = f.readlines()
f.close()
D={}
for w in words: #词频统计
D[w[:-1]]=D.get(w[:-1],0) + 1
print("曹操出现次数为:{} ".format(D["曹操"]))