第七章部分习题
课本:《Python编程 从入门到实践》
环境:Python 3.6.2
下面只写部分习题(大多都十分简单)
代码:
#7-1 print("#7-1") car=input('Which car do you want to rent?\n') print("Let me see if I can find you a Subaru") #7-2 print('#7-2') people_num=input("How many people dine?\n") if people_num.isdigit(): people_num=int(people_num) if people_num>8: print("There is no suitable table for you") else: print("There is a available table") #7-3 print("#7-3") num=input("Please input a integer\n") if num.isdigit(): num=int(num) if num%10==0: print("An integer multiple of 10") else: print("No an integer multiple of 10") #7-4 print("#7-4") while True: ingredient=input("Please input Pizza ingredients (quit to end the loop)\n") if ingredient=="quit": break; else: print("We will add",ingredient,"to pizza") #7-5 print("#7-5") while True: age=input("How old are you? (q to quit)\n") if age=="q" : break age=int(age) if age<3: print("Free") elif age<=12: print("10 dollars") else: print("15 dollars")
结果: