Explanation:
๐น Step 1: Create List
x = [1,2,3]
A list x is created
๐ Values inside list: 1, 2, 3
๐น Step 2: Understand sum() Function
sum(x, 5)
sum() adds all elements of an iterable
Syntax:
sum(iterable, start)
๐ Here:
iterable = [1,2,3]
start = 5 (initial value)
๐น Step 3: Perform Calculation
๐ First add all elements:
1 + 2 + 3 = 6
๐ Then add start value:
6 + 5 = 11
๐น Step 4: Print Output
print(sum(x, 5))
๐ Output:
11

0 Comments:
Post a Comment