美文网首页
python从入门到编程习题第7章

python从入门到编程习题第7章

作者: 数据分析历程 | 来源:发表于2020-03-29 11:12 被阅读0次

#7-1汽车租赁

car = input("What car do you like to find?")

print("Let me see if I can find you a " + car)

d

#7-2餐馆订位

num = input("How many people would you like to have dinner?")

num = int(num)

if num > 8:

    print("There is no empty table")

else:

    print("We have a table for you")

#7-3 10的整数倍

num = input("Please Enter a number: ")

num = int(num)

if num % 10 == 0:

    print("Integral multiple of 10")

else:

    print("Not integral multiple of 10")

#7-4披萨配料

q = "What ingredients would you like to add?"

q += "\n Enter 'quit' when you are finished."

pizza = True

while pizza :

    pizza = input(q)

    if pizza == "quit":

        pizza = False

    else:

        print("The " + str(pizza) + "have been added")

#7-5电影票

while True:

    print("Enter 'quit' when you are finished.")

    age = input("How old are you?")

    if age =="quit":

        break

    elif int(age) < 3:

        print("You are Free")

    elif int(age) >=3 and int(age)<12:

        print("The Price of you is 10$")

    else:

        print("The Price of you is 15$ " )

#7-6三个出口

q = "What ingredients would you like to add?"

q += "\n Enter 'quit' when you a finish."

message = ""

while message !="quit":

    message = input(q)

    if message != "quit":

        print("The " + str(message) + " have been added")

message1 = "How old are you?"

message1 += "\n Enter 'quit' when you are finished."

age = True

while age:

    age = input(message1)

    if age == "quit":

        age = False

    elif int(age) < 3:

        print("You are Free")

    elif int(age) >=3 and int(age)<12:

        print("The Price of you is 10$")

    else:

        print("The Price of you is 15$ " )

#7-8熟食店

sandwish_orders=["Bocadillo Sandwich","Arepa Sandwich","Croque Madame Sandwich"]

finished_sandwiches = []

while sandwish_orders:

    current_orders = sandwish_orders.pop()

    print("I made your " + current_orders)

    finished_sandwiches.append(current_orders)

print("All the sandwiches have been finished: " )

for finished_sandwich in finished_sandwiches:

    print(finished_sandwich)

#

相关文章

网友评论

      本文标题:python从入门到编程习题第7章

      本文链接:https://www.haomeiwen.com/subject/vreyuhtx.html