Signed-off-by: MZ <zhangruize@sairate.fun>

This commit is contained in:
MZ 2024-07-16 08:48:49 +08:00
commit a41ec8a137
29 changed files with 521 additions and 0 deletions

47
2024-6-1-teacher.py Normal file
View File

@ -0,0 +1,47 @@
'''
请编写一个管理员管理前台会员信息系统
1.后台信息管理系统只有一个管理员 用户名admin 密码admin
2.管理员登录成功后可以管理前台会员信息
3.前台会员信息包含:
添加会员信息
删除会员信息
查看会员信息
退出
----添加用户:
1.判断用户是否存在?
2.如果存在,请重新输入
3.如果不存在将用户名和密码分别添加到liebiaozhong
----删除用户
1.判断用户名是否存在
2.如果存在请删除
3.如果不存在请重新输入
'''
print('欢迎来到管理员登录界面'.center(50,'*'))
# 初始会员信息
users = ['Jack','Cindy','Mike']
passwds = ['asdf','123','qwed']
# 请输入用户名和密码
user = input('请输入用户名:')
passwd = input('请输入密码:')
# 1.如果输入的用户名和密码为管理员,那么就可以进入管理员界面,否则用户名输入错误,该用户名不存在
# 2.进入操作界面来进行操作
if user == 'admin' and passwd == 'admin':
print('管理员%s成功进入登录系统界面'%user)
while 1:
print('''
**********操作界面***********
1.添加会员信息
2.删除会员信息
3.查看会员信息
4.退出
''')
option =input('请输入你的选择:')

6
2024-6-16-1.py Normal file
View File

@ -0,0 +1,6 @@
w=int(input())
s=int(input())
a=0
for i in range(w,s+1):
a=a+i*i
print(a)

5
2024-6-16-2.py Normal file
View File

@ -0,0 +1,5 @@
n=int(input())
for i in range(3,n+1)
tep=a+b
b=a
tep=b

2
2024-6-2-2.py Normal file
View File

@ -0,0 +1,2 @@
a=(1,2,3,[7,8,9])
print(a[3][2])

6
2024-6-2-3.py Normal file
View File

@ -0,0 +1,6 @@
a=(1,2,3,4)
b=(5,6,7,8)
print(2 in a)
print(a>b)
print(a*2)
print(a+b)

View File

@ -0,0 +1,85 @@
import os
import time
users=['as','Water','Ryan']
passwords=['asdfghjkl','1234','awsd123']
def menu():
print('''
**********操作界面***********
1.查看会员信息
2.添加会员信息
3.删除会员信息
4.退出
''')
z=input()
os.system('cls')
Pan(z)
def printuser():
print('会员用户有:')
print(users)
def back():
print('按b返回,其他键退出')
back=input()
os.system('cls')
if back=='b':
menu()
else:
exit()
def Pan(zero):
if zero=='1':
printuser()
back()
elif zero=='2':
addname=input('添加用户名:')
addpassword=input('添加密 码:')
if addname not in users:
if addname=='':
print('用户名不能为空')
else:
users.append(addname)
passwords.append(addpassword)
print('添加成功')
printuser()
else:
print('用户名已经存在')
back()
elif zero=='3':
removename=input('删除用户名:')
if removename in users:
index=users.index(removename)
users.remove(removename)
passwords.remove(passwords[index])
print('删除成功')
printuser()
else:
print('没有该用户')
back()
elif zero=='4':
exit()
def login():
user=input('用户名:')
password=input('密 码:')
if user=='Kun'and password=='iKun':
istrue=True
print('管理员%s成功进入登录系统界面'%user)
time.sleep(2)
os.system('cls')
else:
istrue = False
print('登录失败')
if istrue == True:
menu()
else:
loginerror()
def loginerror():
time.sleep(2)
os.system('cls')
login()
print('欢迎来到管理员登录界面'.center(50,'*'))
login()
os.system("pause")

3
2024-6-2.py Normal file
View File

@ -0,0 +1,3 @@
a=(1,2,3,4,5,6,7,8,9)
print(a[::2])
print(a[1::2])

