- In which of following brackets use in tuple ?
- []
- {}
- ()
- ''
- Which of the following is true about tuples in Python ?
- Tuples are mutable.
- Tuples are enclosed in square brackets.
- Tuples can contain elements of different data types.
- Tuples have no specific order.
- What is the correct way to create an empty tuple ?
- empty_tuple = []
- empty_tuple = ()
- empty_tuple = {}
- empty_tuple = None
- What will be the output of the following code ?
my_tuple = (1, 2, 3, 4, 5)
result = my_tuple[2:4]
print(result)
- (1, 2)
- (3, 4)
- (2, 3)
- (3, 4, 5)
- Solve the code :
tu = (1,2,3,4,5)
tu[0]= 0
print(tu)
- (0,2,3,4,5)
- (0,1,2,3,4,5)
- (0)
- Error
- What will be the output of following code ?
tu = (1,2,3,4,5)
t2=tu[::-1]
print(t2)
- (1, 2, 3, 4)
- (5, 4, 3, 2, 1)
- (1, 2, 3, 4,5)
- Error
- Solve the code :
tu = (1,2,3,4,5)
t2=tu[1:-1]
print(t2)
- (1, 2, 3, 4)
- (5, 4, 3, 2, 1)
- (2, 3, 4)
- Error
- What will be the output of following code ?
tu = ("hello")
print(type(tu))
- <class 'str'>
- <class 'tuple'>
- <class 'list'>
- <class 'chr'>
- Which of the following methods can be used to find the number of occurrences of a specific element in a tuple ?
- count()
- find()
- occurrences()
- search()
- Solve the given code :
tu = (5,1,2)
print(max(tu))
- 2
- 1
- 0
- 5
- Solve the given code :
tups = (5,1,2)
print(sum(tups,2))
- 6
- 8
- 10
- Error
- What will be the output of given code ?
tups = (5,1,2)
del(tups)
print(tups2)
- ()
- blank
- Error
- None of above
- What will be the output of following code ?
tuples = ('Spark','Python','Java','C','Ruby')
stop = 2
slice1 = tuples[slice(stop)]
print(slice1)
- ('Spark','Python','Java','C','Ruby')
- ('Spark','Python','Java')
- ('Spark', 'Python')
- Error
- Output of following code :
a,b,c=(2,3),(1,4),(2,2)
print(b)
print(type(b))
- (1, 4) and <class 'tuple'>
- (1, 4) and <class 'string'>
- (1, 4) and <class 'list'>
- Error
- Solve the given code :
a=1,
print(type(a))
- <class 'tuple'>
- <class 'string'>
- <class 'list'>
- <class 'int'>