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())