commit e70ffbfdd87938babc74902c92e00c5ba84f2a91 Author: sairate Date: Thu Jul 11 12:20:22 2024 +0800 Signed-off-by: sairate diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..35410ca --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# 默认忽略的文件 +/shelf/ +/workspace.xml +# 基于编辑器的 HTTP 客户端请求 +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..105ce2d --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..2a01189 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..e15ec35 --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/pythonProject.iml b/.idea/pythonProject.iml new file mode 100644 index 0000000..2c80e12 --- /dev/null +++ b/.idea/pythonProject.iml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/lambada.py b/lambada.py new file mode 100644 index 0000000..50496dc --- /dev/null +++ b/lambada.py @@ -0,0 +1 @@ +print(sum(list(range(1,101,2)))) \ No newline at end of file diff --git a/五星红旗.py b/五星红旗.py new file mode 100644 index 0000000..d9a34d8 --- /dev/null +++ b/五星红旗.py @@ -0,0 +1,40 @@ +import turtle +turtle.speed(0)#设置速度为最快 +def wujiao(size,x,y,angle=0): + #初始化开始位置和方向 + turtle.penup() + turtle.goto(x,y) + turtle.setheading(angle) + turtle.pendown() + #循环绘制五角星 + turtle.color("yellow","yellow") + turtle.begin_fill() + for i in range(5): + turtle.forward(size) + turtle.left(72) + turtle.forward(size) + turtle.right(144) + turtle.end_fill() +#绘制背景色 +turtle.color("red","red") +turtle.begin_fill() +turtle.penup() +turtle.goto(-300,200) +turtle.pendown() +turtle.goto(300,200) +turtle.goto(300,-200) +turtle.goto(-300,-200) +turtle.goto(-300,200) +turtle.end_fill() +#五角星的绘制和参数 +wujiao(30, -250, 150) +wujiao(9, -170, 180, 30) +wujiao(9, -140, 145, 45) +wujiao(9, -150, 120, 0) +wujiao(9, -170, 90, -30) +turtle.penup() +turtle.goto(0,0) +turtle.pendown() +turtle.write("中国",font=("华文行楷",50)) +turtle.hideturtle() +turtle.done()#结束绘制 \ No newline at end of file diff --git a/刘家赫.py b/刘家赫.py new file mode 100644 index 0000000..6d88d94 --- /dev/null +++ b/刘家赫.py @@ -0,0 +1,72 @@ +import turtle +import random + +def move(x1, y1,x2, y2): + t1.penup() + t2.penup() + t1.goto(x1, y1) + t2.goto(x2, y2) + t1.pendown() + t2.pendown() +def draw(r,g,b,n,step): + for i in range(1,3*n+1): + if i>2*n: + t1.pencolor("white") + t2.pencolor("white") + t1.forward(step) + t2.forward(step) + t1.left(360/n) + t2.right(360/n) + elif (n%2==1): + t1.pencolor(r,g,b) + t2.pencolor(r,g,b) + t1.forward(step) + t2.forward(step) + t1.left(360/n) + t2.right(360/n) + else: + t1.pencolor("white") + t2.pencolor("white") + t1.forward(step) + t2.forward(step) + t1.left(360/n) + t2.right(360/n) + + +t1=turtle.Turtle() +t2=turtle.Turtle() + +t2.left(180) + +n=int(input()) +step=int(input()) + +t1.speed(10) +t2.speed(10) + +t1.pensize(5) +t2.pensize(5) + +x1,y1=0,0 +x2,y2=0,0 + +move(x1, y1,x2, y2) + + +while 1: + for i in range(5): + g=random.random() + b=random.random() + draw(1,g,0,n,step) + x1+=step + x2-=step + move(x1, y1, x2, y2) + + for i in range(5): + g=random.random() + b=random.random() + draw(1,0,0,n,step) + x1-=step + x2+=step + move(x1, y1, x2, y2) +turtle.down() \ No newline at end of file diff --git a/判卷.py b/判卷.py new file mode 100644 index 0000000..89eb431 --- /dev/null +++ b/判卷.py @@ -0,0 +1,28 @@ +b='ABCCBACBAC' + +n=int(input('请输入人数')) +list=[] +for i in range(0,n): + temp=input() + while len(temp)!=len(b): + temp=input("重新输入:") + list.append(temp) + +score=[0] +correct_daan=[""] + +count=1 +for j in list: + score.append(0) + correct_daan.append("") + daan=j + for i in range(0, 10): + if daan[i] == b[i]: + correct_daan[count] += b[i] + score[count] += 10 + else: + correct_daan[count] += 'X' + count+=1 + +for i in range(1,len(score)): + print("{}号学员,{}分数".format(i,score[i]),correct_daan[i]) \ No newline at end of file diff --git a/多人判卷.py b/多人判卷.py new file mode 100644 index 0000000..e0ecba0 --- /dev/null +++ b/多人判卷.py @@ -0,0 +1,24 @@ +correct_answer="AAAAABBBBB" + +n=int(input("请输入判卷人数")) + +user_answer_list=[0] +user_score_list=[0] +mark_answer_list=[0] + +for i in range(n): + user_answer_list.append(input("请输入{}号人的答案".format(i+1))) + +for i in range(1,n+1): + user_score_list.append(0) + mark_answer_list.append("") + for j in range(len(correct_answer)): + if user_answer_list[i][j]==correct_answer[j]: + user_score_list[i]+=10 + mark_answer_list[i]+=correct_answer[j] + else: + mark_answer_list[i]+="X" + +for i in range(1,n+1): + print("{}号人成绩为{}分,矫正{}".format(i,user_score_list[i],mark_answer_list[i])) + diff --git a/巡线.py b/巡线.py new file mode 100644 index 0000000..6ebac73 --- /dev/null +++ b/巡线.py @@ -0,0 +1,68 @@ +import cv2 +import numpy as np + +def region_of_interest(img, vertices): + mask = np.zeros_like(img) + cv2.fillPoly(mask, vertices, 255) + masked_image = cv2.bitwise_and(img, mask) + return masked_image + +def draw_lines(img, lines): + if lines is None: + return + img = np.copy(img) + blank_image = np.zeros((img.shape[0], img.shape[1], 3), dtype=np.uint8) + + for line in lines: + for x1, y1, x2, y2 in line: + cv2.line(blank_image, (x1, y1), (x2, y2), (0, 255, 0), thickness=5) + + img = cv2.addWeighted(img, 0.8, blank_image, 1, 0.0) + return img + +def process(image): + height = image.shape[0] + width = image.shape[1] + + region_of_interest_vertices = [ + (0, height), + (width // 2, height // 2), + (width, height) + ] + + gray_image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) + canny_image = cv2.Canny(gray_image, 100, 200) + cropped_image = region_of_interest(canny_image, + np.array([region_of_interest_vertices], np.int32)) + + lines = cv2.HoughLinesP(cropped_image, + rho=2, + theta=np.pi / 180, + threshold=50, + lines=np.array([]), + minLineLength=40, + maxLineGap=100) + + image_with_lines = draw_lines(image, lines) + return image_with_lines + +def main(): + cap = cv2.VideoCapture(0) + + while cap.isOpened(): + ret, frame = cap.read() + if not ret: + break + + frame = process(frame) + + cv2.imshow('frame', frame) + + if cv2.waitKey(1) & 0xFF == ord('q'): + break + + cap.release() + cv2.destroyAllWindows() + +if __name__ == "__main__": + main() diff --git a/平方数.py b/平方数.py new file mode 100644 index 0000000..cff532b --- /dev/null +++ b/平方数.py @@ -0,0 +1,21 @@ +list=[] + +count=0 + +n=int(input()) + +for i in range(n): + list.append(int(input())) + +for i in list: + num=i + result=0 + for x in range(1,int((num/2)**0.5)+1): + if num-x**2==(int((num-x**2)**0.5))**2: + print("Yes") + result=1 + break + count += 1 + print(count) + if result==0: + print("No") \ No newline at end of file diff --git a/开关灯.py b/开关灯.py new file mode 100644 index 0000000..7ad0361 --- /dev/null +++ b/开关灯.py @@ -0,0 +1,20 @@ +list=[0] +count=0 +n=int(input()) + +for i in range(n): + list.append(0) + +for i in range(2,n+1): + for j in range(i,n+1,i): + if j%i==0: + if list[j]==0: + list[j]=1 + else: + list[j]=0 + count+=1 + print(count) + +for i in range(1,n+1): + if list[i]==0: + print(i,end=" ") \ No newline at end of file diff --git a/循环.py b/循环.py new file mode 100644 index 0000000..1b2586d --- /dev/null +++ b/循环.py @@ -0,0 +1,18 @@ +import turtle +import random +n=int(input()) +turtle.speed(0) +turtle.pensize(10) +turtle.fillcolor("red") +turtle.begin_fill() +for j in range(18): + for i in range(n): + r = random.random() + g = random.random() + b = random.random() + turtle.pencolor(1, g, b) + turtle.forward(100) + turtle.right(360/n) + turtle.right(20) +turtle.end_fill() +turtle.done() \ No newline at end of file diff --git a/猜数字.py b/猜数字.py new file mode 100644 index 0000000..fdf67f7 --- /dev/null +++ b/猜数字.py @@ -0,0 +1,18 @@ +import random +num=random.randint(1,100) +count=0 +while 1: + input_num=int(input("请输入猜测的数字:")) + if input_num>num: + print("猜大了") + elif input_num5: + print("猜了{}次,菜".format(count)) +else: + print("猜了%d次,真厉害"%count) diff --git a/美丽的雪花.py b/美丽的雪花.py new file mode 100644 index 0000000..a5a97f7 --- /dev/null +++ b/美丽的雪花.py @@ -0,0 +1,49 @@ +import turtle +import random + +# listx=[0] +# listy=[0] +# +# listcx = [] +# listcy = [] +# +# for p in range(25): +# listcx.append(0) +# listcy.append(0) +# listx.append(0) +# listy.append(0) + +t=turtle.Turtle() +t.speed(0) + +for i in range(40): + step = random.randint(20, 50) + r=random.random() + g=random.random() + b=random.random() + x = random.randint(-400, 400) + y = random.randint(-300, 300) + # is_xing=0 + # while is_xing==0: + # is_xing=1 + # x = random.randint(-400, 400) + # y = random.randint(-300, 300) + # for j in range(i-1): + # listcx[j] = abs(x - listx[j]) + # listcy[j] = abs(y - listy[j]) + # for k in range(i+1): + # if listcy[k] <= 200 or listcy[k] <= 200: + # is_xing = 0 + # listx[i]=x + # listy[i]=y + + t.penup() + t.goto(x,y) + t.pendown() + t.pencolor(r, g, b) + for a in range(6): + t.forward(step) + t.penup() + t.goto(x,y) + t.pendown() + t.right(60) \ No newline at end of file diff --git a/螺旋.py b/螺旋.py new file mode 100644 index 0000000..2ea63c7 --- /dev/null +++ b/螺旋.py @@ -0,0 +1,16 @@ +import turtle +pen=turtle.Turtle() +pen.speed(0) +n=int(turtle.numinput("边数","请输入边数:")) +name=turtle.textinput("姓名","请输入姓名:") +colors=["red","green","blue","yellow","black"] + +angle=360/n+1 +for i in range(360): + pen.pencolor(colors[i%n]) + pen.penup() + pen.forward(i*10) + pen.pendown() + pen.write(name,font=("华文行楷",int(i/50))) + pen.right(angle) + pen.pensize(i/20) \ No newline at end of file