1. While loop
while condition: code block (loop body) execution Flow: 1. Determine if the condition is true. If it's true. Executes the code block 2. Judge again whether the condition is true ... 3. When the condition is false. Execute else jumps out of the loop. The loop ends with an example of a few simple while loops: (1): The sum of the numbers within 1~100: num = 1 sums = 0 While num <= 100:sum = sum + num num + = 1 print (sum) (2): 1-2+3-4.......99 so the sum of the numbers: num = 1 sum = 0 while num < 100:if num% 2 = = 0:sum = sum-num if num% 2! = 0:sum = sum + num num + = 1 print (sum) 4. break end loop. Stops the current loop 5. continue ends the current cycle. Continue with the next loop &nBsp 2. Formatted output %s: A placeholder for a string that can place any content (number) A for the variable format as follows: print ("haha haha%s"% a)   ; %d: Placeholder for numbers (IBID.) 3. Operators logic operations: and and the meaning. Both left and right values must be true. The result of the operation is true or or meaning. The left and right sides have one that is true. The result is true. All is false. The result can be false not non-meaning. It turned out to be false. Now is true . not true or false, not false both true
Python learning [day2]while loop and execution flow, formatted output, operator