KEMBAR78
Python MCQ Questions | PDF
0% found this document useful (0 votes)
9 views3 pages

Python MCQ Questions

Uploaded by

venteysharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

Python MCQ Questions

Uploaded by

venteysharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Python MCQs with Answers

1. 1. What is the correct way to create an object in Python?

 a) obj = ClassName
 b) obj = ClassName()
 c) obj = new ClassName()
 d) obj = ClassName.new()

Answer: b

2. 2. Which keyword is used to define a class in Python?

 a) def
 b) class
 c) object
 d) struct

Answer: b

3. 3. Which method is used to read an entire file in Python?

 a) file.read()
 b) file.readline()
 c) file.readlines()
 d) file.open()

Answer: a

4. 4. What is the syntax for inheritance in Python?

 a) class Child inherits Parent


 b) class Child(Parent)
 c) class Child: Parent
 d) class Parent -> Child

Answer: b

5. 5. What is polymorphism in Python?

 a) Overloading functions
 b) Same method name with different implementations
 c) Many classes
 d) Multiple inheritance
Answer: b

6. 6. What does the 're' module in Python handle?

 a) Math operations
 b) Regular expressions
 c) File handling
 d) Networking

Answer: b

7. 7. Which block is used for exception handling in Python?

 a) try-except
 b) if-else
 c) loop-catch
 d) do-catch

Answer: a

8. 8. What is the purpose of 'assert' in Python?

 a) Logging
 b) Debugging
 c) Condition checking
 d) Looping

Answer: c

9. 9. Which library is commonly used for database connection in Python?

 a) sqlite3
 b) pandas
 c) numpy
 d) matplotlib

Answer: a

10. 10. What function is used to execute SQL queries in Python?

 a) cursor.query()
 b) execute()
 c) run()
 d) sql.run()
Answer: b

11. 11. How do you commit changes to a database in Python?

 a) db.save()
 b) commit()
 c) db.commit()
 d) sql.commit()

Answer: c

You might also like