python 学习day five
2019-09-07 21:14 叫我永康就好啦 阅读(107) 评论(0) 收藏 举报1、代码学习部分
car=input("What kind of cars you want to rent?")
print("Let me see if I can find you a "+car)
number=input("How many people?")
number=int(number)
if number > 8:
print("There are no extra table")
else:
print("There have table")
number1=input("please input a number:")
number1=int(number1)
if number1%10 == 0:
print("This number is integral multiple the 10.")
else:
print("This number is not integral multiple the 10.")
prompt="please order your dosing:"
prompt+="\nplease input quit to finish."
while True:
dosing=input(prompt)
if dosing == "quit":
break
else:
print("we will add "+dosing+" in pizza.")
while True:
age = input("please tell me your age:\nplease input quit to finish.")
if age == "quit":
break
age = int(age)
if age<3:
print("you are free.")
break
elif age <12:
print("you need pay 10 dollars.")
else:
print("you need pay 15 dollars.")
#发生错误:在输入quit时,发生错误:nvalid literal for int() with base 10: 'quit' 怎么破解? 问晨哥。
active = True
while active:
age = input("please tell me your age:\nplease input quit to finish.")
if age == "quit":
active = False
age = int(age)
if age <3:
print("you are free.")
break
elif age <12:
print("you need pay 10 dollars.")
else:
print("you need pay 15 dollars.")
#无限循环 : 快捷键ctrl+C 结束
while True:
print("zyk is so smart.")
sandwich_orders=["jack","lucy","tuna"]
finished_sandwiches=[]
while sandwich_orders:
current_sandwiches=sandwich_orders.pop()
print("I made your "+current_sandwiches+" sandwich")
finished_sandwiches.append(current_sandwiches)
print("I have made these sandwich for you:")
for sandwich in finished_sandwiches:
print(sandwich)
sandwich_orders=["pastrami","jack","pastrami","lucy","pastrami","tuna"]
print("Pastrami have been sold out.")
while "pastrami" in sandwich_orders:
sandwich_orders.remove('pastrami')
print(sandwich_orders)
2、学习心得与疑问
2.1、数字用引号括起来,代表计算机将它当作字符串,不能将数字与字符串进行比较,否则会发生错误
2.2、将数值输入用于计算和比较前,务必将其转换为数值表示
2.3、多行代码快速注释:Ctrl+/
2.4、\n 换行符的用法:要放在引号中
2.5、在列表里单引号‘’与双引号”“可以混合用吗?
答:可以
浙公网安备 33010602011771号