China Naming Network - Company naming - How to use python to output odd and even numbers within 100?

How to use python to output odd and even numbers within 100?

In Python, you can use loop statements and conditional statements to output even numbers from 0 to 100. The following are sample codes for several implementations:

Using a for loop and an if conditional statement:

Please click to enter a picture description.

Using while loops and if conditional statements:

Please click to enter a picture description.

Both methods loop through all numbers from 0 to 100, and judge whether the current number is even (that is, whether it can be divisible by 2) with an if conditional statement, and if so, output it. It should be noted that the range function range () is used here, which can generate an integer sequence with a starting value of 0 and an ending value of 100 (excluding), and the step size is 1 by default.