1、熟悉python可视化的设计
2、完成综合小程序的设计。
3、完成代码的设计
一、排序小程序
lstScore=[]
for i in range (0,6):
cj=float(input("请输入第{0}个评分:".format(i)))
lstScore.append(cj)
print(lstScore)
smax=max(lstScore)
smin=min(lstScore)
lstScore.remove(smax)
lstScore.remove(smin)
finalScore=round(sum(lstScore)/len(lstScore),2)
formatter='去掉一个最高分{0}\去掉一个最低分{1}\n最后得分{2}'
print(formatter.format(smax,smin,finalScore))print("排序前:",lstScore)
lstScore.sort(reverse=True)
二、随机密码生成器
import random
num=int(input('密码长度: '))
nums=int(input('几个特殊字符: '))
numd=int(input('几位数字: '))
digitL=['0','1','2','3','4','5','6','7','8','9']
symbol=['!','@','#','$','%','^','&','*','(',')','<','>']
alpha=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r', 's','t','u','v','w','x','y','z']
s=random.sample(symbol,nums)
d=random.sample(digitL,numd)
a=random.sample(alpha,num-nums-numd)
l=s+d+a
random.shuffle(l)
passward=''.join(l)
print('生成的密码是:',passward)
三、顺序逆序输出器
s=input('请输入几个英语单词(用空格分隔):')
wordL=s.split()
aL=[]
for word in wordL:
if 'a' in word:
aL.append(word)
print('含有字母a的单词:',aL)
wordL.sort()
print('顺序输出:',wordL)
wordL.sort(reverse=True)
print('逆序输出:',wordL)
四、库存查询器
inventory={'apple':100,'pear':59,'banana':30,'strawberry':60,'durian':20,'peach':60}
while True:
fruit=input('请问您要查询哪种水果?')
if fruit in inventory:
print('库房里有{}箱{}'.format(inventory[fruit],fruit))
else:
print('不好意思,我们库存里没有这种水果')
if fruit=='':
print('当前库存:')
for key,value in inventory.items(): print('{:>10}-----------{:<5}'.format(key,value))
break