day6作业详解
1.day6题目
1,老男孩好声⾳选秀⼤赛评委在打分的时候呢, 可以进⾏输入. 假设, 老男孩有10个评委. 让10个评委进⾏打分, 要求, 分数必须⼤于5分, 小于10分.
- 电影投票. 程序先给出⼀个⽬前正在上映的电影列表. 由⽤户给每⼀个电影打分. 最终,将该⽤户打分信息公布出来
lst = ['惊奇队长', '比悲伤更悲伤的故事', '驯龙高手3', '复仇者联盟4'] 结果:
3.念数字. 给出一个字典. 在字典中标识出每个数字的发音.
包括相关符号. 然后由用户输入一个数字.
让程序读出相对应的发音(不需要语音输出. 单纯的打印即可)
4.车牌区域划分, 现给出以下车牌. 根据车牌的信息, 分析出各省的车牌持有量.
cars = ["鲁A10086", "黑A45678", "黑C12345", "湘B00001", "京C78912", "京A66666"]
locations = {"鲁": "山东", "黑": "黑龙江", "京": "北京",'湘':'湖南'}
5.干掉主播. 现有如下主播收益信息, 按照要求, 完成相应操作:
zhubo = {'卢本伟':100,'PDD':2000000,'阿冷':1231231,'轩墨宝宝':898989}
1.计算主播平均收益值
2.干掉收益小于平均值的主播
3.干掉卢本伟
2.作业详解
点击查看详细内容
1 sama = 0 count = 1
while count <= 10:
fs = int(input('请%s好评委打分:')%count)
sama = sama + fs
if fs < 5 or fs > 10:
print("请给出合理的分数")
else:
print("总分:%d" %sama)
count +=12
lst = ['惊奇队长', '比悲伤更悲伤的故事', '驯龙高手3', '复仇者联盟4']
dic = {}
for i in lst:
df = int(input("请给【%s】打分:"%i).strip())
dic[i] = df
print(dic)3
dic = {
"1":"yi",
"2":"er",
"3":"san",
"4":"si",
"5":"wu",
"6":"liu",
"7":"qi",
"8":"ba",
"9":"jiu",
"10":"shi",
"+":"jia",
"-":"jian",
}
i_nu = input("请输入数字:").strip()
for i in i_nu:
print(dic[i])4 统计
cars = ["鲁A10086", "黑A45678", "黑C12345", "湘B00001", "京C78912", "京A66666"]
locations = {"鲁": "山东", "黑": "黑龙江", "京": "北京",'湘':'湖南'}
dic = {}for i in cars:
print(i) #遍历车牌
l_key = i[0] #鲁
if dic.get(locations[l_key]) == None: #dic字典'山东'不存在
dic[locations[l_key]] = 1
else:
dic[locations[l_key]] = dic[locations[l_key]]+1
print(dic)5 坑点:字典在迭代时不能修改
zhubo = {'卢本伟':1822300,'PDD':2000000,'阿冷':1731231,'轩墨宝宝':898989}5-1
sama = 0
for i in zhubo:
sama += zhubo[i]
sama = sama // len(zhubo)
print("平均收益:%d 元"%sama)5-2
for i in list(zhubo): #把dict转成list
if zhubo[i] < sama:
zhubo.pop(i)
print(zhubo)5-3
zhubo.pop('卢本伟')
print(zhubo)