MCQ Bank
What is the output of "hello world".upper()?
- A) Hello World
- B) Hello world
- C) hello World
- D) HELLO WORLD
What is the output of len((10, 20, 30))?
- A) 1
- B) 3
- C) 2
- D) 0
What is the result of the following operation? (1, 2) + (3, 4)
- A) (1, 2, 3, 4)
- B) (1, 2)(3, 4)
- C) (4, 6)
- D) [1, 2, 3, 4]
If skills = "Python|Java|C++|Machine Learning", what is the result of skills.split("|")?
- A) Python, Java
- B) Python, Java, C++, Machine Learning
- C) Python
- D) Python, Java, C++
What is the result of the following operation? set1 = {1, 2, 3} set2 = {2, 3, 4} print(set1 & set2)
- A) {2, 3, 4}
- B) {1, 4}
- C) { }
- D) {2, 3}
Which method is used to add a single element to a Python set?
- A) insert()
- B) append()
- C) add()
- D) extend()
What is the result of name, *details = ("Areeba", 87, "Passed")?
- A) name = "Areeba", details = [87, "Passed"]
- B) name = "Areeba", details = ["Passed"]
- C) name = "Passed", details = [87]
- D) name = 87, details = ["Passed"]
What will len(str(1234)) return?
- A) 4
- B) 1
- C) 3
- D) 2
Which method adds a single element to a set?
- A) insert()
- B) push()
- C) add()
- D) append()
What does list.copy() do?
- A) Creates a shallow copy of the list
- B) Creates a reference to the same list
- C) Creates a deep copy
- D) Deletes the list
What is the result of set([True, 1, False, 0])?
- A) {}
- B) {True, False, 1, 0}
- C) {1, 0}
- D) {True, False}
What will be the output of students[0] if students = ["Ali", "Sara", "John", "Zain"]?
- A) Sara
- B) Zain
- C) John
- D) Ali
What does skills.split("|") return if skills = "Python|Java|SQL"?
- A) ('Python', 'Java', 'SQL')
- B) ['P', 'y', 't', 'h', 'o', 'n']
- C) "Python Java SQL"
- D) ['Python', 'Java', 'SQL']
Which method converts "bachelor of science" to "Bachelor Of Science"?
- A) capitalize()
- B) upper()
- C) title()
- D) format()
Which of the following checks whether an "apple" is present in the set "Fruits"?
- A) fruits.has('apple')
- B) 'apple' in fruits
- C) find(fruits, 'apple')
- D) 'apple' exists in fruits
What does the index() method do in a tuple?
- A) Returns the index of the first matching element
- B) Inserts an element at a given index
- C) Removes an element by index
- D) Changes the value at a specific index
Which of the following is a valid tuple concatenation?
- A) tuple1.append(tuple2)
- B) tuple1.extend(tuple2)
- C) tuple1.add(tuple2)
- D) tuple1 + tuple2
Which operator is used for variable-length unpacking in Python?
- A) //
- B) *
- C) **
- D) &
How can we access the last element of a tuple?
- A) tuple[-1]
- B) tuple[length]
- C) tuple.last()
- D) tuple[len]
Which list method is used to add multiple elements at the end of a list?
- A) append()
- B) insert()
- C) add()
- D) extend()