主要内容:
for循环
while循环
格式化输出(2)
数据统计及记录
#############################################################
1、for循环
(A):
# #one_guess_age
# num_age = 40
# for i in range(3):
# age_input = int(input("input age:"))
# if num_age == age_input:
# print ("OK")
# break
# elif age_input < num_age:
# print("smaller")
# else:
# print("bigger")
# else:
#for循环正常执行则执行else中的内容
# exit("too many attempt")
# print("welcome two")
验证:
F:\Python\Python3\python.exe D:/python培训/our_python/day2/test.py
input age:0
smaller
input age:50
bigger
input age:40
OK
welcome two
(B)
# for i in range(3):
# if i < 2:
# continue
# # continue退出本次循环,继续下一次循环
# else:
# for j in range(10):
# if j<8:
# continue
# # continue退出本次循环,继续下一次循环
# else:
# print(i,j)
验证:
F:\Python\Python3\python.exe D:/python培训/our_python/day2/test.py
2 8
2 9
2、while循环
#while循环
count = 0
oldboy_age=56
while coun