第二天知识点

while循环

while条件:

  代码块

  判断代码块 =="某某内容"

  break     #停止当前循环

  继续判断

  print(打印)

  continue   #停止当前循环,继续执行下次循坏

格式化输出

print(%s今年%s岁,爱好是%s,性别是%s % (      ))

%s   字符串的占位符, 可以放置任何内容

%d   数字的占位符

运算符(逻辑运算)

and 并且的意思    两真为真

or  后者的意思    一真为真    全假为假

not 非得意思     非假既真  非真既假

 


count = 1
while count <= 10:
print( count)
count = count + 1
if count == 5:
break # 彻底停止循环. 不会执行后面的else
else: # while条件不成立的时候执行
print("这里是else")

猜你喜欢

转载自www.cnblogs.com/xiaole-7890/p/9273915.html