Question Bank US05MIBCA04:
Python Programming Unit 1
[NEP]
MCQ
1. Python is a widely used general-purpose, language.
a. High Level programming
b. Middle Level programming
c. Low Level programming
d. Machine Level programming
2. Who developed the Python language?
a. Zim Den
b. Guido van Rossum
c. Niene Stom
d. Wick van Rossum
3. Which one of the following is the correct extension of the Python file?
a. .p
b. .python
c. .py
d. None of above
4. What do we use to define a block of code in Python language?
a. Key
b. Brackets
c. Indentation
d. None of these
5. Which character is used in Python to make a single line comment?
a. /
b. //
c. #
d. !
6. Identifier is start with then it indicates it is private.
a. Underscore (_)
b. Double Underscore ( )
c. Dollar Sign($)
d. & (ampersand)
7. Which of the following is valid Python identifiers?
a. 123total
b. total123
c. ca$h
d. if
8. Which of the following operators is the correct option for power(ab)?
a. a ^ b
b. a**b
c. a ^ ^ b
d. a ^ * b
9. Which one of the following has the highest precedence in the expression?
a. Division
b. Subtraction
c. Power
d. Parentheses
10. Which one of these is floor division?
a. /
b. //
c. %
d. None of the mentioned
11. Which one of the following has the same precedence level?
a. Addition and Subtraction
b. Multiplication, Division and Addition
c. Multiplication, Division, Addition and Subtraction
d. Addition and Multiplication
12. Which statement is used to check multiple conditions in Python?
a. Else if
b. Elseif
c. Elif
d. None of these
13. A while loop in Python is used for what type of iteration?
a. indefinite
b. discriminant
c. definite
d. indeterminate
14. When does the else statement written after loop executes?
a. When break statement is executed in the loop
b. When loop condition becomes false
c. Else statement is always executed
d. None of the above
15. Which of the following is not used as loop in Python?
a. for loop
b. while loop
c. do-while loop
d. None of the above
16. In which Removes all elements of dictionary dict.
a. [Link]()
b. [Link]()
c. [Link]()
d. [Link]()
17. In which following operation of an array
a. Index
b. matrix
c. traverse
d. slicing
18. Which of these about a set is not true?
a. Mutable data type
b. Allows duplicate values
c. Data type with unordered values
d. Immutable data type
19. Which of the following statements is used to create an empty set?
a. { }
b. set()
c. [ ]
d. ( )
20. Which of the following statements create a dictionary?
a. d = {}
b. d = {“john”:40, “peter”:45}
c. d = {40:”john”, 45:”peter”}
d. All of the mentioned
21. Which of the following is a Python tuple?
a. [1, 2, 3]
b. (1, 2, 3)
c. {1, 2, 3}
d. {}
22. has ability to iterate over the items of any sequence, such as list.
a. While loop
b. While else
c. For loop
d. If
23. is a collection of objects which ordered and immutable.
a. A. Sequence
b. B. List
c. C. Tuple
d. D. Set
24. While accessing an index out of the range will cause an .
a. IndexError
b. TypeError
c. SubscriptError
d. None of these
25. Strings are immutable in Python, which means a string cannot be modified.
a. True
b. False
26. What will following Python code return?
str1="Stack of books"
print(len(str1))
a. 11
b. 14
c. 15
d. 16
Long Questions
1. List out python application and explain the features of Python in detail.
2. What is meaning of Type Casting? Explain type casting functions of Python.
3. List and explain any three operators with example.
4. Write a detailed note on User Input and Output in Python in detail.
5. Explain decision making and branching in Python.
6. Explain all Looping Statement with Example.
7. List out python collection? Explain any one of them.
8. Explain string built in function and methods.
9. What is Array? Explain Array elements with example.
UNIT-2
1. What is used to initialize an object in Python?
A) init ()
B) start ()
C) constructor()
D) init()
2. Which keyword is used to define a class in Python?
A) object
B) def
C) class
D) self
3. What is the function of a destructor in Python?
A) It creates an object
B) It deletes an object automatically
C) It initializes attributes
D) It copies attributes
4. What will the global keyword do in a function?
A) Declare a local variable
B) Create a new object
C) Access a variable outside the function
D) None of the above
5. Which method is used to get the next value from an iterator?
A) next()
B) iterate()
C) get()
D) run()
6. What is inheritance in Python?
A) Creating variables
B) Accessing global variables
C) Creating a new class from an existing class
D) Creating a dictionary
7. What is method overriding?
A) Changing the parent class name
B) Using the same method name in child class
C) Creating two classes
D) Hiding class attributes
8. Which keyword is used to import a module in Python?
A) include
B) require
C) import
D) module
9. What is the correct syntax for a lambda function that adds 10 to its input x?
A) lambda x: x + 10
B) def lambda(x): x + 10
C) lambda(x) = x + 10
D) x => x + 10
10. Which of the following is not a built-in exception in Python?
A) IndexError
B) MemoryError
C) NullPointerException
D) ValueError
11. Which block is used to handle exceptions in Python?
A) handle
B) try-except
C) if-else
D) catch-finally
12. What type of error occurs when dividing a number by zero?
A) TypeError
B) ValueError
C) ZeroDivisionError
D) SyntaxError
13. represents an entity in the real world with its identity and behavior.
A. A method
B. An object
C. A class
D. An operator
14. is used to create an object.
A. class
B. constructor
C. User-defined functions
D. In-built functions
15. What is Instantiation in terms of OOP terminology?
A. Deleting an instance of class
B. Modifying an instance of class
C. Copying an instance of class
D. Creating an instance of class
16. The assignment of more than one function to a particular operator is .
A. Operator over-assignment
B. Operator overriding
C. Operator overloading
D. Operator instance
17. Which of the following is not an exception handling keyword in Python?
A. try
B. except
C. accept
D. finally
18. How many except statements can a try-except block have?
A. zero
B. one
C. more than one
D. more than zero
19. Which of these is not a fundamental feature of OOP in Python?
A. Encapsulation
B. Inheritance
C. Instantiation
D. Polymorphism
20. Which of the following is not a type of inheritance?
A. Single-level
B. Double-level
C. Multi-level
D. Multiple
Long Questions
1. Explain Function in python in detail with example.
2. What is scope in python? Explain in detail with example.
3. Explain python iterator in detail with example.
4. Explain any five error types with example.
5. Write a detailed note on exception handling in python.
6. What is inheritance? List all types of inheritance. Explain any two/three inheritance
with example
7. Differentiate between Method Overloading and Method Overriding.