python學習實例(4)

#=========================================
#第四章的python程序
#=========================================#=========================================
#4.1 簡潔的Python
#=========================================#<程序:Python數組各元素加1>
arr = [0,1,2,3,4]
for e in arr:tmp=e+1print (tmp)#==================================================================================================#=========================================
#4.2 Python內置數據結構
#=========================================#+++++++++++++++++++++++++++++++++++++++++
#4.2.1 Python基本數據類型
#+++++++++++++++++++++++++++++++++++++++++#<程序:產生10-20的隨機浮點數>
import random
f = random.uniform(10,20)
print(f)#<程序:產生10-20的隨機整數>
import random
i = random.randint(10,20)
print(i)#<程序:布爾類型例子>
b = 100<101
print (b)#+++++++++++++++++++++++++++++++++++++++++
#4.2.2 列表(list)
#+++++++++++++++++++++++++++++++++++++++++#<程序:序列索引>
L=[1,1.3,"2","China",["I","am","another","list"]]
print(L[0])#<程序:序列加法>
L1= [1,1.3]
L2= ["2","China",["I","am","another","list"]]
L = L1 +L2
print(L)#<程序:字符串專用方法調用>
L=[1,1.3,"2","China",["I","am","another","list"]]
L.append("Hello world!")
print(L)#<程序:while循環對列表進行遍歷>
L = [1,3,5,7,9,11]
mlen = len(L)
i =0
while(i<mlen):print(L[i]+1)i += 1#<程序:for循環對列表進行遍歷>
L = [1,3,5,7,9,11]
for e in L:e+=1print(e)#+++++++++++++++++++++++++++++++++++++++++
#4.2.3 再談字符串
#+++++++++++++++++++++++++++++++++++++++++#第一種方式
S=input("1. Enter 1,2, , , :")#Enter: 1,2,3,4
L = S.split(sep=',')		#['1','2','3','4']
X=[]
for a in L:X.append(int(a))
print("Use split:", X)#第二種方式
S=input("2. Enter 1,2, , , :")#Enter: 1,2,3,4
L = S.split(sep=',')			#['1','2','3','4']
L= [int(e) for e in L]
print("Use split and embedded for:", L)#+++++++++++++++++++++++++++++++++++++++++
#4.2.4 字典(Dictionary)——類似數據庫的結構
#+++++++++++++++++++++++++++++++++++++++++#<程序:統計字符串中各字符出現次數>
mstr = "Hello world, I am using Python to program, it is very easy to implement."
mlist = list(mstr)
mdict = {}
for e in mlist:if mdict.get(e,-1)==-1:	#還沒出現過mdict[e]=1else:					#出現過mdict[e]+=1
for key,value in mdict.items():print (key,value)#練習題4.2.13#程序1
d_info1={'XiaoMing':[ 'stu','606866'],'AZhen':[ 'TA','609980']}
print(d_info1['XiaoMing'])
print(d_info1['XiaoMing'][1])#程序2
d_info2={'XiaoMing':{ 'role': 'stu','phone':'606866'},
'AZhen':{ 'role': 'TA','phone':'609980'}}
print(d_info2['XiaoMing'])
print(d_info2['XiaoMing']['phone'])#練習題4.2.14#程序1
di={'fruit':['apple','banana']}
di['fruit'].append('orange')
print(di)#程序2
D={'name':'Python','price':40}
D['price']=70
print(D)
del D['price']
print(D)#程序3
D={'name':'Python','price':40}
print(D.pop('price'))
print(D)#程序4
D={'name':'Python','price':40}
D1={'author':'Dr.Li'}
D.update(D1)
print(D)#==================================================================================================#=========================================
#4.3 Python賦值語句
#=========================================#+++++++++++++++++++++++++++++++++++++++++
#4.3.1 基本賦值語句
#+++++++++++++++++++++++++++++++++++++++++#<程序:基本賦值語句>
x=1; y=2
k=x+y
print(k)#+++++++++++++++++++++++++++++++++++++++++
#4.3.2 序列賦值
#+++++++++++++++++++++++++++++++++++++++++#<程序:序列賦值語句>
a,b=4,5
print(a,b)
a,b=(6,7)
print(a,b)
a,b="AB"
print(a,b)
((a,b),c)=('AB','CD') #嵌套序列賦值
print(a,b,c)#+++++++++++++++++++++++++++++++++++++++++
#4.3.3 擴展序列賦值
#+++++++++++++++++++++++++++++++++++++++++#<程序:擴展序列賦值語句>
i,*j=range(3)
print(i,j)#+++++++++++++++++++++++++++++++++++++++++
#4.3.4 多目標賦值
#+++++++++++++++++++++++++++++++++++++++++#<程序:多目標賦值語句1>
i=j=k=3
print(i,j,k)
i=i+2 #改變i的值,并不會影響到j, k
print(i,j,k)#<程序:多目標賦值語句2>
i=j=[] 	#[]表示空的列表,定義i和j都是空列表,i和j指向同一個空的列表地址
i.append(30)  #向列表i中添加一個元素30,列表j也受到影響
print(i,j)
i=[];j=[]
i.append(30)
print(i,j)#+++++++++++++++++++++++++++++++++++++++++
#4.3.5 增強賦值語句
#+++++++++++++++++++++++++++++++++++++++++#<程序:增強賦值語句1>
i=2
i*=3       #等價于i=i*3
print(i)#<程序:增強賦值語句2>
L=[1,2]; L1=L; L+=[4,5]
print(L,L1)#<程序:增強賦值語句3>
L=[1,2]; L1=L; L=L+[4,5]
print(L,L1)#==================================================================================================#=========================================
#4.4 Python控制結構
#=========================================#+++++++++++++++++++++++++++++++++++++++++
#4.4.1 if語句
#+++++++++++++++++++++++++++++++++++++++++#<程序:if語句實現百分制轉等級制>
def if_test(score):if(score>=90):print('Excellent')elif(score>=80):print('Very Good')elif(score>=70):print('Good')elif(score>=60):print('Pass')else:print('Fail')
if_test(88)#<程序:if語句舉例—擴展>
def if_test(score):if(score>=90):print('Excellent',end=' ')if(score>=95):print('*')else:print(' ')
if_test(98)#+++++++++++++++++++++++++++++++++++++++++
#4.4.2 While循環語句
#+++++++++++++++++++++++++++++++++++++++++#<程序:while循環實現從大到小輸出2*x,0<x<=10 >
x=10
while x>0:print(2*x,end=' ')x=x-1#<程序:while循環實現從大到小輸出2*x,x不是3的倍數>
x=10
while x>0:if x%3 == 0:x=x-1continueprint(2*x,end=' ')x=x-1#<程序:while循環實現從大到小輸出2*x,x第一次為6的倍數時退出循環>
x=10
while x>0:if x%6 == 0:breakprint(2*x,end=' ')x=x-1#<程序:while循環例子1改進>
i = 1
while True:print(i,'printing')if i==2:breaki=i+1#<程序:判斷是否為質數>
b=7
a=b//2
while a>1:if b%a==0:print('b is not prime')breaka=a-1
else:    #沒有執行break,則執行elseprint('b is prime')#+++++++++++++++++++++++++++++++++++++++++
#4.4.3 for循環語句
#+++++++++++++++++++++++++++++++++++++++++#<程序:for的目標<target>變量>
i=1
m=[1,2,3,4,5]
def func():x=200for x in m:print(x);print(x);
func ()#<程序:while循環改變列表2>
words=['cat','window', 'defenestrate']
for w in words[:]:if len(w)>6:words.append(w)
print(words)#<程序:使用range遍歷列表>
L=['Python','is','strong']
for i in range(len(L)):print(i,L[i],end=' ')#==================================================================================================#=========================================
#4.5 Python函數調用
#=========================================#+++++++++++++++++++++++++++++++++++++++++
#4.5.1 列表做參數
#+++++++++++++++++++++++++++++++++++++++++#<程序:列表的append方法>
def func(L1):L1.append(1)
L=[2]
func(L)
print(L)#<程序:加法(+)合并列表>
def func(L1):x=L1+[1]print(x,L1)
L=[2]
func(L)
print (L)#<程序:列表分片的例子>
def func(L1):x=L1[1:3]print(x,L1)
L=[2,'a',3,'b',4]
func(L)
print(L)#<程序: L=X>
def F0():X=[9,9]   #X是局部變量,這個指針在局部棧上,但是[9,9]在外面heap上。L.append(8)    #L是全局變量
X=[1,2,3]
L=X
F0()
print("X=",X,"L=",L)#<程序: L=X[:]>
def F0():X=[9,9]   #X 這個指針在局部棧上,但是[9,9]在外面heap上。L.append(8)   #L是全局變量
X=[1,2,3]; L=X[:]		#L是X的全新拷貝
F0()		#改變L不會改變X
print("X=",X,"L=",L)#<程序: 返回(return)列表>
def F1():L=[3,2,1]	#L是局部變量,而[3,2,1]內容是在棧的外面,heap上return(L)   # 傳回指針指到[3,2,1]。這個[3,2,1]內容不會隨F1結束而消失。
L=F1()
print("L=",L)#<程序: L做函數參數傳遞>
def F2(L):		#參數L是個指針,是存在棧上的局部變量L=[2,1]		#L 指向一個全新的內容,和原來的參數L完全分開了。return(L)
def F3(L):		#參數L是個指針,是存在棧上的局部變量L.append(1)    #L 指向的是原來的全局內容。會改變全局LL[0]=0
L= [3, 2, 1]
L=F2(L);print("L=",L)
F3(L);print("L=",L)#<程序: list為參數的遞歸函數>
def recursive(L): if L ==[]: return L=L[0:len(L)-1]   # L指向新產生的一個list,和原來的List完全脫鉤了print("L=",L) recursive(L) print("L:",L) return 
X=[1,2,3] 
recursive(X) 
print("outside  recursive, X=",X)#練習題4.5.2def recursive_2(L): if L ==[]: return print("L=",L) recursive_2(L[0:len(L)-1]) print("L:",L) return 
X=[1,2,3] 
recursive_2(X) 
print("outside  recursive_2, X=",X)#==================================================================================================#=========================================
#4.6 Python自定義數據結構
#=========================================#+++++++++++++++++++++++++++++++++++++++++
#4.6.2 面向對象基本概念——類(Class)與對象(Object)
#+++++++++++++++++++++++++++++++++++++++++#<程序:自定義學生student類,并將該類實例化>
class student:	 #學生類型:包含成員變量和成員函數def __init__ (self,mname,mnumber):#當新對象object產生時所自動執行的函數self.name = mname				#self代表這個object。名字self.number = mnumber			#ID號碼self.Course_Grade = {}			#字典存課程和其分數self.GPA = 0					#平均分數def getInfo(self):print(self.name,self.number)
XiaoMing = student("XiaoMing","1")		
#每一個學生是一個object,參數給__init()__
A_Zhen = student("A_Zhen","2")
XiaoMing.getInfo()
A_Zhen.getInfo()#==================================================================================================#=========================================
#4.7 基于Python面向對象編程實現數據庫功能
#=========================================#+++++++++++++++++++++++++++++++++++++++++
#4.7.1 Python面向對象方式實現數據庫的學生類
#+++++++++++++++++++++++++++++++++++++++++#<程序:擴展后的Student類>
class student:def __init__ (self,mname,studentID):self.name = mname; self.StuID = studentID;	self.Course_Grade = {};self.Course_ID = []; self.GPA = 0;	self.Credit = 0def selectCourse(self,CourseName,CourseID):self.Course_Grade[CourseID]=0;			#CourseID:0 加入字典self.Course_ID.append(CourseID)			# CourseID 加入列表self.Credit = self.Credit+ CourseDict[CourseID].Credit #總學分數更新def getInfo(self):print("Name:",self.name);print("StudentID",self.StuID);print("Course:")for courseID,grade in self.Course_Grade.items():print(CourseDict[courseID].courseName,grade)print("GPA",self.GPA); 	print("Credit",self.Credit); print("")def TakeExam(self, CourseID):self.Course_Grade[CourseID]=random.randint(50,100)self.calculateGPA()def Grade2GPA(self,grade):if(grade>=90):return 4elif(grade>=80):return 3elif(grade>=70):return 2elif(grade>=60):return 1else:return 0def calculateGPA(self):g = 0;#遍歷每一門所修的課程for courseID,grade in self.Course_Grade.items():g = g + self.Grade2GPA(grade)* CourseDict[courseID].Creditself.GPA = round(g/self.Credit,2)#+++++++++++++++++++++++++++++++++++++++++
#4.7.2 Python面向對象方式實現數據庫的課程類
#+++++++++++++++++++++++++++++++++++++++++#<程序:課程類>
class Course:def __init__ (self,cid,mname,CourseCredit,FinalDate):self.courseID = cidself.courseName = mnameself.studentID = []self.Credit = CourseCreditself.ExamDate = FinalDatedef SelectThisCourse(self,stuID):	#記錄誰修了這門課,在studentID列表里self.studentID.append(stuID)#+++++++++++++++++++++++++++++++++++++++++
#4.7.3 Python創建數據庫的學生與課程類組
#+++++++++++++++++++++++++++++++++++++++++#<程序:建立課程信息>
def setupCourse (CourseDict):	#建立CourseList: list of Course objectsCourseDict[1]=Course(1,"Introducation to Computer Science",4,1)CourseDict[2]=Course(2,"Advanced Mathematics",5,2)CourseDict[3]=Course(3,"Python",3,3)CourseDict[4]=Course(4,"College English",4,4)CourseDict[5]=Course(5,"Linear Algebra",3,5)#<程序:建立班級信息>
def setupClass (StudentDict):    #輸入一個空列表NameList = ["Aaron","Abraham","Andy","Benson","Bill","Brent","Chris","Daniel","Edward","Evan","Francis","Howard","James","Kenneth","Norma","Ophelia","Pearl","Phoenix","Prima","XiaoMing"] stuid = 1for name in NameList:StudentDict [stuid]=student(name,stuid)     #student對象的字典stuid = stuid + 1#+++++++++++++++++++++++++++++++++++++++++
#4.7.4 Python實例功能模擬
#+++++++++++++++++++++++++++++++++++++++++#<程序:模擬選課>
def SelectCourse (StudentList, CourseList):for stu in StudentList:		#每一個學生修幾門課CourseNum = random.randint(3,len(CourseList))		#修CourseNum數量的課#隨機選,返回列表CourseIndex = random.sample(range(len(CourseList)), CourseNum)for index in CourseIndex:stu.selectCourse(CourseList[index].courseName,CourseList[index].Credit)CourseList[index].SelectThisCourse(stu.StuID)#<程序:模擬考試>
def ExamSimulation (StudentList, CourseList):for day in range(1,6):	#Simulate the datefor cour in CourseList:if(cour.ExamDate==day):	# Hold the exam of course on that dayfor stuID in cour.studentID:for stu in StudentList:if(stu.StuID == stuID):	#student stuID selected this coursestu.TakeExam(cour.courseID)#<程序:主程序>
import random
CourseDict={}
StudentDict={}
setupCourse(CourseDict)
setupClass(StudentDict)
SelectCourse(list(StudentDict.values()),list(CourseDict.values()))
ExamSimulation(list(StudentDict.values()),list(CourseDict.values()))
for sid,stu in StudentDict.items():stu.getInfo()#==================================================================================================#=========================================
#4.8 有趣的小烏龜——Python之繪圖
#=========================================#+++++++++++++++++++++++++++++++++++++++++
#4.8.2 小烏龜繪制基礎圖形繪制
#+++++++++++++++++++++++++++++++++++++++++#<程序:繪出三條不同的平行線>
from turtle import *
def jumpto(x,y):		#移動小烏龜不繪圖up(); goto(x,y); down()
reset()			#置小烏龜到原點處
colorlist = ['red','green','yellow']
for i in range(3):jumpto(-50,50-i*50);width(5*(i+1));color(colorlist[i])   #設置小烏龜屬性forward(100)	#繪圖
s = Screen(); s.exitonclick()#<程序:繪出邊長為50的正方形>
from turtle import *
def jumpto(x,y):up(); goto(x,y); down()
reset()
jumpto(-25,-25)
k=4
for i in range(k):forward(50)left(360/k)
s = Screen(); s.exitonclick()#解法1#<程序:繪出半徑為50的圓>
from turtle import *
import math
def jumpto(x,y):up(); goto(x,y); down()
def getStep(r,k):rad = math.radians(90*(1-2/k))return ((2*r)/math.tan(rad))
def drawCircle(x,y,r,k):S=getStep(r,k)speed(10); jumpto(x,y)	for i in range(k):forward(S)left(360/k)
reset()
drawCircle(0,0,50,20)
s = Screen(); s.exitonclick()#解法1#<程序:繪出半徑為50的圓>
from turtle import *
circle(50)
s = Screen(); s.exitonclick()#+++++++++++++++++++++++++++++++++++++++++
#4.8.3 小烏龜繪制迷宮
#+++++++++++++++++++++++++++++++++++++++++#<程序:迷宮輸入>
m=[[1,1,1,0,1,1,1,1,1,1],[1,0,0,0,0,0,0,0,1,1],[1,0,1,1,1,1,1,0,0,1],[1,0,1,0,0,0,0,1,0,1],[1,0,1,0,1,1,0,0,0,1],[1,0,0,1,1,0,1,0,1,1],[1,1,1,1,0,0,0,0,1,1],[1,0,0,0,0,1,1,1,0,0],[1,0,1,1,0,0,0,0,0,1],[1,1,1,1,1,1,1,1,1,1]]#<程序:迷宮中的墻與通道繪制>
from turtle import *
def jumpto(x,y):up(); goto(x,y); down()
def Access(x,y):jumpto(x,y)for i in range(4):forward(size/6); up(); forward(size/6*4); down();forward(size/6); right(90)
def Wall(x,y,size):color("red"); jumpto(x,y);for i in range(4):forward(size)right(90)goto(x+size,y-size); jumpto(x,y-size); goto(x+size,y)#<程序:小烏龜畫迷宮>
reset(); speed('fast')
size=40; startX = -len(m)/2*size; startY = len(m)/2*size
for i in range(0,len(m)):for j in range(0,len(m[i])):if m[i][j]==0:Access(startX+j*size, startY-i*size)else:Wall(startX+j*size, startY-i*size,size)
s = Screen(); s.exitonclick()   #程序練習題4.8.2#<程序:多個圓形的美麗聚合>
from turtle import *
reset()
speed('fast')
IN_TIMES = 40
TIMES = 20
for i in range(TIMES):right(360/TIMES)forward(200/TIMES)  #這一步是做什么用的?for j in range(IN_TIMES):right(360/IN_TIMES)forward (400/IN_TIMES)
write(" Click me to exit", font = ("Courier", 12, "bold") )
s = Screen()
s.exitonclick()

