综合小程序的设计

1、熟悉python可视化的设计

2、完成综合小程序的设计。

3、完成代码的设计

一、排序小程序

ec9f3ad824bb4c7f966340cdcc95bac1.jpg 

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)

二、随机密码生成器

f6dca6c56ef64d7f852fad29fdb3e4c2.jpg 

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)

三、顺序逆序输出器

088ef7533e8b4488b39b02b0682d1e78.jpg 

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)

四、库存查询器

b45ad9663e2048e4923a2c9d83a5f0ed.jpg 

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值