Python Practice › Function Programs › Program 16
Sum from 0 to n
Write a Python function to calculate the sum of numbers from 0 to 10.
Output
55
Approach
sum(range(n + 1)).
Solution
def sum_to(n=10): return sum(range(n + 1)) print(sum_to())Output
55
Learn the concept
New to this topic? Read the lesson, then come back.