?

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/445551.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/445551.shtml
英文地址,請注明出處:http://en.pswp.cn/news/445551.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

用Python批量生成字幕圖片用于視頻剪輯

說明 視頻剪輯時需要為視頻添加字幕&#xff0c;添加字幕方法之一&#xff1a;根據字幕文本文件批量生成透明底只有字幕內容的圖片文件&#xff0c;如下圖&#xff0c;然后將這些圖片文件添加到視頻剪輯軟件軌道中。 于是用pillow這Python圖片工具庫執行本次批量生成工作。 …

關于接地:數字地、模擬地、信號地、交流地、直流地、屏蔽地、浮

除了正確進行接地設計、安裝,還要正確進行各種不同信號的接地處理。控制系統中&#xff0c;大致有以下幾種地線&#xff1a; &#xff08;1&#xff09;數字地&#xff1a;也叫邏輯地&#xff0c;是各種開關量&#xff08;數字量&#xff09;信號的零電位。 &#xff08;2&…

python學習實例(5)

# #5.1 計算思維是什么 ##<程序: 找假幣的第一種方法> by Edwin Sha def findcoin_1(L):if len(L) <1:print("Error: coins are too few"); quit()i0while i<len(L):if L[i] < L[i1]: return (i)elif L[i] > L[i1]: return (i1)ii1print("All…