16
2024-6-23-1.py Normal file
View File

@ -0,0 +1,16 @@
import random
secret_number = random.randint(1, 100)
attempts = 0
while True:
guess = int(input("猜猜看数字是多少1-100之间"))
attempts += 1
if guess == secret_number:
print("你居然猜对了!你猜了", attempts, "次,真菜!像只小菜一样!不是有啥实力啊!!!")
break
elif guess < secret_number:
print("小了,太菜了!像只小菜一样!有啥实力啊!!!")
else:
print("大了,太菜了!像只小菜一样!有啥实力啊!!!")

17
2024-6-23-2.py Normal file
View File

@ -0,0 +1,17 @@
import random
secret_number = random.randint(1, 100)
for attempts in range(1, 6):
guess = int(input("猜猜看数字是多少1-100之间"))
if guess == secret_number:
print("你居然猜对了!你猜了", attempts, "次,真菜!像只小菜一样!不是有啥实力啊!!!")
break
elif guess < secret_number:
print("小了,太菜了!像只小菜一样!有啥实力啊!!!")
else:
print("大了,太菜了!像只小菜一样!有啥实力啊!!!")
if attempts == 5 and guess != secret_number:
print("你没有在5次之内猜对真菜像只小菜一样不是有啥实力啊正确答案是", secret_number)

4
2024-6-30-1.py Normal file
View File

@ -0,0 +1,4 @@
for i in range(1,10):
for j in range(1,i+1):
print(j,"x ",i,"=",j*i,end='\t')
print()

3
2024-6-9-1.py Normal file
View File

@ -0,0 +1,3 @@
string1 ='Good Morning PePig'
print(string1[5:12:] )
print(string1[:-6:-1])

4
2024-6-9-2.py Normal file
View File

@ -0,0 +1,4 @@
a=input()
b=a.split()
b.reverse()
print(b)

7
2024-6-9-3.py Normal file
View File

