Python Program to Add All Numbers up To n using For loop

Python Program to Add All Numbers up To n using For loop

Write Python Program to Add All Numbers up To n using For loop

# Write Python Program to Add All Numbers up To n using For loop (1 + 2 + 3 + …. + n)

n = 10
Sum = 0
for i in range(1, n + 1):
    Sum = Sum + i
    
print(f'Sum of first {n} number : {Sum}')

Output:

Sum of first 10 number : 55