一個用LaTeX寫長除法計算過程的示例

源碼 \begin{array}{lr} & x1 \\ x1 \!\!\!\!\!\! & \overline{)x^2 2x 1} \\ & \underline{x^2\ \ x\ \ \ \ \ \ \ } \\ & x 1 \\ & \underline{x1} \\ & 0 \end{array}效果 x1x1???????????)x22x1 ̄x2x ̄x1x1 ̄0\begin{array}…

AltiumDesigner中PCB如何添加 Logo

AltiumDesigner中PCB如何添加 Logo 轉載2015-10-29 00:07:55標簽&#xff1a;it文化教育首先用到的畫圖軟件&#xff0c;當然是大家熟悉的Altium Designer了&#xff0c;呵呵&#xff0c;相信很多人都用過這款畫圖軟件吧&#xff08;現在電路設計一直在用&#xff09;&#xff…

python學習實例(6)

# #6.6 文件系統&#xff08;File System&#xff09; ## #6.6.3 Python中的文件操作 ##<程序&#xff1a;讀取文件os.py> f open("./Task1.txt",r); fls f.readlines() for line in fls:line line.strip(); print (line) f.close()#<程序&#xff1a;讀…

網絡視頻ts格式文件下載及將其合成單一視頻文件

一些網站會將視頻分割成n個ts文件。 用貓抓chrome插件&#xff0c;抓取index.m3u8&#xff0c;可得到眾多ts文件下載地址。 可用迅雷打包下載ts文件以及index.m3u8文件&#xff0c;但有時會出現下載不了的情況&#xff0c;懷疑是請求報頭的問題上。 若迅雷下載不了&#xff…

