7-1 汽车租赁
car=input('what kind of cars do you want?')
print("let's me see if i can find you a ",car)
输出
PS C:\Users\wula\Desktop\大二下课程\高编\python_work> python .\第七章.py
what kind of cars do you want?Subaru
let's me see if i can find you a Subaru
7-3 10的整数倍
num=input("please enter a number: ")
num=int(num)
if num%10 == 0:
print('this number is an integer multiple of 10')
else:
print('this number is not an integer multiple of 10')
输出
PS C:\Users\wula\Desktop\大二下课程\高编\python_work> python .\第七章.py
please enter a number: 25
this number is not an integer multiple of 10
PS C:\Users\wula\Desktop\大二下课程\高编\python_work> python .\第七章.py
please enter a number: 20
this number is an integer multiple of 10
7-5 电影票
i=0
while i<3:
i=input('how old are you? ')
i=int(i)
if i<3:
print('the ticket price is free.')
elif 3<= i<=12:
print('the ticket price is 10 dollar.')
else:
print('the ticket price is 15 dollar.')
i += 1
输出
PS C:\Users\wula\Desktop\大二下课程\高编\python_work> python .\第七章.py
how old are you? 16
the ticket price is 15 dollar.
PS C:\Users\wula\Desktop\大二下课程\高编\python_work> python .\第七章.py
how old are you? 11
the ticket price is 10 dollar.
7-8 熟食店
sandwichs = ['potato','apple','pear']
finished_sandwich=[]
while sandwichs:
sandwich= sandwichs.pop()
print("i made ",sandwich,"sandwich.")
finished_sandwich.append(sandwich)
for temp in finished_sandwich:
print(temp)
输出
i made pear sandwich.
i made apple sandwich.
i made potato sandwich.
pear
apple
potato