好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

python学习日记(1)

之前学习了Alex的python教程Alex的教学真的非常棒,也很幽默。嘿嘿。希望自己可以坚持下去。

while count <3:
guess_number = int(input("guess_number_of_kids:"))
if guess_number == number_of_kids:
print("yep,you got it!")
break
elif guess_number> number_of_kids:
print("think smaller...")
else:
print("think bigger...")

count+=1
if count==3:
countine_confirm = input("do you want keeping guessing...?")
if countine_confirm !="n": 若是按下n则表示退出游戏
count =0 当按下回车键后表明还想玩,则程序继续执行。

task: 单独打出这段代码,理清思路。

新知识点: continue

for i in range(0,10):
if i<3:
print("loop",i)
else:
continue
print("hehe"..)

执行结果 :=== RESTART: C:/Users/dell/AppData/Local/Programs/Python/Python35-32/4.py ===
loop 0
hehe...
loop 1
hehe...
loop 2
hehe...

后来加断点???啥意思?
for i in range(0,10):
if i<3:
print("loop",i)
else:
continue(作用是跳出本次循环,进入下一次循环)
print("hehe"..)
问: 同样代码 却没有hehe?


新知识点:双循环

for i in range(10):
print("________",i)
for j in range(10):
print(j)
执行结果:
=== RESTART: C:/Users/dell/AppData/Local/Programs/Python/Python35-32/4.py ===
________ 0

以上就是python学习日记(1)的详细内容,更多请关注Gxl网其它相关文章!

查看更多关于python学习日记(1)的详细内容...

  阅读:42次