Python function test error record 2

1. Only one statement block will be executed among multiple statement blocks of if...elif...else?

正确

2. In Python, for and while can have else statements?

forwhile 都可以有 else 语句。

3. What is the output result of the above code?

for i in [1, 0]:
    print(i+1)
21

4. What is the output of the following code?

while 4 == 4:
    print('4')
无限次输出 4,直到程序关闭。

5. Which of the following descriptions is correct?

A.break 语句用于终止当前循环。
B.continue 语句用于跳过当前剩余要执行的代码,执行下一次循环。
C.break 和 continue 语句通常与  if, if...else 和 if...elif...else 语句一起使用。

6. What is the output of the following code?

for char in 'PYTHON STRING':
  if char == ' ':
      break

  print(char, end='')
  
  if char == 'O':
      continue
PYTHON

Guess you like

Origin blog.csdn.net/qq_46009608/article/details/110005356