& python syntax error notes -day01

grammar

  • python syntax, executed from top to bottom, a process will have to stop implementation of the following processes after a condition is met.

  • We must pay attention to the level before the name of each language indent.

  • if...elif...else

  • print('')

print("这个显示输出")
# 三个引号,可以换行
content = '''床前明月光,
疑是地上霜。'''
print(content)
  • while
#循环嵌套
while True:
print('这是第一个循环')
while True:
print('这是第二个循环,需要下面加break,才能中止当前循环,进行第一个循环。')
break
break
#打印1 2 3 4 5 6 8 9 10
count = 1
while count <= 10:
if count != 7:
print(count)
count = count + 1
print('结束')
'''循环打印'''
count = 0
while count >= 0 and count <= 99:
count = count + 1
print(count)
#或者
count = 1
while count <= 100:
print(count)
count = count + 1
  • break # abort the current cycle
#通过break实现1-10打印
count = 1
while True: #如果循环为真
print(count)
if count == 10:
break #如果count等于10则中止当前循环。
count = count + 1
print("结束")
  • continue # continue this cycle if they are not in continue down, return
count = 1
while count <=10:
if count == 7:
count = count + 1 #给count 赋值加1,使其不等于1,方便跳出
continue # 返回循环
print(count)
count = count + 1
  • after a while .... else # is not satisfied while the condition is triggered.

Error notes

  1. python must pay attention to grammar before indentation.
  2. A grammar must be followed to determine the end of the colon.
  3. Analyzing symbols <= not write the equal sign in front of the <number.
  4. Attention to the case, being given as true, it must be True.

Guess you like

Origin www.cnblogs.com/Dtime/p/10954488.html