(adsbygoogle = window.adsbygoogle || []).push({ google_ad_client: "ca-pub-2960223314593660", enable_page_level_ads: true }); Python program to print even numbers between 1 to 100. - TecGlance

Header Ads

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

2 comments:

  1. What is the use of num = num + 1 here?

    ReplyDelete
    Replies
    1. Thanks for pointing it out. Its not needed. Python range automatically iterates in its range with a step of 1 (default).

      Delete

Powered by Blogger.