PCB布局,布線技巧總結

PCB布局 在設計中&#xff0c;布局是一個重要的環節。布局結果的好壞將直接影響布線的效果&#xff0c;因此可以這樣認為&#xff0c;合理的布局是PCB設計成功的第一步。 布局的方式分兩種&#xff0c;一種是交互式布局&#xff0c;另一種是自動布局&#xff0c;一般是在自動布…

python學習實例(7)

# #第8章 信息安全&#xff08;Information Security&#xff09;的python程序 ## #8.3 措施和技術 ## #8.3.1 密碼學 ##非對稱加密#<程序&#xff1a;把n分解成p*q> import math n 221 m int(math.ceil(math.sqrt(n))) flag 0 for i in range(2,m1,1):if n % i 0:pr…

什么是TTL電平、CMOS電平、RS232電平

工作中遇到一個關于電平選擇的問題,居然給忘記RS232電平的定義了,當時無法反應上來,回來之后查找資料才了解兩者之間的區別,視乎兩年多的時間,之前非常熟悉的一些常識也開始淡忘,這個可不是一個好的現象.:-),還是把關于三種常見的電平的區別copy到這里.做加深記憶的效果之用.. …

RFI濾波器電路

RFI濾波器電路 最實用解決方案是通過使用一個差分低通濾波器在儀表放大器前提供 RF 衰減濾波器。該濾波器需要完成三項工作&#xff1a;盡可能多地從輸入端去除 RF能量&#xff0c;保持每個輸入端和地之間的 AC 信號平衡&#xff0c;以及在測量帶寬內保持足夠高的輸入阻抗以避免…

