sum=0 for i in range(100,501): if(i%2==0): sum=sum+i print("Sum of number 100 to 500 -", sum)
Explain : Step 1: Declare a variable which store 0 and name assign sum. Step 2: Start a loop set range (100,501), Start value-100 and stop value- 500. Step 3: Set condtion i %2 means number divide by 2 remainder 0 means this number divide by 2. Step 4: The number divide by 2 is add in varaible sum. Step 5: print the sum variable value.