Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

TIU Quiz-10

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

Which of the following is the correct way to connect to an SQLite3 database in Python?

a)

db = sqlite3.connect('database_name')

b)

db = sqlite3.connection('database_name')

c)

db = sqlite3.Connection('database_name')

d)

db = sqlite3.database('database_name')

2.

What method is used to commit changes to the database in SQLite3?

b)

db.update()

c)

db.commit()

d)

db.execute()

3.

How can you create a new table named students with columns id, name, and age?

a)

cursor.execute("CREATE TABLE students (id INT, name TEXT, age INT)")

b)

cursor.execute("NEW TABLE students (id INT, name TEXT, age INT)")

c)

cursor.execute("CREATE students (id INT, name TEXT, age INT)")

d)

cursor.execute("TABLE students (id INT, name TEXT, age INT)")

4.

What is method overriding in OOP?

a)

Defining a method with the same name but different parameters in the same class

b)

Defining a method with the same name and parameters in a derived class

c)

Using multiple methods with different names

d)

Redefining a method with different parameters in the same class

5.

Which statement about class and object is incorrect?

a)

A class is a blueprint for objects.

b)

An object is an instance of a class.

c)

Classes can have attributes and methods.

d)

Objects can inherit classes.

6.

How do you create an instance of a class named Car?

a)

Car = new Car()

b)

my_car = Car()

c)

my_car = Car.create()

d)

Car my_car = Car()

7.

What is the purpose of the init method in a Python class?

a)

To initialize a class attribute

b)

To initialize an instance of a class

c)

To define a class method

d)

To delete an instance of a class

8.

What is the output of the following code: matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]; [row[0] for row in matrix]?

a)

[1, 4, 7]

b)

[1, 2, 3]

c)

[1, 5, 9]

d)

[3, 6, 9]

9.

How do you ensure a SQLite3 connection is properly closed in Python?

a)

db.close()

b)

db.end()

c)

db.terminate()

d)

db.stop()

10.

Which list comprehension correctly generates the Cartesian product of lists [1, 2] and [3, 4]?

a)

[(x, y) for x in [1, 2] for y in [3, 4]]

b)

[(x, y) for x in [1, 2], y in [3, 4]]

c)

[(x, y) in ([1, 2], [3, 4])]

d)

[(x, y) from [1, 2] to [3, 4]]