Python program to print even numbers between 1 to 100.
Python program to print even numbers between 1 to 100.
Algorithm:::
Step 1: Start
Step 2: Repeat steps 3,4&5 until num=100 reaches
Step 3: If num%2==0 goto step 4
Step 4: Print num
Step 5: Compute num=num+1
Step 6: Stop
Flowchart:::
Program code:::
for num in range(1,100):
if num%2==0:
print num
num=num+1
if num%2==0:
print num
num=num+1
What is the use of num = num + 1 here?
ReplyDeleteThanks for pointing it out. Its not needed. Python range automatically iterates in its range with a step of 1 (default).
Delete