Home »
Python
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?
- An immutable type of data type which can store anything
- A mutable type of data type which can only store string
- An immutable type of data type which can store only stored string
- 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.
Discuss this Question
2. Python tuples are IMMUTABLES. What does this statement mean?
- An immutable nature of python tuples states that it allows us to store the element at the creation time only
- 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?
- :
- ,
- ::
- None of the above
Answer: B) ,
Explanation:
In python tuples, elements are separated by a comma ( , ) symbol.
Discuss this Question
4. What is the nature of the python tuples data type?
- In python, tuples are of ordered nature
- 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?
- The ordered nature of tuples indicates that you can only store the data in sequence
- The ordered nature of tuples indicates that the items are retained in the order in which they are inserted
- 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
- 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.
Explanation:
The ordered nature of tuples indicates that the items are retained in the order in which they are inserted.
Discuss this Question
6. Can you create a single-element tuple?
- Yes
- No
Answer: A) Yes
Explanation:
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. Is it possible to create an empty tuple?
- Yes
- No
Answer: A) Yes
Explanation:
Yes, you can create an empty tuple. For example, T=().
Discuss this Question
8. Is parentheses important to store elements inside a tuple?
- Yes
- No
Answer: B) No
Explanation:
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?
- T1= "ram", "hello"," include help"
- T1=("ram",)
- T1=("ram")
- 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))
- <class 'str'>
- <class 'tuple'>
- Error
Answer: A) <class 'str'>
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?
- {}
- []
- ()
- 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[0],T1[-2])
- Hello
- Hello all
- Hello you
- Error
Answer: C) Hello you
Explanation:
"Hello you" will be the output.
Discuss this Question
13. Do tuples follow the concept of negative indexing?
- YES
- NO
- In special conditions only
Answer: A) YES
Explanation:
Yes, tuples also follow the concept of negative indexing.
Discuss this Question
14. What do you mean by negative indexing?
- Negative indexing in python helps us to traverse the list from the end
- Negative indexing in python helps us to traverse the list from the starting
- 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.
Discuss this Question
15. Can you create a tuple inside a tuple?
- Yes
- 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[-1])
- Error
- Hello
- -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?
T1=("hello",[1,2,3,4],("Namastey","Bonjour"))
print(T1[1])
- Hello
- 1
- [1,2,3,4]
- 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?
- String
- Tuple
- 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
19. Will it be considered a tuple?
T1= "include help",
print(type(T1))
- Yes
- No
- It will show you the error
Answer: A) Yes
Explanation:
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","all")
print(t1[2:4])
- Yes
- 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])
- ("everyone", "include helps" ," welcomes", "you")
- ("everyone", "include helps" ," welcomes")
- ("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?
- Tuple[start:end]
- Tuple[start:end:steps]
- Only A
- Only B
- Both A and B
Answer: E) 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:
tpl = (10, 20, 30, 40, 50)
print(tpl) # Prints (10, 20, 30, 40, 50)
print(tpl[0:5]) # Prints (10, 20, 30, 40, 50)
print(tpl[0:5:2]) # Prints (10, 30, 50)
Discuss this Question
23. What will be the output of the following code?
T1=(88,99,77,11,22,33,44)
print([:])
- Entire tuple will be printed
- Tuple will be printed in reverse order
- the Same tuple will be printed
- 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?
- Remove()
- Delete()
- Del()
- It is 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?
- Remove
- Delete
- 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?
t1=("hello","everyone","include helps","welcomes","you","all")
del t1
print(t1)
- name 't1' is not defined
- ("hello","everyone","include helps","welcomes","you","all")
- Hello, everyone, include helps
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?
- size()
- len()
- lenln()
- list_len()
Answer: B) len()
Explanation:
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?
t1=(["hello",1,2,3], ["Hi"," everyone"," How"," Are"," You"])
- print(len(t1))
- print(len[t1])
- 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"])
- 9
- 3
- 5
- 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?
t1=([22,1,2,3],)
print(t1*2)
- ([22, 1, 2, 3], [22, 1, 2, 3])
- ([44,1,4,6])
- Error
- 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?
- It gives you the sum of the entire tuple
- It counts the occurrence of an element
- It gives the sum of all 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?
t1=("Can","you","can","a","can","as","a","canner","can","can","a","can")
print(t1.count("can"))
- 5
- 4
- 3
- 1
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?
- Is
- In
- Is_there
- 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","a","can","as","a","canner","can","can","a","can")
print("can" in t1)
- Yes
- True
- False
- 5
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?
t1=("hello","hi",[100,1000,10000])
t1[2][1]=2000
print(t1)
- It will show you the error as tuples are immutable
- It will change Hi to 2000
- ('hello', 'hi', [100, 2000, 10000])
- ('hello', '2000', [100, 2000, 10000])
Answer: C) ('hello', 'hi', [100, 2000, 10000])
Explanation:
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 type.
Discuss this Question
36. What will be the output of the following code?
t1=("hello","hi")
print(t1+("Include helps","Welcome you all"))
- It will show you the error as tuples are immutable
- ('hello', 'hi', 'Include helps', 'Welcome you all')
- ('hello', '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?
- Tuple
- List
- Both are equal
Answer: A) Tuple
Explanation:
Creating tuples is faster in python compared to the list.
Discuss this Question
38. How do you find the total of all the elements of the tuple?
- total() function
- sum() function
- aggregate() function
- sum_total function
Answer: 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?
- Not in keyword returns true if a specific element is not there in the tuple
- 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?
- Tuples
- List
Answer: A) Tuples
Explanation:
Since tuples are immutable therefore it takes less memory than the list.
Discuss this Question