首页 > 其他分享 >第四章实验

第四章实验

时间:2022-09-29 12:56:26浏览次数:54  
标签:end python train 实验 time print dict 第四章

实例一

import datetime
mot = ["今天星期一:\n坚持下去,因为我别无选择",
       "今天星期二;\n含泪播种的人一定能笑着收获;",
       "今天星期三;\n做对的事情比事情做对重要;",
       "今天是星期四;\n命运给予我们的不是失望之酒,而是机会之杯",
       "今天是星期五;\n不要等到明天",
       "今天是星期六;\n求知如饥,虚心若愚",
       "今天星期日;\n成功将属于那些从来不说不可能的人"]
day=datetime.datetime.now().weekday()
print(mot[day])

  

 

 实例二

 

 

 

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")

  

实例三

oldlist = ["迈克尔.乔丹","卡里姆 阿布杜尔 贾巴尔","哈基姆 奥拉朱旺","查尔斯 巴克利","姚明"]
newlist = ["贾森 基德","史蒂夫 纳什","格兰特 希尔"]
oldlist.extend(newlist)
print(oldlist)

  

 

实例四

str1 = "千山鸟飞绝"
str2 = "万径人踪灭"
str3 = "孤舟蓑笠翁"
str4 = "独钓寒江雪"
verse = [list(str1),list(str2),list(str3),list(str4)]
print("\n-- 横板--\n")
for i in range(4):
    for j in range(5):
        if j == 4:
            print(verse[i][j])
        else:
            print(verse[i][j],end="")
verse.reverse()
print("\n--竖版---\n")
for i in range(5):
    for j in range(4):
        if j == 3:
            print(verse[j][i])
        else:
            print(verse[j][i],end="")

 

  

 

coffeename = ("蓝山","卡布奇诺","曼特宁","摩卡","麝香猫","哥伦比亚")
print(coffeename)

  

 

 

 实例6

 

coffeename = ("蓝山","卡布奇诺","曼特宁","摩卡","麝香猫","哥伦比亚")
print("你好,欢迎光临,伊米咖啡馆~\n\n我店有:\n")
for name in coffeename:
    print(name + "咖啡",end = " ")

  

 

实例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")

  

 

 

 实例8

coffeename = ("蓝山","卡布奇诺","曼特宁","摩卡","麝香猫","哥伦比亚")
coffeename = ("蓝山","卡布奇诺","曼特宁","摩卡","拿铁","哥伦比亚")
print("新元组",coffeename)

  

 

 实例9

name = ['奇妙','冷伊一','香凝','黛蓝']
sign = ['水瓶座','射手座','双鱼座','双子座']
dictionary = dict(zip(name,sign))
print(dictionary)

  

 

 

 

实例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("香凝")))

  

 

 实例11

name = ["绮梦","伊一","香凝","黛蓝"]
sign = ['水瓶','射手','双鱼','双子']
dictionary = {i:j+'座'for i,j in zip(name,sign)}
print(dictionary)

  

 

 实例12

python = {'绮梦','伊一','香凝','子轩'}
c = {'伊一','零语','子轩','圣博'}
print('选择python语言的学生有:',python,'\n')
print('选择c语言的学生有:',c)

  

 

 

 

python = set(['绮梦','伊一','香凝','子轩'])
python.add('零语')
c = set(['伊一','零语','子轩','圣博'])
c.remove('零语')
print('选择python语言的学生有:',python,'\n')
print('选择c语言的学生有:',c)

  

 

 

python = set(['绮梦', '冷伊一', '香凝', '梓轩'])
c = set(['冷伊一', '零语', '梓轩', '圣博'])
print("选择Python语言的学生有:", python)
print("选择C语言的学生有:", c)
print("交集运算:", python & c)
print("并集运算:", python | c)
print("差集运算:", python - c)

  

 

 

 

print("“王者荣耀“游戏角色:")
print("====坦克:====")
tank = ["苏烈","刘邦","钟馗","张飞","牛魔","程咬金","白起","刘禅","庄周","项羽","廉颇","巨灵神","安禄山","猪八戒"]
for i in tank:
     print(i,end=" ")
print("\n"+"====战士:====")
warrior = ["狂铁","裴擒虎","铠","孙悟空","哪吒","杨戬","橘右京","亚瑟","雅典娜","夏侯惇","关羽","吕布","韩信","老夫子","达摩",
             "典韦","曹操","钟无艳","墨子","赵云","刑天","龙且"]
for i in warrior:
     print(i,end=" ")
print("\n"+"====刺客:====")
assassin = ["百里玄策","庞统","花木兰","靳柯","不知火舞","李白","娜可露露","兰陵王","韩信","宫本武藏","盖聂","红拂"]
for i in assassin:
    print(i,end=" ")
print("\n"+"====法师:====")
master = ["杨玉环","奕星","女娲","周瑜","鬼谷子","芈月","东皇太一","大乔","诸葛亮","貂蝉","张良","安琪拉"]
for i in master:
    print(i,end=" ")
print("\n"+"====射手:====")
shooter = ["公孙离","百里守约","后羿","刘备","黄忠","马可波罗","成吉思汗","虞姬","李元芳","艾琳","狄仁杰","鲁班七号","孙尚香"]
for i in shooter:
    print(i,end=" ")
print("\n"+"====辅助:====")
auxiliary = ["明世隐","梦奇","孙膑","太乙真人","蔡文姬"]
for i in auxiliary:
    print(i,end=" ")

  

 

 实战2

 

