Python Sequence Data Types important MCQs in English/Hindi | Nielit Notes | PDF
In this post, we cover all important Questions from the topic "Python Sequence Data Types".
These MCQs will definitely help to pass IT and Computer students in any exam and interview that have Pyhton Sequence Data Types topic.
The Python Sequence Data Types chapter covers the following topics:
Lists, tuples and dictionary, (Slicing, Indexing, Concatenation, other operations
on Sequence data type), concept of mutability, Examples to include finding
the maximum, minimum, mean; linear search on list/tuple of numbers, and
counting the frequency of elements in a list using a dictionary.
After completion of the Python Sequence Data Types unit, Students will be able to:
- Work with various built-in Sequence datatypes and their use.
- Understand the concept of mutable and immutable objects.
Python Sequence Data Types MCQs
Here are the 42 most important and frequently asked MCQs from the "Python Sequence Data Types" topic.
1. Which of the following is a Python tuple?
a. [1, 2, 3]
b. (1, 2, 3)
c. {1, 2, 3}
d. {}
Ans. b
2. What will be the output of the following Python code?
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]
a. [2, 3, 9]
b. [1, 2, 4, 3, 8, 9]
c. [1, 4, 8]
d. (1, 4, 8)
Ans. c
3. How to get last element of list in python? Suppose we have list with name arr, contains 5 elements.
a. arr[0]
b. arr[5]
c. arr[last]
d. arr[-1]
Ans. d
4. How to copy one list to another in python?
a. l1[] = l2[]
b. l1[] = l2
c. l1[] = l2[:]
d. l1 = l2
Ans. c
5. Is Python case sensitive when dealing with identifiers?
a. Yes
b. No
c. machine dependent
d. none of the mentioned
Ans.a
6. In which data type, indexing is not valid ?
a.list
b.string
c.dictionary
d.None of the above
Ans. c
7. In which of the following data type, duplicate items are not allowed ?
a.list
b.set
c.dictionary
d.None of the above
Ans. b
8. Which statement is correct?
a. List is immutable && Tuple is mutable
b. List is mutable && Tuple is immutable
c. Both are Mutable.
d. Both are Immutable
Ans.b
9. What is the output of the following program : print((1, 2) + (3, 4))
a. (1, 2), (3, 4)
b. (4, 6)
c. (1, 2, 3, 4)
d. Invalid Syntax
Ans. c
10. In order to store values in terms of key and value we use that core data type in python?
a.List
b.Class
c.Dictionary
d.Tupple
Ans. c
11. How we can convert the given list into the set ?
a.list.set()
b.set.list()
c.set(list)
d.None of the above
Ans. c
12. Which one of the following is mutable data type?
a. set
b. int
c. str
d. tupl
Ans. a
13. What will be the output of the following Python code?
print(0xA + 0xB + 0xc.
a. 0xA0xB0xC
b. Error
c. 0x22
d. 33
Ans. d
14. Suppose list1 is [2445,133,12454,123], what is max(list1)?
a. 2445
b. 133
c. 12454
d. 123
Ans. c
15. Suppose list1 is [3, 5, 25, 1, 3], what is min(list1)?
a. 3
b. 5
c. 25
d. 1
Ans. d
16. Which one of the following is immutable data type?
a. list
b. set
c. int
d. dict
Ans. c
17. Which of the follwing are the keys in the given statement : abc = {"first":10, "second":20}
a. 10, 20
b. first, second
c. first, 10, second, 20
d. first, 20
Ans. b
18. Which of the following statements is used to create an empty set?
a. []
b. {}
c. ()
d. set()
Ans. d
19. Which of the following function is used to know the data type of a variable in Python?
a. datatype()
b. typeof()
c. type()
d. vartype()
Ans. c
20. In which data type, indexing is not valid?
a. List
2. String
3. Dictionary
4. None of the above
Ans. c
21. If we change one data type to another, then it is called
a.Type conversion
b.Type casting
c.Both of the above
d.None of the above
Ans. c
22. What is list data type in Python ?
a.collection of integer number
b.collection of string
c.collection of same data type
d.collection of different data type
Ans. d
23. Which of the following can convert the string to float number ?
a.str(float,x)
b.float(str,int)
c.int(float(str))
d.float(str)
Ans. d
24. x=c.123, then int(x) will give
a.c.1
b.0
c.1
d.3
Ans. d
25. Which of the sequence are valid in the set data type in python ?
a.1,1,1,1,1,1
b.2,3,4,5,6,1,2
c.1,2,3,4,5,6
d.None of the above
Ans. c
26. What is the average value of the following Python code snippet?
>>>grade1 = 80
>>>grade2 = 90
>>>average = (grade1 + grade2) / 2
a. 85.0
b. 85.1
c. 95.0
d. 95.1
Ans. a
27. What error occurs when you execute the following Python code snippet?
apple = mango
a. SyntaxError
b. NameError
c. ValueError
d. TypeError
Ans. b
28. Suppose a list with name arr, contains 5 elements. You can get the 2nd element from the list using:
a. arr[-2]
b. arr[2]
c. arr[-1]
d. arr[1]
Ans. d
29. What will be the output of the following Python code?
>>>str1="helloworld"
>>>str1[::-1]
a. dlrowolleh
b. hello
c. world
d. helloworld
Ans. a
30. Suppose list1 is [1, 5, 9], what is sum(list1)?
a. 1
b. 9
c. 15
d. Error
Ans. c
31. Suppose a tuple arr contains 10 elements. How can you set the 5th element of the tuple to 'Hello'?
a. arr[4] = 'Hello'
b. arr(4) = 'Hello'
c. arr[5] = 'Hello'
d. Elements of tuple cannot be changed
Ans. d
32. What type of data is: arr = [(1,1),(2,2),(3,3)]?
a. Array of tuples
b. Tuples of lists
c. List of tuples
d. Invalid type
Ans. c
33. Which of the following data type is used to store values in Key & Value format?
a. List
b. Tuple
c. Dictionary
d. Set
Ans. c
34. Select the correct example of complex datatype in Python
a. 3 + 2j
b. -100j
c. 5j
d. All of the above are correct
Ans. d
35. How can we create an empty list in python?
a. list=()
b. list.null
c. null.list
d. list=[]
Ans. d
36. All keywords in Python are in ____
None of the below
lower case
UPPER CASE
Capitalized
Ans. a
37. What is the output of following: set([1,1,2,3,4,2,3,4])
a. [1,1,2,3,4,2,3,4]
b. {1,2,3,4}
c. {1,1,2,3,4,2,3,4}
d. Invalid Syntax
Ans. b
38. Can tuple be used as dictionary key in python?
a. True
b. False
c. Tuple is not used in python
d. None of the above
Ans. a
39. What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
print(a.get(1,4))
a. 1
b. A
c. 4
d. Invalid syntax for get method
Ans. b
40. What will be the output of the following Python code snippet?
a={1:"A",2:"B",3:"C"}
a.setdefault(4,"D")
print(a.
a. {1: ‘A’, 2: ‘B’, 3: ‘C’, 4: ‘D’}
b. None
c. Error
d. [1,3,6,10]
Ans. a
41. Which statement is correct?
a. List is immutable && Tuple is mutable
b. List is mutable && Tuple is immutable
c. Both are Mutable.
d. Both are Immutable
Ans. b
42. What is the data type of print(type(5))?
a. int
b. float
c. double
d. integer
Ans.a
No comments: