《Python编程-从入门到实践》课后习题(7)

7-1

car = input('What kind of car do you want?\n')
print('Let me see if I can find you a '+car)

7-2

seats = input('How many seats do you want?\n')
seats = int(seats)
if seats>8:
    print('No suitable tables')
else:
    print('There is a available table')

7-3

num = input('Input a number: ')
if int(num)&10:
    print('The number '+num+" isn't 10's multiple")
else:
    print('The number '+num+" is 10's multiple")

7-4

thing = input('What do you want to add in the pizza?\n')
while thing!='quit':
    print('We will add '+thing+' to the pizza.\n')
    thing = input('What else do you want to add?\n')

7-5

age = input('How old are you?: ')
if int(age)<3:
    print('You age is '+age+' and you are free')
elif int(age)>=3 and int(age)<=12:
    print('You age is '+age+' and you need pay $10')
elif int(age)>12:
    print('You age is '+age+' and you need pay $15')

7-7

while True:
    i = 1

7-8

sandwich_orders = ['A', 'B', 'C']
finished_sandwichs = []
while sandwich_orders:
    sandwich = sandwich_orders.pop()
    print('I made you '+sandwich)
    finished_sandwichs.append(sandwich)

7-9

sandwich_orders = ['A', 'B', 'C', 'pastrami', 'pastrami', 'pastrami']
print('Pastramis are sold out')
while 'pastrami' in sandwich_orders:
    sandwich_orders.remove('pastrami')
finished_sandwichs = []
while sandwich_orders:
    sandwich = sandwich_orders.pop()
    print('I made you '+sandwich)
    finished_sandwichs.append(sandwich)

7-10

destis = []
message = ''
while message!='quit':
    message = input('If you could visit one place in the world, where would you go?\n')
    destis.append(message)
print('The result is:')
for  desti in destis:
    print(desti)

猜你喜欢

转载自blog.csdn.net/wanghj47/article/details/79693171
今日推荐