Python編程作業【第四周】(一)

7-1 rent a car

car = input("What kind of car do you want to rent?")
print("Let me see if I can find you a Subaru")

7-2 order table

people_number = int(input("How many people will have dinner here?"))
if people_number > 8:
    print("No table avaliable")
else:
    print("tables are avaliable")

7-3 10's times

number = int(input("Please input a number: "))
if number % 10 == 0:
    print("The number is times of ten")
else:
    print("The number is not times of ten")

7-4 pizza

msg = ""
judge = True
while True:
    msg = input("please input a burdening: ")
    if msg == "quit":
        break;
    else:
        print("We will add this burdening to the pizza")

7-5 ticket of cinema

age = 0
while True:
    msg = int(input("please input an age: "))
    if msg < 3:
        print("Free")
    elif msg <= 12:
        print("10 dollars")
    else:
        print("15 dollars")

7-7 endless loop

age = 0
while age < 4:
    print ("hello")

7-8 store

sandwich_orders = ["beef", "pork", "vegetable"]
finished_sandwiches = []
while sandwich_orders:
    sandwich = sandwich_orders.pop()
    print("I made your tuna sandwich")
    finished_sandwiches.append(sandwich)
print("All sandwiches have been made")

7-9 pastrami has been out of sale

sandwich_orders = ["beef", "pastrami", "pork", "pastrami", "vegetable", "pastrami"]
while "pastrami" in sandwich_orders:
    sandwich_orders.remove("pastrami")
print (sandwich_orders)
print("All pastrami sandwiches have been deleted")

7-10 dream places

places = []
while True:
    place = input("Where do you want to go? ")
    if place == "quit":
        break
    else:
        places.append(place)
print (places)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章