car = input("What car do you want: ")
print("Let me see if I can find you a " + car)
What car do you want: YanBin
Let me see if I can find you a YanBin
习题7-3
n = input("Input an integer: ")
n = int(n)
if (n % 10):
print("not 10 de zheng shu bei")
else:
print("10 de zheng shu bei")
africamonkey@africamonkey-yoga:~/Downloads$ python3 a.py
Input aninteger: 1010 de zheng shu bei
africamonkey@africamonkey-yoga:~/Downloads$ python3 a.py
Input aninteger: 5not10 de zheng shu bei
习题7-4
active = Truewhile active:
message = input("pei liao: ")
if message != "quit":
print(message)
else:
active = False
pei liao: yan
yan
pei liao: tang
tang
pei liao: shui
shui
pei liao: quit
习题7-8
sandwich_orders = ['pastrami', 'beef', 'pork', 'chicken']
finished_sandwiches = []
while sandwich_orders:
sandwich = sandwich_orders.pop()
print("I made your " + sandwich + " sandwich")
finished_sandwiches.append(sandwich)
print("I made ", end="")
for sandwich in finished_sandwiches:
print(sandwich + ', ', end="")
print("")
I made your chicken sandwich
I made your pork sandwich
I made your beef sandwich
I made your pastrami sandwich
I made chicken, pork, beef, pastrami,