Monday, 30 March 2026

Print the Sum of Number in range in python

 #Print the Sum of Number in range
#0,1,2,3,4,5,6,7,8,9,10
#0+1+2+3+4+5+6+7+8+9+10=55
num=int(input("Enter a number: "))
print(sum(i for i in range(1,num+1)))#--->Logic

No comments:

Post a Comment

Print the Sum of Number in range in python

 #Print the Sum of Number in range #0,1,2,3,4,5,6,7,8,9,10 #0+1+2+3+4+5+6+7+8+9+10=55 num=int(input("Enter a number: ")) print(sum...