We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 17
ih
Python Tuples MCQs
Python Tuples MCQs: This section contains multiple-choice questions and answers on Python
Tuples. These MCQs are written for beginners as well as advanced, practice these MCQs to
enhance and test the knowledge of Python Tuples,
List of Python Tuples MCQs
1. What do you mean by python tuples?
‘A. An immutable type of data type which can store anything
B. A mutable type of data type which can only store string
C. An immutable type of data type which can store only stored string
D. A mutable type of data type which can only store numbers
Answer: A) An immutable type of data type which can store anything.
Explanation:
A tuple is the immutable nature of data type which can store anything i.e, numbers, strings,
characters, etc.
7 \
Discuss this Question
2. Python tuples are IMMUTABLES. What does this statement mean?
A. An immutable nature of python tuples states that it allows us to store the element at the
creation time only
B. An immutable nature of python tuples states that it allows us to store the data whenever
we want after its creation
Answer: A) An immutable nature of python tuples states that it allows us to store the element
at the creation time only.
Explanation:‘An immutable nature of python tuples states that it allows us to store the element at the
creation time only.
Discuss this Question )
\ )
3. In python tuples, different elements are separated by which symbol?
A:
B.,
c:
D. None of the above
Answer: B) ,
Explanation:
In python tuples, elements are separated by a comma (, ) symbol.
Discuss this Question )
ee
4, What is the nature of the python tuples data type?
A. In python, tuples are of ordered nature
8. In python, tuples are of unordered nature
Answer: B) In python, tuples are of unordered nature.
Explanation:
In python, tuples are of ordered nature.
Discuss this Question )
5. What do you mean by the ordered nature of python tuples?
A. The ordered nature of tuples indicates that you can only store the data in sequence
B. The ordered nature of tuples indicates that the items are retained in the order in which
they are insertedC. The ordered nature of tuples indicates that the elements which you will put after the
creation of the tuples will be added from the last index
D. The ordered nature of tuples indicates that the elements which you will put after the
creation of the tuples will be added from the first index
Answer: B) The ordered nature of tuples indicates that the items are retained in the order in
which they are inserted
Explanatio!
The ordered nature of tuples indicates that the items are retained in the order in which they are
inserted
6. Can you create a single-element tuple?
A. Yes
B. No
Answer: A) Yes
Explanatior
To create a single-element tuple you have to write an element inside parentheses and after the
element, you have to put the comma. For example T= (98,) will create a single element tuple.
Discuss this Question )
/
7. |s it possible to create an empty tuple?
A. Yes
B. No
Answer: A) Yes
Explanation:
Yes, you can create an empty tuple. For example, T=() .6 \
Discuss this Question )
_— /
8. Is parentheses important to store elements inside a tuple?
A. Yes
B. No
Answer: B) No
Explanatio!
No, parentheses are not important to store elements inside a tuple. But it is suggested to use
parentheses when storing elements of the tuple.
Discuss this Question )
—— /
9. Which of the following will show an error when creating a tuple?
ram", “hello"," include help"
ram’
C.T1=(‘ram")
D. Three of them are correct
Answer: C) T1=("ram")
Explanation:
Among the given options, the third option is wrong. As to create a single element you have to
put a comma after the element, else it would be a challenging job.
Discuss this Question )
10. What will be the output of the following code?
tuple1 = ("tuple")
print (type(tuple1))
A.
B. C. Error
Answer: A)
Explanation:
If you will create a single element tuple without a comma it will be considered a string.
Discuss this Question )
11. To access the element of a tuple through indexing which symbol is used?
Ag
8.0
C0
D. None
Answer: B) []
Explanation:
To access the elements of a tuple through indexing we have to use square brackets [].
\
Discuss this Question )
/
12. What will be the output of the following code,
T1=(“hello”, "everyone", "include helps”, "welcomes", "you", all")
print (T1[@],T1[-2])
A. Hello
B. Hello all
C. Hello you
D. Error
Answer: C) Hello you
Explanation:
“Hello you" will be the output.cr »
Discuss this Question )
\ /
13. Do tuples follow the concept of negative indexing?
A. YES
B.NO
C.In special conditions only
‘Answer: A) YES
Explanation:
Yes, tuples also follow the concept of negative indexing.
Discuss this Question )
XY /
14, What do you mean by negative indexing?
A. Negative indexing in python helps us to traverse the list from the end
B. Negative indexing in python helps us to traverse the list from the starting
C. There is no such thing as negative indexing in python
‘Answer: A) Negative indexing in python helps us to traverse the list from the end.
Explanation:
Negative indexing in python helps us to traverse the list from the end.
r >
Discuss this Question )
15. Can you create a tuple inside a tuple?
A. Yes
B. No
Answer: A) Yes
Explanation:We can create a tuple inside a tuple.
Discuss this Question )
16. What will be the output of the following code?
T1=(“hello", "include help", -1)
print(T1[-2])
A Error
B. Hello
c-1
Answer: c) -1
Explanation:
Negative index will access the element from the last element there -1 index means the last
element of the tuple which means -1 is the answer.
Discuss this Question )
17. What will be the output of the following code?
Ta=(“hello”, [1,2,3,4], "Namastey", "Bonjour"))
print(T1[1])
A. Hello
B.1
C.11,2,3,4]
D. 1,2,3,4
ol>
Answer: C) [1,2,3,4]
Explanation:
Since the index 1 list is started so all the elements of the list will be printed.»
Discuss this Question )
/
18. If you are writing a single element inside parentheses in double quotations what it
will be considered as?
A. String
B, Tuple
C. List
Answer: A) String
Explanation:
If you will write a single element in double quotation inside parentheses it will be considered a
string data type.
Discuss this Question )
XY S
19. Will it be considered a tuple?
Tis “include help",
print (type(T1))
A. Yes
B. No.
C.It will show you the error
Answer: A) Yes
Explanatio!
Yes, it will be considered a tuple as a comma is inserted after the first element.
Discuss this Question )
\ )
20. Will the fourth index element will be included in the result?
Suppose you have the following code,t1=("hello","everyone","include helps”, "welcomes", "you","al1")
print (t1[2:4])
A. Yes
B. No
Answer: B) No
Explanation:
No, the fourth index element will not be included in the result, as the slicing operator only
works for the end-1 index, that means in this case it will work only till the third index.
Discuss this Question )
—— /
21. What will be the output of the following code?
t1=("hello","everyone","include helps", "welcomes", "you", "all")
print (t1[2:4])
welcomes", "you")
welcomes")
B. ("everyone’, "include helps
C. (‘include helps" ," welcomes")
Answer: C) ("include helps" ," welcomes")
Explanation:
The result would be: ("include helps" ," welcomes") , because indexing starts from 0.
Discuss this Question }
22. In python tuples, what is the syntax of the slicing operator?
A. Tuple[startend]
B. Tuple(start:end:steps]
c.onlyA
D. Only B
E, Both A and BAnswer: £) Both A and B
Explanation:
Both Tuple[start:end] and Tuple[start:end:steps] are the correct syntaxes of the slicing
operator in python tuples.
Consider the following example:
Copy
tpl = (10, 20, 30, 40, 58)
print(tpl) # Prints (10, 28, 30, 40, 58)
print(tpl[@:5]) # Prints (10, 20, 30, 48, 50)
print(tpl[@:5:2]) # Prints (10, 30, 5@)
Discuss this Question }
ee
23. What will be the output of the following code?
T1=(88,99,77,11,22,33,44)
print([:])
A. Entire tuple will be printed
B. Tuple will be printed in reverse order
C. the Same tuple will be printed
D. It will show you the error
Answer: A) Entire tuple will be printed
Explanation:
Entire tuple will be printed
Discuss this Question }
\ )
24. Which function is used to delete the particular element of the tuple?
A. Remove()
B. Deleted)C. Del)
D. Itis not possible to delete the particular element of the tuple
Answer: D) It is not possible to delete the particular element of the tuple
Explanation:
Since tuples are immutable, therefore you can not delete a particular element from the tuple.
Discuss this Question )
\ /
25. Which keyword is used to delete the entire tuple?
A. Remove
B. Delete
C. Del
Answer: C) Del
Explanation:
The del keyword will delete the entire tuple.
\
Discuss this Question )
/
26. What will be the output of the following code?
ti=("hello","everyone","include helps", "welcomes", "you","al1l")
del t1
print (t1)
A. name 't1' is not defined
B, ("hello", "everyone",
C. Hello, everyone, include helps
‘include helps","welcomes","you","all")
Answer: A) name 't1' is not defined
Explanation:Since the del t1 command is there so it will delete the entire t1 tuple so when you will print
the t1 it will show you the- name 't1' is not defined.
Discuss this Question )
\ /
27. Which python function will get you the size of the python tuple?
A. size)
B. len()
C.lening
D. list_len
Answer: B) len()
Explanatio1
The Len(), function will give you the total number of elements present in the tuple.
Discuss this Question )
28. What will be the syntax to use the Len function to get the size of the following tuple?
ti=(["hello",1,2,3], [ You"])
everyon
How"," Are’
A. print(len(t1))
B. print (len[t1])
C. print([len(t1)])
Answer: A) print (len(t1))
Explanation:
To get the size of any tuple we will use the following syntax: - print(len(t1)), where t1 is
the name of the tuple.
Discuss this Question )
29. What will be the size of the following tuple?t1=(["hello",1,2,3], ["Hi"," everyone"," How," Are"," You"])
AQ
B.3
cs
D.2
Answer: D) 2
Explanation:
The size of the tuple would be 2, as the tuple included 2 lists therefore the total size would be
2.
Discuss this Question )
30. What will be the output of the following code?
ti=([22,1,2,3],)
print(t1*2)
A. ([22, 1, 2, 3], [22, 1, 2, 31)
B. ((44,1,4,6])
C. Error
D. Not defined
Answer: A) ([22, 1, 2, 3], (22, 1, 2, 3))
Explanation:
When you multiply any integer with the tuple it repeats the elements of the tuple that number
of times,
——_—_—_—_—_.
Discuss this Question )
\ )
31. What does count() function do in python tuples?
A. It gives you the sum of the entire tuple
B, It counts the occurrence of an elementCG It gives the sum ofall the integers present inside the tuples
Answer: B) It counts the occurrence of an element
Explanation:
The count() functions help us to find the total occurrence of a particular element inside a
tuple
Discuss this Question )
\ /
32. What is the output of the following code?
can"
‘cane!
print(t1.count("can"))
AS
B.4
C3
D1
Answer: A) 5
Explanation:
A total of 5 times the “can" word has occurred inside a tuple.
Discuss this Question )
)
33. Which keyword is used to check the particular element inside the tuple?
Als
B.In
C. ls there
D. Is_present
Answer: B) In
Explanation:In keyword is used to check whether the particular element is inside the tuple.
Discuss this Question )
34. What will be the output of the following code?
t1=("Can", "you","can",
print(“can" in t1)
2"can","as",
2 "canner","can","can",
A Yes
B. True
C. False
D5
Answer: B) True
Explanation:
In Keyword returns the result in true or false, If the particular element is there in the list then it
returns you the true, else false.
Discuss this Question )
\ /
35. What will be the output of the following code?
ti=(“hell
+1[2][1]=2000
print (t1)
hi", [100,1000,10000])
A. It will show you the error as tuples are immutable
B. It will change Hi to 2000
C. Chello’, ‘hi’, [100, 2000, 10000)
D. hello’, '2000', [100, 2000, 10000))
Answer: C) (‘hello’, ‘hi, (100, 2000, 10000))
Explanatio!
Tuples are immutable but if there is any list inside a tuple then you can easily update the value
of that list or mutable data typeDiscuss this Question )
/
36. What will be the output of the following code?
t1=(“hello","hi")
print(ti+("Include helps","Welcome you all"))
‘A. [twill show you the error as tuples are immutable
B. (‘hello’, ‘hi’, Include helps’, ‘Welcome you all’)
C. Chello’, ‘hi’ (‘include helps’, ‘Welcome you all’)
Answer: B) (‘hello’, ‘hi, ‘Include helps’, ‘Welcome you all’)
Explanation:
Tuples are immutable but you can concatenate another tuple inside a tuple.
Discuss this Question )
37. Among the tuple and list which of the creation is faster?
A.Tuple
B. List
C. Both are equal
Answer: A) Tuple
Explanation:
Creating tuples is faster in python compared to the list.
7
Discuss this Question )
38. How do you find the total of all the elements of the tuple?
A. total() function
B. sum() function
C. aggregate() function
D. sum_total functionAnswer: B) Sum( function
Explanation:
The sum() function will help you to find out the sum of all the elements in the tuple.
/ \
Discuss this Question )
39. What is the functionality of the Not in the keyword in a python tuple?
A. Not in keyword returns true if a specific element is not there in the tuple
B. Not in keyword returns false if a specific element is not there in the tuple
Answer: A) Not in keyword returns true if a specific element is not there in the tuple
Explanation:
not in is a Python membership operator that returns true if a specific element is not there in
the tuple.
Discuss this Question }
40. Among tuples and lists which takes less memory?
A. Tuples
B. List
Answer: A) Tuples
Explanation:
Since tuples are immutable therefore it takes less memory than the list.
Discuss this Question )