Write a program in python to print sum of 1 to 50 numbers.
Answers
Answered by
36
BY USING FOR LOOP
sum=0
for i in range (51):
sum=sum+i
print("sum of number is",sum)
---------------------------------------------⬆⬆❣❣
.
.
mark it and follow me dude✌✌
Answered by
7
Below are the Output and the python program for the above question :
Output: "The Sum of 1 to 50 number is: 1275"
Explanation:
Sum=0#variable which holds the sum value.
for x in range(1,51):#For loop which runs from 1 to 50 and access the number.
Sum=Sum+x# It add the number.
print("The Sum of 1 to 50 number is: ",Sum)#It will prints the sum value of all the numbers.
Code Explanation :
- The above code is in Python language, which holds one for loop which runs for the value of 1 to 50.
- Then the sum variable holds the total by adding the previous value to the new value and then it will be printed with the help of a print statement.
Learn More ;
- Python program : https://brainly.in/question/12744042
Similar questions
Geography,
5 months ago
Social Sciences,
5 months ago
Math,
10 months ago
History,
10 months ago
Math,
1 year ago