Exam Part I
Posted aek971
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Exam Part I相关的知识,希望对你有一定的参考价值。
n=0 for i in range(1,100): if(i%2==1): n=n+1/i else: n=n-1/i print(n)
1
from random import radint RollResult=[] for i in range(100): roll=radint(1,6) RollResult.append(roll) RollFrequecity=[] for j in range(1,6): frequecity=RollResult.count(j) RollFrequecity.append(frequecity) print(frequecity)
2,检测到
ImportError: cannot import name ‘radint‘ from ‘random‘ (d:\\program files (x86)\\py\\lib\\random.py)
而无法显示结果。
from numpy import random sum=0 array=[] random.randint(1,100,size=(3,3))
3
import csv import jieba with open("weather.csv",‘r‘) as f: reader = csv.reader(f) fieldnames = next(reader) words=jieba.lcut counts={} for word in words: if len(word) == 1: continue elif: word = "重度污染" elif: word = "轻度污染" elif: word = "中度污染" elif: word = "优" elif: word = "良" counts[rword] = counts.get(rword,0) + 1 else: del(counts[word]) items = list(counts.items())
以上是关于Exam Part I的主要内容,如果未能解决你的问题,请参考以下文章