write a program that prints even numbers 2 through 20 using a while loop.

write a program that prints even numbers 2 through 20 using a while loop.

write a program that prints even numbers 2 through 20 using a while loop.

Answer

Explanation:

Step1: Initialize variable

Let num = 2 as the starting even - number.

Step2: Set up the while - loop condition

The loop should continue as long as num <= 20. while num <= 20:

Step3: Print the number

Print the current even number. print(num)

Step4: Increment the number

Increment num by 2 to get the next even number. num = num + 2

Here is the complete Python code:

num = 2
while num <= 20:
    print(num)
    num = num + 2

Answer:

num = 2
while num <= 20:
    print(num)
    num = num + 2