write a program in python to print the sum of all even number from 1 to 50.
Answers
Answered by
0
Answer:
=50(50+1)/2
=50*51/2
=25*50
=1275
Answered by
3
Below are the output and the python program for the above question :
Output :"The Sum of 1 to 50 even number is: 650."
Explanation:
Even=0#variable which holds the sum value.
for x in range(0,51,+2):#For loop which runs from 1 to 50 and access the even number only.
Even=Even+x# It will add the number.
print("The Sum of 1 to 50 even number is: ",Even)#It will prints the sum value of even number.
Code Explanation :
- The above code is in python language which holds one for loop which runs for the value of 1 to 50 with an increment of 2 because increment of 2 will give the even number.
- Then the even variable will add all the value and the sum will be printed with the help of print function.
Similar questions