• python 从入门到实践第七章课后题


    '''7-1'''
    car = "请问你需要租约什么品牌的汽车"
    cat=''
    while cat != 'quit':
    cat = input(car)
    print("我去查询下,是否还有" + cat + "的汽车。")

    '''7-2'''

    number = "请问你几位用餐"

    while number:
    ressen=int(input(number))
    if ressen > 8 :
    print("没有空座")
    else:
    print("有空座")


    '''7-4'''

    pizz = "请输入要想添加的配料"
    pizz += " 请输入quit退出"

    while True:
    info = input(pizz)
    if info == 'quit':
    break
    else:
    print("我们将在您的披萨中添加" + info)



    '''7-5'''

    mes = "请输入你的年纪"

    while mes :
    info = int(input(mes))
    if info < 3 :
    print("免费")
    elif info >3 and info <=12 :
    print("5元")
    else:
    print("10元")

    """
    """
    '''7-8'''
    sandwich_orders = ['s1','s2','s3']
    finished_sandwiche = []

    while sandwich_orders:#判断条件为真
    for i in sandwich_orders:
    print("I made your tuna sandwich : " + i)
    sandwich_orders.pop()
    finished_sandwiche.append(i)
    print(finished_sandwiche)

    '''7-9'''

    sandwich_orders = ['s1','pastrami','s2','pastrami','s3','pastrami']

    print("五香牛肉卖完了")
    while 'pastrami' in sandwich_orders:#判断一个条件如果在列表中
    sandwich_orders.remove('pastrami')#用.remove自定元素名称来删除
    print(sandwich_orders)
    """

    '''7-10'''

    local = {}#定义一个空的字典

    names = "请输入你的姓名"
    mesinfo = "如果让你去度假你希望去哪里"
    Active = True #定义一个标志为真

    while Active == True :#给while 条件
    name = input(names)
    city = input(mesinfo)
    local[name] = city#用字典的方法把获取到用户的值写进字典中
    cn=input("是否在接受调查 Y/N")
    if cn.lower() == 'n':
    Active = False#标志设置为假
    #print(local)

    print("调查的结果为:")
    for a , b in local.items():#用for 循环遍历字典
    print(a+"希望去"+b)
  • 相关阅读:
    网站安全策略
    防止表单重复提交的几种策略
    Laravel5中防止XSS跨站攻击的方法
    PHP + ORACLE 远程连接数据库环境配置
    iview table表格内容为数组或者对象的子元素时问题讨论
    jquery中 $(xxx).each() 和 $.each()的区别,以及enter键一键登录
    vue.js 强行赋值、刷新数组或者对象 方法之 $.set()
    vue 组件,以及组件的复用
    vue 和 jquery混合使用
    JS清除空格之trim()方法
  • 原文地址:https://www.cnblogs.com/upuser/p/13177961.html
Copyright © 2020-2023  润新知