7-3 10的整数倍:让用户输入一个数字,并指出这个数字是否是10的整数倍.
num = int(input('please input a number: '))
if num % 10 == 0:
print("your input number is divided exactly by ten")
please input a number: 20
your input number is divided exactly by ten
>>>
7-5 电影票:有家电影院根据观众的年龄收取不同的票价:不到3岁的观众免费;3~12岁的观众为10美元;超过12岁的观众为15美元. 请编写一个循环,在其中询问用户的年龄,并指出其票价.
while True:
age = int(input('how old are you ? '))
if age < 3:
print('you are free')
elif 3 <= age <= 12:
print('price of your ticket is 10 dollar')
else:
print('price of your ticket is 15 dollar')
>>>
how old are you ? 1
you are free
how old are you ? 2
you are free
how old are you ? 3
price of