使用Ultra Librarian 生成PCB庫文件

第一步&#xff1a;找到對應芯片的CAD文件&#xff0c;以OPA350為例&#xff1a; http://www.ti.com/product/opa350 第二步&#xff1a; 下載上圖右邊連接的 Ultra Librarian.zip &#xff0c; 然后根據提示&#xff0c;安裝。 安裝好后打開Ultra Librarian&#xff0c;會出現…

借漢諾塔理解棧與遞歸

我們先說&#xff0c;在一個函數中&#xff0c;調用另一個函數。 首先&#xff0c;要意識到&#xff0c;函數中的代碼和平常所寫代碼一樣&#xff0c;也都是要執行完的&#xff0c;只有執行完代碼&#xff0c;或者遇到return&#xff0c;才會停止。 那么&#xff0c;我們在函…

簡單迷宮問題

迷宮實驗是取自心理學的一個古典實驗。在該實驗中&#xff0c;把一只老鼠從一個無頂大盒子的門放入&#xff0c;在盒子中設置了許多墻&#xff0c;對行進方向形成了多處阻擋。盒子僅有一個出口&#xff0c;在出口處放置一塊奶酪&#xff0c;吸引老鼠在迷宮中尋找道路以到達出口…

qt超強繪圖控件qwt - 安裝及配置