information = ["车次", " ", "出发站-到达站", " ", "出发时间", " ", "到达时间"," ","历时"]
train_number = ["T40","T298","T158","Z62"]
destination = ["长春-北京","长春-北京","长春-北京","长春-北京"]
start_time = ["00:12","00:06","12:48","21:58"]
arrival_time = ["12:20","10:50","21:06","08:18"]
time = ["12:08","10:44","08:18","8:20"]
for i in information:
     print(i,end="")     
print("")
print(train_number[0],' ',destination[0],' ',start_time[0],' ',arrival_time[0],' ',time[0],' ')
print(train_number[1],' ',destination[1],' ',start_time[1],' ',arrival_time[1],' ',time[2],' ')
print(train_number[2],' ',destination[2],' ',start_time[2],' ',arrival_time[2],' ',time[2],' ')
print(train_number[3],' ',destination[3],' ',start_time[3],' ',arrival_time[3],' ',time[3],' ')
chufa_chx = dict(zip(train_number,destination))
start_time_chx = dict(zip(train_number,start_time))
arrival_time_chx = dict(zip(train_number,arrival_time))
lishi_chx = dict(zip(train_number,time))
train = input("请输入购买车次:")
passenger = input("请输入乘车人(用逗号分隔):")
achufa = chufa_chx[train]
print("你已购" + train + "次列车" + achufa + "开,请" + passenger + "尽快换取纸质车票。【铁路客服】")

  

 

 

实战3

TV = [("《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 new frontier town》收视率:","0.259%"),
      ("《Distant distance》收视率:","0.394%"),
   ("《Music legend》收视率:","0.562%")]
TV.sort(key=lambda x:x[1], reverse=True)
for item in TV:
    print(item[0] + str(item[1]))
 

  

 

 

实例4

 

print("定制自己的手机套餐:")
call = ["0分钟", "50分钟", "100分钟", "300分钟", "不限量"]
flow = ["0M", "500M", "1G", "5G", "不限量"]
message = ["0条", "50条", "100条"]
print("A.请设置通话时长:")
for i,j in enumerate(call):
    print(str(i+1) + '.' + j)
A = int(input("输入选择的通话时长编号:"))
print("B.请设置流量包:")
for i,j in enumerate(flow):
    print(str(i+1) + '.' + j)
B = int(input("输入选择的流量包编号:"))
print("C.请设置短信条数:")
for i,j in enumerate(message):
    print(str(i+1) + '.' + j)
C = int(input("输入选择的短信条数编号:"))
print("您的手机套餐定制成功:"+ "免费通话时长为" + call[A-1] +
    "/月,"+ "流量为" + flow[B-1] + "/月,"+
    "短信条数" + message[C-1] + "/月")

  

 

 

标签:end,python,train,实验,time,print,dict,第四章
From: https://www.cnblogs.com/3077721976LSQ/p/16719035.html

相关文章

  • 实验2:Open vSwitch虚拟交换机实践
    实验2:OpenvSwitch虚拟交换机实践一、实验目的能够对OpenvSwitch进行基本操作;能够通过命令行终端使用OVS命令操作OpenvSwitch交换机,管理流表;能够通过Mininet的Pytho......
  • 第四章python实训
    shift+win+s局部截图4-1:输出每日一帖4datetime.datetime.now()  获取当前日期datetime.datetime.now().weekday()  获取当前日期的星期  运行结果:  ......
  • 实验2:Open vSwitch虚拟交换机实践
    实验2:OpenvSwitch虚拟交换机实践一、实验目的能够对OpenvSwitch进行基本操作;能够通过命令行终端使用OVS命令操作OpenvSwitch交换机,管理流表;能够通过Mininet的Pyth......
  • 24届实验班周测一听课笔记
    问题1,一元三次怎么十字相乘考研概念性的题f[g(x)]有偶则偶,奇奇复奇奇概念题不要证明,举反例有不确定,读完题选可能对的,拿特例推翻选项看清ln和lg......
  • 实验2:Open vSwitch虚拟交换机实践
    实验2:OpenvSwitch虚拟交换机实践一、实验目的能够对OpenvSwitch进行基本操作;能够通过命令行终端使用OVS命令操作OpenvSwitch交换机,管理流表;能够通过Mininet的Pytho......
  • 实验2:Open vSwitch虚拟交换机实践
    1.基础要求:/home/用户名/学号/lab2/目录下执行ovs-vsctlshow命令p0和p1连通性测试的执行结果截图;/home/用户名/学号/lab2/目录下开启MininetCLI并执行pingall命令......
  • 实验2:Open vSwitch虚拟交换机实践
    一、实验目的能够对OpenvSwitch进行基本操作;能够通过命令行终端使用OVS命令操作OpenvSwitch交换机,管理流表;能够通过Mininet的Python代码运行OVS命令,控制网络拓扑中的O......
  • 实验2:Open vSwitch虚拟交换机实践
    实验2:OpenvSwitch虚拟交换机实践一、实验目的能够对OpenvSwitch进行基本操作;能够通过命令行终端使用OVS命令操作OpenvSwitch交换机,管理流表;能够通过Mininet的Pytho......
  • 实验1:SDN实验拓扑
    一、实验目的能够使用源码安装Mininet;能够使用Mininet的可视化工具生成拓扑;能够使用Mininet的命令行生成特定拓扑;能够使用Mininet交互界面管理SDN拓扑;能够使用Python......
  • 实验2:Open vSwitch虚拟交换机实践
    实验2:OpenvSwitch虚拟交换机实践一、实验目的能够对OpenvSwitch进行基本操作;能够通过命令行终端使用OVS命令操作OpenvSwitch交换机,管理流表;能够通过Mininet的Pytho......