- 博客(52)
- 收藏
- 关注
原创 实验7:7-5
import matplotlib.pyplot as pltimport numpy as npx=np.arange(-5,6)y=x**4+3*x**3+x**2+4*xyl =4*x**3+9*x**2+2*x+4y2=12*x**2+18*x+2y3=24*x+18plt.subplot(221)plt.plot (x,y, 'r' )plt.subplot (221)plt.plot (x,yl,'b--')plt.subplot (223)plt.plot (x,y2,
2022-05-06 11:28:51 516
原创 实验7:7-4
import matplotlib.pyplot as pltimport numpy as npplt.rcParams['font.sans- serif'] =['SimHei' ]x=np.arange(0,9)y=3*x**2+7*x-9plt .plot(x,y)plt.title('我是图标题' )plt.xlabel( 'x 的取值' )plt.ylabel( 'y 的取值 ')plt.legend( labe ls = '我是图例' ) |plt.text (5,80,
2022-05-06 11:24:22 369
原创 实验7:7-2
import numpy as npx=np.random.rand(5,5)print(x)y=(x-x.min())/(x.max()-x.min())print(y)
2022-05-06 11:02:49 117
原创 实验7:7-1
import numpy as npd=np.array([[1,2,3],[4,5,6],[7,8,9]])print(d)e=d.sum()f=d.mean(axis=1)g=d.mean(axis=0)print(e,f,g)
2022-05-06 10:56:21 456
原创 实验6:6-8
import jiebaf=open("sy6-8.txt","r")words=jieba.lcut(f.read())s_set=set(words) s_dict=dict.fromkeys(s_set,0) for i in s_dict: s_dict[i]=words.count(i)ls_set=set(s_dict.values())s_list=list(ls_set)s_list.sort(reverse=True)con=0for i in ra...
2022-05-06 10:40:25 131
原创 实验6:6-7
if __name__=="__main__": f=open("sy6-7.txt","r") st=f.readlines() dic=dict() for i in st: inf=i.split(",") dic.update({inf[0]:inf[1]}) while True: st=input("请输入你要查询的人(如果不查询请输入stop):") if(st=='stop'):...
2022-05-06 10:39:35 98
原创 实验6:六-6
f=open('sy6-6.txt','r')dic={}a=f.readlines()for i in a: b=i[:-1].split(' ') c=[eval(x) for x in b[1:]] dic[b[0]]=round((sum(c)-max(c)-min(c))/(len(c)-2),2)items=list(dic.items())items.sort(key=lambda x:x[1],reverse=True)for i in range(6):...
2022-05-06 10:38:31 127
原创 实验6:6-5
f=open('sy6-5.txt','w')n=0for i in range(20): for j in range(0,2): n+=1 if n%5==0: f.write(str(i)+'\n') else: f.write(str(i)+' ')f.close()
2022-05-06 10:36:41 113
原创 实验6:6-4
f=open('sy6-4.txt','w')n=0for i in range(2,100): for j in range(2,i): if i%j==0: break else: n=n+1 f.write(str(i))f.close()
2022-04-26 11:02:37 217
原创 实验6:6-3
f=open('sy6-3.txt','r')a=f.readlines()y=0s=0w=0for i in a: b=i.split(',') y=y+int(b[1]) s=s+int(b[2]) w=w+int(b[3])print((y/5),(s/5),(w/5))f.close()
2022-04-26 10:45:22 255
原创 实验6:6-2
f=open('sy6-2.txt','r')a=f.read()b=a.split(',')for i in range(len(b)): b[i]=int(b[i])c=max(b)d=min(b)print(c,d)f.close()
2022-04-26 10:35:03 238
原创 实验5:5-9
def oddsum(n): m=n*n*n lst=[] for x in range(1,m+1,2): lst.append(x) i=0 while i<len(lst): s=sum(lst[i:i+n]) if s==m: return lst[i:i+n] i=i+1 return[]n=int(input('请输入任意一个正整数:'))nli...
2022-04-22 10:42:22 66
原创 实验5:5-8
def isSymmetrical(x): for i in range(4): for j in range(4): if x[i][j]!=x[i][j]: return False else: return Truedef prime(x): if x<2: return False else: for i in range(2...
2022-04-22 10:17:57 100
原创 实验5:5-7
def fib(n): if n==1 or n==2: return 1 elif n==0: return 0 else: return fib(n-2)+fib(n-1)n=int(input())print(fib(n))
2022-04-19 11:52:29 103
原创 实验5:5-6
def prime(m): for i in range(2,m): if m%i==0: return False return Trues=0for i in range(4,1001,2): for j in range(2,i//2+1): if prime(j) and prime(i-j): print('{}={}+{}'.format(i,j,i-j),end=' ')...
2022-04-19 11:46:18 91
原创 实验5:5-5
def count_num(s): d={} lst=s.split() for c in lst: if c not in d: d[c]=1 else: d[c]=d[c]+1 return ds1='Python VB VFP C C++ Java Python Java Python C'dd=count_num(s1)d1=sorted(dd.keys())print('Or...
2022-04-19 11:28:56 1325
原创 实验5:5-4
def add_dic(): a=input('please input an English word:') b=input('please input the Chinese meaning:') mydict[a]=b def search_dic(): a=input('please input the word you want to look for:') print(mydict.get(a)) def main(): whi...
2022-04-19 11:08:47 180
原创 实验5:5-3
def g(x): a=sorted(list(x),reverse=True) b='' b=b.join(a) return bm=input('请输入一个正整数:')n=g(m)print(n)
2022-04-19 11:04:32 77
原创 实验5:5-2
def n(x,y): r=x%y while r!=0: x=y y=r r=x%y if y==1: return print('互质') else: return print('不互质')import randoma=random.randint(1,100)b=random.randint(1,100)print(a,b)n(a,b)...
2022-04-19 10:48:12 69
原创 实验5:5-1
def a(x): if x%2==1: return True else: return Falseif __name__=='__main__': n=int(input()) a(n)if a(n)==True: print('奇数')else: print('偶数')
2022-04-16 11:22:53 138
原创 实验4:4-14
from datetime import datetimea=datetime.now()print(a.strftime('%Y-%m-%d %H%M%S'))print(a.strftime('%Hh%Mm%Ss %b.%d.%Y'))print(a.strftime('%Y年%m月%d日 %H点%M分%S秒'))m=a.monthprint(m)if m<=3: print('第一季度')elif m<=6: print('第二季度')elif ...
2022-04-12 11:29:33 154
原创 实验4:4-13
a={'wzs','wzx','wzc'}b={'zyx','wzs','zyv'}c={'xjp','zyx','wzs'}d=((a&b)|(a&c)|(b&c))e=(a&b&c)print(d-e)
2022-04-12 11:16:41 57
原创 实验4:4-12
a={1,2,3,4,5,6,7,8}b={1,2,3,4}c={5,6,7,8}e={4,7,8,1,2,2,6,2,2,1,6,8,7,4,5,5,5,8,5,5,5,4,2,2,6,4}print(e)print(e&b)print(c-(b|e))u=str(e)i=input("请输入候选人编号:")if i in u: print('该候选人获得选票')else: print('该候选人没有获得选票')...
2022-04-12 11:07:36 194
原创 实验4:4-11
a={'pscores.py','cscores.py','vbscores.py','vfpscores.py','c++scores.py'}b={'pscores.py','dbscores.py','osscores.py','c++scores.py','netscores.py'}print(a-b)print(a&b)print(a^b)print(a|b)
2022-04-12 10:32:54 189
原创 实验四:4-10
a={'Han':65,'Wang':97,'Ma':73,'Xu':85,'Yang':92}b=sorted(zip(a.values(),a.keys()))b.reverse()for i in range (len(b)): print(b[i][1])
2022-04-09 12:05:40 39
原创 实验4:4-8
monthdays={'Jan':31,'Feb':28,'Mar':31,'Apr':30,'May':31,'Jun':30,'Jul':31,'Aug':31,'Sep':30,'Oct':31,'Nov':30,'Dec':31}print(monthdays.keys())print(monthdays.values())print(monthdays.items())print(monthdays['May'])monthdays['Feb']=29print(monthdays)
2022-04-09 11:16:03 48
原创 实验四:4-7
a={'北京':100000,'天津':300000,'重庆':401400,'济南':210000,'南京':710000,'西安':210000,'郑州':450000,'长沙':410000,'武汉':430000}b=input("请输入城市名称:")print(a.get(b))
2022-04-09 10:57:37 69
原创 实验4:4-6
a=input("请输入一段英文字母串:")alist=list(a)while len(alist)>0: b=max(alist) alist.remove(b) print(b,end=" ")
2022-04-09 10:47:38 47
原创 实验4:4-5
list1=[0,10,20,30,40,50,60,70,80,90,100]list2=[]list3=[]for i in (list1): if i<60: list2.append(i) if i>=90: list3.append(i)ave2=sum(list2)/len(list2)ave3=sum(list3)/len(list3)print("不及格学生平均分:",ave2)print("优秀学生平均分:",ave...
2022-04-01 12:08:34 40
原创 实验4:4-4
list1=[95,94,98,99,91,95,97,96,92,93]a=sum(list1)b=min(list1)c=max(list1)ave=(a-b-c)/(len(list1)-2)print(ave)
2022-04-01 11:53:46 45
原创 实验4:4-3
x=(input("请输入参加演出的学生姓名:").split(","))list1=list(x)list1.insert(0,'Actors')y=(input("请输入一个学生名字:"))r=list1.index(y)print(r)
2022-04-01 11:44:22 55
原创 实验4:4-2
import randomastr='qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890'for i in range(10): c=random.sample(astr,8) print(c)
2022-04-01 10:54:55 207
原创 实验四:4-1
a=eval(input("请输入一段英文字符串:"))b=eval(input("请输入一个字母:"))c=a.lower()d=c.count(b.lower())print(d)
2022-04-01 10:30:17 59
原创 18十汇顶科技爱就爱上
i=1s=100x=50while i<10: i+=1 s+=2*x x/=2print("第十次落地时共经过{}米,第十次反弹{}米".format(s,x))
2022-03-29 11:13:24 299
原创 实验三:3-17
x=eval(input("输入任意的实数:"))n=1a=xsum=1+xwhile a>1e-6: n=n+1 a=a*x/n sum=sum+aprint(sum)
2022-03-29 11:07:00 254
原创 实验3:3-17
a=eval(input("输入任意的实数a(a>=0):"))x0=awhile True: x1=(x0+a/x0)/2 if abs(x1-x0)<0.000001: print("a的开平方为{}".format(x1,".6f")) break x0=x1
2022-03-25 11:36:24 56
原创 实验3:3-15
f1=1f2=2f3=3sum=0while True: f4=f1+f2+f3 f1=f2 f2=f3 f3=f4 sum=sum+1 if f4>=2000: print(sum) break
2022-03-25 11:12:18 47
原创 实验3:3-14
for x in range(0,20): y=19-x if x*2+y*4==44: print("鸡有{}只 兔有{}只".format(x,y))
2022-03-25 10:57:05 39
原创 实验3:3-13
for A in range(1,10): for B in range(0,10): for C in range(0,10): for D in range(0,10): if (A*1000+B*100+C*10+D)-(C*100+D*10+C)==(A*100+B*10+C): print(A,B,C,D,)
2022-03-25 10:44:37 45
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人