qwt是一個基于LGPL版權協議的開源項目&#xff0c; 可生成各種統計圖。它為具有技術專業背景的程序提供GUI組件和一組實用類&#xff0c;其目標是以基于2D方式的窗體部件來顯示數據&#xff0c; 數據源以數值&#xff0c;數組或一組浮點數等方式提供&#xff0c; 輸出方式可以是…

BFPRT

在一大堆數中求其前k大或前k小的問題&#xff0c;簡稱TOP-K問題。而目前解決TOP-K問題最有效的算法即是BFPRT算法&#xff0c;其又稱為中位數的中位數算法&#xff0c;該算法由Blum、Floyd、Pratt、Rivest、Tarjan提出&#xff0c;最壞時間復雜度為O(n)O(n)。 讀者要會快速排序…

180°舵機的使用步驟

一.步驟 1.首先查看舵機的運行參數&#xff0c;包括工作的電壓和電流&#xff0c;轉1&#xff08;60&#xff09;需要的脈寬是多少。 2.根據舵機提供的參數&#xff0c;算出需要的PWM的周期和脈寬的范圍。 3.通過單片機或者其他數字電路產生相應的PWM波&#xff0c;便可以驅…

Qt開源項目

圖像處理&#xff1a; Krita digikam inkscape 編輯器&#xff1a; LiteIDE QDevelper KDeveloper Monkey Studio TeXstudio 繪圖&#xff1a; ZeGrapher QtiPlot qcustomplot QWT HotShots Inkscape 三維建模&#xff1a; QCAD FreeCAD OpenModelica LibreCAD 音樂&#xff1a…

使用Python作為計算器

數值 1.python支持基本的數學運算符&#xff0c;而且應用python你可以像寫數學公式那樣簡單明了。 eg: >>> 2 2 4 >>> 50 - 5*6 20 >>> (50 - 5*6) / 4 5.0 >>> 8 / 5 # division always returns a floating point number 1.6 2.除法…

java整體打印二叉樹

一個調的很好的打印二叉樹的代碼。 用空格和^v來表示節點之間的關系。 效果是這樣&#xff1a; Binary Tree: v7v v6v ^5^ H4H …