निम्नलिखित का आउटपुट क्या है?
What is the output of the following ?
t=(2, 3, 4, 3.5, 5, 6)
print(sum(t) + t.count(2)) A
24
B
23.5
C
24.5
D
25.5
Explanation
Let's break down the code and understand it step by step:
Given:
t = (2, 3, 4, 3.5, 5, 6)
-
sum(t): This function will return the sum of all the elements in the tuple
t.- 2 + 3 + 4 + 3.5 + 5 + 6 = 23.5
-
t.count(2): This function will count how many times the number
2appears in the tuplet.- The number
2appears once in the tuple.
- The number
-
Now, we add these two results:
- sum(t) = 23.5
- t.count(2) = 1
So, 23.5 + 1 = 24.5
Thus, the correct answer is (C) 24.5.
Correct Answer: C) 24.5