@ -0,0 +1,7 @@
n=int(input())
print(n//100)
print(n%100//50)
print(n%100%50//20)
print(n%100%50%20//10)
print(n%100%50%20%10//5)
print(n%100%50%20%10%5)

1
2024-6-9-4.py Normal file
View File

@ -0,0 +1 @@
print(13,7,4)

25
2024-7-1-1.py Normal file
View File

@ -0,0 +1,25 @@
b='ABDCCBBDAA'
n=int(input('请输入人数'))
list=[]
for i in range(0,n):
list.append(input())
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])

12
2024-7-1-2.py Normal file
View File

@ -0,0 +1,12 @@
a=input()#用户输入的答案
b="ABDCCBBDAA"
c=""
d=0
if len(a)==len(b): #是否相等
for i in range(len(b)): #比较
if a[i]==b[i]:
c=c+b[i]
d=d+10#加分
else:
c=c+"x"
print(d,'',c)

39
2024-7-3-1.py Normal file
View File

@ -0,0 +1,39 @@
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.done()#结束绘制

17
2024-7-3-2.py Normal file
View File

@ -0,0 +1,17 @@
n=int(input("你想要几边形"))
m=int(input("你想要几个{}边形".format(n)))
import turtle
import random
t=turtle.Turtle()
t.speed(0)
t.pensize(5)
for j in range(m):
for i in range(n):
r = random.random()
g = random.random()
b = random.random()
t.pencolor(r,g,1)
t.backward(100)
t.left(360/n)
t.left(20)
turtie.done()

83
2024-7-3-3.py Normal file
View File

@ -0,0 +1,83 @@
b=int(input())
c=int(input())
import turtle
t=turtle.Turtle()
a=turtle.Turtle()
t.speed(0)
a.speed(0)
t.left(90)
t.pensize(5)
a.pensize(5)
t.goto(0,0)
a.penup()
a.goto(200,0)
a.pendown()
d=0
e=0
f=0
g=0
while 1:
for i in range(10):
for i in range(b):#for循环结构,range()函数迭代器list,tuple...
t.pencolor(e,f,g)
t.forward(c)
t.left(360/b)
a.pencolor(e,f,g)
a.forward(c)
a.left(360/b)
for i in range(b):#for循环结构,range()函数迭代器list,tuple...
t.pencolor("white")
t.forward(c)
t.left(360/b)
a.pencolor("white")
a.forward(c)
a.left(360/b)
d=d+1
e=d/10
if e>0.9:
e=0
d=0
f=f+0.1
if f>0.9:
f=0.1
g=g+0.1
if g>0.9:
g=0
a.backward(20)
for i in range(2):
for i in range(b):#for循环结构,range()函数迭代器list,tuple...
t.pencolor(e,f,g)
t.forward(c)
t.left(360/b)
a.pencolor(e,f,g)
a.forward(c)
a.left(360/b)
for i in range(b):#for循环结构,range()函数迭代器list,tuple...
t.pencolor("white")
t.forward(c)
t.left(360/b)
a.pencolor("white")
a.forward(c)
a.left(360/b)
t.forward(c)
for i in range(10):
for i in range(b):#for循环结构,range()函数迭代器list,tuple...
t.pencolor(e,f,g)
t.forward(c)
t.left(360/b)
a.pencolor(e,f,g)
a.forward(c)
a.left(360/b)
for i in range(b):#for循环结构,range()函数迭代器list,tuple...
t.pencolor("white")
t.forward(c)
t.left(360/b)
a.pencolor("white")
a.forward(c)
a.left(360/b)
a.backward(20)
t.goto(0,0)
a.penup()
a.goto(200,0)
a.pendown()
turtle.down()

72
2024-7-4-1.py Normal file
View File

@ -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(0)
t2.speed(0)
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()

12
2024-7-4-2.py Normal file
View File

@ -0,0 +1,12 @@
import turtle
t=turtle.Turtle()
t.speed(100)
t.pensize(4.5)
t.fillcolor('brown')
t.begin_fill()
for j in range(0,80):
t.pencolor('yellow')
t.backward(120)
t.left(100)
t.end_fill()
t.done()

8
2024-7-4-3.py Normal file
View File

@ -0,0 +1,8 @@
import turtle
t=turtle.Turtle()
for j in range(5):
t.pencolor('yellow')
t.forward(150)
t.left(72)
t.forward(150)
t.right(144)

12
2024-7-5-1.py Normal file
View File

@ -0,0 +1,12 @@
import turtle
import random
t=turtle.Turtle()
t.speed(0)
t.pensize(1)
for i in range(10000):
r = random.random()
g = random.random()
b = random.random()
t.pencolor(r,g,1)
t.backward(1*i)
t.left(61)

16
2024-7-5-2.py Normal file
View File

@ -0,0 +1,16 @@
import math
def is_prime(num):
if num < 2:
return False
for i in range(2, int(math.sqrt(num))+1):
if num % i == 0:
return False
return True
n = int(input())
for i in range(n//2, 1, -1):
if n % i == 0 and is_prime(i):
print(i)
break

View File

@ -0,0 +1,5 @@
# 读取输入的浮点数
n = float(input())
# 计算并输出绝对值,保留两位小数
print(f"{abs(n):.2f}")

4
2024-7-6-1.py Normal file
View File

@ -0,0 +1,4 @@
dict1={'小明':'95分','小红':'90分','小李':'94分','小李':'96分'}
List=[(1,2),(2,3),(3,4)]
dict1=dict(List)
print(dict1)

4
2024-7-6-2.py Normal file
View File

@ -0,0 +1,4 @@
score={'小明':95,'小红':90,'小李':94,}
score['小明']=100
score['Tom']=60
print(score)

2
2024-7-6-3.py Normal file
View File

@ -0,0 +1,2 @@
score=dict.fromkeys(('小明','小红','小李'),0)
print(score)

4
2024-7-6-4.py Normal file
View File

@ -0,0 +1,4 @@
score={'小明':95,'小红':90,'小李':94,}
print(score.get('小明'))
print(score.get('Tom'))
print(score.get('Tom',60))