Computer Science
Which of the below given functions cannot be used with nested tuples ?
- index( )
- count( )
- max( )
- sum( )
Python Tuples
7 Likes
Answer
sum( )
Reason — For sum( ) function to work, the tuple must have numeric elements. Since nested tuples will have at least one element as tuple so the sum( ) function will raise a TypeError and will not work.
Answered By
2 Likes
Related Questions
What is the output of the following code ?
t = (10, 20, 30, 40, 50, 50, 70) print(t[5:-1])
- Blank output( )
- (50,70)
- (50,50,70)
- (50,)
What is the output of the following code?
t = (10, 20, 30, 40, 50, 60, 70) print(t[5:-1])
- Blank output( )
- (10, 20, 30, 40, 50)
- (10, 30, 50, 70)
- (10, 20, 30, 40, 50, 60, 70)
Fill in the blanks:
Tuples are _________ data types of Python.
Fill in the blanks:
A tuple can store values of _________ data types.