#@用户输入与while循环#@while循环
prompt ="\nTell me something, and I will repeat it back to you:"
prompt +="\nEnter 'quit' to end the program. "
message =""while message !='quit':
message =input(prompt)if message !='quit':print(message)#@使用标志
prompt ="\nTell me something, and I will repeat it back to you:"
prompt +="\nEnter 'quit' to end the program. "
action =Truewhile action:
message =input(prompt)if message =='quit':
action =Falseelse:print(message)#@使用break退出循环"
prompt ="\nPlease enter the name of a city you have visited"
prompt +="\n(Enter 'quit' when you are finished.) "whileTrue:
city =input(prompt)if city =='quit':breakelse:print("I'd love to go to "+ city.title()+"!")#@在循环中使用continue
current_number =0while current_number <10:
current_number +=1if current_number %2==0:continueprint(current_number)'''
@@@
有家电影院根据观众的年龄收取不同的票价:不到3岁的观众免费;3~12岁的观众为10美元;超过12岁的观众为15美元。请编写一个循环,在其中询问用
户的年龄,并指出其票价。
在while 循环中使用条件测试来结束循环。
使用变量active 来控制循环结束的时机。
使用break 语句在用户输入'quit' 时退出循环。
@@@
'''
active =Truewhile active:print("Enter 'quit' when you are finished.")
age =input("请输入你的年龄:")if age =='quit':
active =Falseelifint(age)<3:print("The price of you is free.")elif3<=int(age)<12:print("The price of you is $10.")elif12<=int(age):print("The price of you is $15.")