shift+win+s 局部截图
4-1:输出每日一帖4
datetime.datetime.now() 获取当前日期
datetime.datetime.now().weekday() 获取当前日期的星期
运行结果:
4-2:分两列显示2017~2018赛季NBA西部联盟前八名的球队
4-3:向NBA名人堂列表中追加2018年新进入的球星
4-4:使用二维列表输出不同版本的古诗
4-5
coffeename = ('蓝山','卡布奇诺','曼特宁','摩卡','麝香猫','哥伦比亚')
print(coffeename)
4-6
coffeename = ('蓝山','卡布奇诺','曼特宁','摩卡','麝香猫','哥伦比亚')
print("您好~欢迎光临~伊米咖啡馆~\n\n我店有:\n")
for name in coffeename :
print(name + "咖啡",end = " ")
4-7
print("2017~2018赛季NBA西部联盟前八名\n")
team = ("火箭","勇士","开拓者","雷霆","爵士","鹈鹕","马刺","森林狼")
for index ,item in enumerate(team):
if index % 2 ==0 :
print(item+"\t\t",end = '')
else :
print(item + "\n")
4-8
coffeename = ('蓝山','卡布奇诺','曼特宁','摩卡','麝香猫','哥伦比亚')
coffeename = ('蓝山','卡布奇诺','曼特宁','摩卡','拿铁','哥伦比亚')
print("新元组",coffeename)
4-9
name = ['绮梦','冷伊一','香凝','黛香']
sign = ['水瓶座','射手座','双鱼座','双子座']
dictionary = dict(zip(name,sign))
print(dictionary)
4-10
name = ['绮梦','冷伊一','香凝','黛香']
sign_person = ['水瓶座','射手座','双鱼座','双子座']
person_dict = dict(zip(name,sign_person))
sign_all =['白羊座','金牛座','双子座','巨蟹座','狮子座','处女座','天秤座','天蝎座','射手座','摩羯座','水瓶座','双鱼座']
nature = ['有一种让人看见就开心的感觉,阳光,乐观,坚强,性格直来直去,就是有点小脾气。',
'很保守,喜欢稳定,一旦有什么变动就慧觉得心里不踏实,性格比较慢热,是个理财高手。',
'喜欢追求新鲜感,有点小聪明,耐心不够,因您的可爱性格会让很多人喜欢和你做朋友。',
'情绪容易敏感,缺乏安全感,做事情有坚持待敌的毅力,为人重情重义,对朋友和家人突然别忠实。',
'有着远大理想,总想靠自己的努力成为人上人,总是期待贝仰慕被崇拜的感觉。',
'坚持追求自己的完美主义者。',
'追求求平等,和谐,交际能力强,因此朋友较多。最大的缺点就是面对选择总是犹豫不决。',
'精力旺盛,占有欲强,对于生活很有目标,不达目的誓不罢休,复仇心中。',
'崇尚自由,勇敢,果断,独立,身上有一股勇往直前的劲儿,只要想做,就能做。',
'是最有耐心的,做事最小心,做事脚踏实地,比较固执,不达目的不罢休 ,而恶企鹅海战勤奋。',
'人很聪明,最大的特点是创新,追求独一无二的生活,个人之一色彩很浓重的星座。',
'集所有星座的优缺点于一身。最大的有点是有一颗善良的心愿意帮助别人。']
sign_dict = dict(zip(sign_all,nature))
print("【香凝】的星座是",person_dict.get("香凝"))
print("\n 她的性格特点是:\n\n",sign_dict.get(person_dict.get("香凝")))
4-11
name = ['绮梦','冷伊一','香凝','黛香']
sign = ['水瓶','射手','双鱼','双子']
dictionary = {i:j+'座' for i,j in zip(name,sign)}
print(dictionary)
4-12
python = {'绮梦','冷伊一','香凝','梓轩'}
c = {'冷伊一','零雨','梓轩','圣博'}
print('选择Python语言的学生有:',python,'\n')
print('选择C语言的学生有:',c)
4-13
python = set(['绮梦','冷伊一','香凝','梓轩'])
python.add('零语')
c = set(['冷伊一','零语','梓轩','圣博'])
c.remove('零语')
print('选择Python语言的学生有:',python,'\n')
print('选择C语言的学生有:',c)
4-14
python = set(['绮梦','冷伊一','香凝','梓轩'])
c = set(['冷伊一','零语','梓轩','圣博'])
print('选择Python语言的学生有:',python,'\n')
print('选择C语言的学生有:',c)
print('交集运算:',python & c)
print('并集运算:',python | c)
print('差集运算:',python - c)
p4-1
print("“王者荣耀” 的角色:\n")
dictionary = {'====坦克:=====':'安禄山,阿骨朵,白起,程咬金,廉颇,刘邦,苏烈,项羽,夏侯惇,猪八戒,巨灵神,牛魔',
'====战士:====':'曹操,达摩,典韦,宫本武藏,关羽,花木兰,铠,狂铁,老夫子,李信,刘备,露娜,吕布,马超,梦奇,哪吒,盘古,孙策,雅典娜,亚瑟,杨戬,蒙恬,赵云,钟无艳,曜',
'====刺客:====':'阿轲,百里玄策,韩信,橘右京,兰陵王,李白,娜可露露,裴擒虎,司马懿,孙悟空,元歌,云中君,镜',
'====法师:====':'安琪拉,扁鹊,不知火舞,嫦娥,妲己,貂蝉,干将莫邪,高渐离,姜子牙,米莱狄,芈月,墨子,女娲,沈梦溪,上官婉儿,王昭君,武则天,小乔,杨玉环,奕星,嬴政,张良,甄姬,周瑜,诸葛亮,西施',
'====射手:====':'蒙犽,百里守约,成吉思汗,狄仁杰,伽罗,公孙离,后羿,黄忠,李元芳,鲁班七号,马可波罗,孙尚香,虞姬',
'====辅助:====':'蔡文姬,大乔,东皇太一,盾山,刘禅,明世隐,牛魔,孙膑,太乙真人,瑶,张飞,庄周,鬼谷子,钟馗,鲁班大师'}
for key,value in dictionary.items():
print(key,"\n",value)
p4-2
print("车次"+"\t"+"出发站-到达站"+"\t"+"出发时间"+"\t"+"到达时间"+"\t"+"历时")
checi = ['T40','T298','Z158','Z62']
zhan = ['长春-北京','长春-北京','长春-北京','长春-北京']
stime = ['00:12','00:06','12:48','21:58']
etime = ['12:20','10:50','21:06','06:08']
lishi = ['12:08','10:44','08:18','8:20']
print(checi[0]+'\t'+zhan[0]+'\t'+stime[0]+'\t'+etime[0]+'\t'+lishi[0])
print(checi[1]+'\t'+zhan[1]+'\t'+stime[1]+'\t'+etime[1]+'\t'+lishi[1])
print(checi[2]+'\t'+zhan[2]+'\t'+stime[2]+'\t'+etime[2]+'\t'+lishi[2])
print(checi[3]+'\t'+zhan[3]+'\t'+stime[3]+'\t'+etime[3]+'\t'+lishi[3])
number = str(input("请输入要购买的车次:"))
name = str(input("请输入乘车人(用逗号分隔):"))
checi_dict = dict(zip(checi,zhan))
stime_dict = dict(zip(checi,stime))
a = checi_dict[number]
b = stime_dict[number]
print("你已购"+str(number)+"次列车" +str(a)+" "+str(b)+ "开","请"+str(name)+"准时乘车【铁路客服】")
p4-3
print("电视剧的收视排行榜:")
program = {('《Give up,hold on to me》收视率:','1.4%'),
('《The private dishes of the husbands》收视率:','1.343%'),
('《My father-in-law will do martiaiarts》收视率:','0.92%'),
('《North Canton still believe in love》收视率 :','0.862%'),
('《Impossible task》收视率:','0.553%'),
('《Sparrow》收视率:','0.411%'),
('《East of dream Avenue》收视率;','0.164%'),
('《The prodigal son of the frotier town》收视率:','0.259%'),
('《Distant distance》收视率:','0.394%'),
('《Music legend》收视率:','0.562%')}
program_rate = sorted(program,key = lambda x:x[1],reverse = True)
for item in program_rate:
print(item[0]+str(item[1]))
p4-4
标签:name,python,sign,dict,实训,print,香凝,第四章 From: https://www.cnblogs.com/fht0107/p/16719305.html