1. Which of the following is used to display output in Python?
A) output()
B) print()
C) display()
D) echo()
Show Explanation
2. What is the main difference between a list and a tuple in Python?
B) Lists are mutable, tuples are immutable
A) Tuples can hold different data types, lists cannot
C) Lists cannot contain duplicates, tuples can
D) Lists are faster than tuples
Show Explanation
3. What is the significance of indentation in Python?
A) It affects variable naming
B) It is ignored by the interpreter
C) It defines the scope of loops and functions
D) It is used for commenting
Show Explanation
4. Which function is used to get the length of a list in Python?
C) len()
A) count()
B) size()
D) length()
Show Explanation
5. What is a lambda function in Python?
B) A function that returns multiple values
A) A built-in function
C) A function with no parameters
D) An anonymous function
Show Explanation
6. In a class method, what does 'self' refer to in Python?
D) The instance of the class
A) A global variable
B) A method of the class
C) A static variable
Show Explanation
7. What is the main characteristic of a dictionary in Python?
A) It allows duplicate keys
B) It is ordered
C) It stores key-value pairs
D) It is immutable
Show Explanation
8. Which of the following is the correct way to handle exceptions in Python?
A) try-except
B) try-catch
C) catch-try
D) error-exception
Show Explanation
9. What will be the output of the following code?
print(1 + 2 * 3)
A) 9
B) 6
C) 7
D) 3
Show Explanation
10. What does the 'strip()' method do in Python?
A) It splits a string
B) It removes whitespace from the ends of a string
C) It converts a string to lowercase
D) It reverses a string
Show Explanation
11. What does the 'map()' function do in Python?
A) Applies a function to all items in an iterable
B) Merges two lists
C) Filters elements from an iterable
D) Sorts an iterable
Show Explanation
12. Can a function in Python return multiple values?
A) Yes, as a tuple
B) No, only one value can be returned
C) Yes, but only if they are of the same type
D) Yes, as a list
Show Explanation
13. How do you concatenate a list of strings in Python?
A) concat()
B) combine()
C) merge()
D) join()
Show Explanation
14. What will be the output of the following code?
print(7 // 2)
A) 3
B) 3.5
C) 4
D) 2
Show Explanation
15. Which function is used to check if an object is an instance of a specified class in Python?
A) isinstance()
B) type()
C) check()
D) class()
Show Explanation
16. What is the purpose of the 'with' statement in Python?
A) It defines a function
B) It handles exceptions
C) It manages resources efficiently
D) It imports modules
Show Explanation
17. What does the 'break' statement do in a loop?
A) It terminates the loop
B) It skips the current iteration
C) It restarts the loop
D) It continues to the next loop
Show Explanation
18. How do you add an item to the end of a list in Python?
A) insert()
B) append()
C) add()
D) extend()
Show Explanation
19. What is inheritance in Python?
D) A way to create a new class using an existing class
A) A way to access variables
B) A method to define a function
C) A type of error
Show Explanation
20. What does the 'len()' function do in Python?
C) Returns the number of items in an object
A) Returns the type of an object
B) Returns the first item of an object
D) Returns the last item of an object
Show Explanation