ns=[1,3,5,8]
cnt=0
for a in ns:
for b in ns:
for c in ns:
if a!=b and a!=c and b!=c:
print(a*100+b*10+c)
cnt+=1
print(cnt)
for i in range(1,1001):
n=str(i)
if '3' in n:
if '33' in n:
n='&'+n
t=True
for j in range(2,i):
if i%j==0:
t=False
break
if t:
n=n+'*'
print(n)
ns=list(map(int,input().split(',')))
print(len(ns))
print(min(ns))
s=''
for n in ns:
if 1<=n<=26:
s+=chr(64+n)
else:
s+='[bad]'
ns.sort(reverse=True)
ns=list(map(str,ns))
print(','.join(ns))
print(s)
import turtle,random
turtle.setup(800,600)
t=turtle.Turtle()
t.speed(7)
t.pensize(5)
t.color('black','yellow')
for i in range(5):
x=random.randint(-400,400)
y=random.randint(-300,300)
t.penup()
t.goto(x,y)
t.pendown()
t.begin_fill()
l=random.randint(10,150)
for j in range(5):
t.forward(l)
t.right(36*4)
t.end_fill()
import turtle
t=turtle.Turtle()
t.left(90)
def fen(n,l):
if n==0:
return
else:
t.left(25)
t.forward(l)
fen(n-1,l-6)
t.backward(l)
t.right(50)
t.forward(l)
fen(n-1,l-6)
t.backward(l)
t.left(25)
fen(4,60)
import turtle,random
turtle.setup(800,600)
turtle.tracer(0)
t=turtle.Turtle()
t.left(90)
def fen(n,l,left,right):
if n==0:
return
else:
t.left(left)
t.forward(l)
fen(n-1,l-6,left,right)
t.backward(l)
t.right(left)
t.right(right)
t.forward(l)
fen(n-1,l-6,left,right)
t.backward(l)
t.left(right)
for i in range(50):
x=random.randint(-400,400)
y=random.randint(-300,300)
t.penup()
t.goto(x,y)
t.pendown()
n=random.randint(4,6)
l=random.randint(30,60)
if x<0:
left,right=20,-5 #偏左边时左右分支要转的角度
else:
left,right=-5,20 #偏左边时左右分支要转的角度
fen(n,l,left,right)
①在py代码文件同一目录下,新建userpass.txt文件,输入账号,密码(如有中文记得文件–另存为–右下角编码UTF-8改为ANSI–保存)
②在py代码文件同一目录下,新建goods.txt文件,输入商品数据(如有中文记得文件–另存为–右下角编码UTF-8改为ANSI–保存)
001,菠萝,水果,10;002,玫瑰,鲜花,999;003,柚子,水果,20;004,榴莲,水果,30
③参考程序
import random
code=random.randint(100000,999999)
print('您的登录验证码为',code)
n=input('请输入用户名:')
pw=input('请输入密码:')
c=int(input('登录验证码:'))
is_in=True
with open('./userpass.txt','r') as f:
s=f.read()
name,password=s.split(',')
if n==name and pw==password and c==code:
is_in=True
print('身份验证通过,欢迎登录!')
else:
print('身份验证失败!')
if is_in:
with open('./goods.txt','r') as f:
s=f.read()
goods=s.split(';')
for good in goods:
print(good)
while True:
try:
order=input('::')
if order=='add':
good_num=input('商品编号:')
good_name=input('商品名:')
good_type=input('商品类型:')
good_stock=int(input('库存数量:'))
if good_num.strip() and good_name.strip() and good_type.strip() and good_stock:
new_s=good_num+','+good_name+','+good_type+','+str(good_stock)
goods.append(new_s)
s=s+';'+new_s
with open('./goods.txt','w') as f:
f.write(s)
elif order=='count':
cnt=0
for good in goods:
good_datas=good.split(',')
cnt+=int(good_datas[3])
print(cnt)
for good in goods:
print(good)
except Exception as e:
print(e)