0% found this document useful (0 votes)
54 views20 pages

MCQ Unit 3

Uploaded by

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

MCQ Unit 3

Uploaded by

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

303 - Database Handling Using Python SY BCA SEM 3

MCQ : UNIT-3 Python Interaction with SQLite


Que.1)Which of the following is true about The PYTHONPATH Variable?
A. The PYTHONPATH is an environment variable
B. It consists of a list of directories
C. The syntax of PYTHONPATH is the same as that of the shell variable PATH
D. All of the above
Ans.D

Que.2)Which of the following is false about global() and local() functions?


A. can be used to return the names in the global and local namespaces depending on the
location from where they are called.
B. If locals() is called from within a function, it will return all the names that can be accessed
locally from that function.
C. If globals() is called from within a function, it will return all the names that can be
accessed globally from that function.
D. The return type of both these functions is list
Ans.D

Que.3)Once a package is created it can be install using which of the following function?
A. install_PackageName()
B. setup()
C. pip PackageName
D. __package__.py
Ans.B

Que.4)Correct way to run the query in Python SQLite3 is:


A. sqlite3.execute.query
B. sqlite.run.execute(query)
C. sqlite3.execute(query)
D. None of the above
Ans.C

Que.5)CONNECT() function in SQLite3 is used for:


A. To connect to database
B. To open database
C. To create database
D. All of the above
Ans.D

Que.6)Which of the following is/are built-in modules?


A. Collection
B. Copy
C. Os
D. All of the above
303 - Database Handling Using Python SY BCA SEM 3

Ans.D. All of the above

Que.7)Which command is used to call a module in python?


A. Import <module-name>
B. <module-name>
C. .import <module-name>
D. .import <module-name.py>
Ans.A. import <module-name>

Que.8)Which of the following is the source of path information?


A. Environment variables
B. Existing folder
C. Default folder
D. All of the above
Ans.D. All of the above

Que.9)Why is it not a good practice to load all the member methods of the module in scope?
A. Because it occupies more memory
B. Because it occupies very less memory
C. Because it doesn't occupy any memory
D. None of the above
Ans.A. Because it occupies more memory

Que.10)Identify the correct output from the following code:. Import math as m print("floor
value of 5.2 is",m.floor(5.2)) print("ceil value of 5.2 is", m.ceil(5.2))
A. Floor value of 5.2 is 5 and ceil value of 5.2 is 10
B. Floor value of 5.2 is 5 and ceil value of 5.2 is 6
C. Error
D. Floor value of 5.2 is 6 and ceil value is 5.2 is 5
Ans.B. Floor value of 5.2 is 5 and ceil value of 5.2 is 6

Que.11)Python path can be saved from ______


A. Windows Environment Variables
B. Windows user profile Settings
C. Windows startup and recovery
D. Windows system protection
Ans.A

Que.12)We can access package’s all modules and object by this way :
A. import <package name>
B. from <package name> import *
C. from <package name>. <module name>
D. Import <object name>
Ans.B
303 - Database Handling Using Python SY BCA SEM 3

Que.13)Connect() method is used to


A. Create database
B. Connect with database
C. Create tables
D. Save database
Ans.A, B

Que.14)which method is used to retrieve N number of records


A. fetchone()
B. fetchall()
C. fetchmany()
D. fetchN()
Ans.C

Que.15)Close() function in sqlite3 is used for the:


A. To close the tables
B. To close the query
C. To close the database
D. None of the above
Ans.C

Que.16)By this way we can import sqlite3 module


A. .import sqlite3
B. .import sqlite3 as s
C. from sqlite3 import *
D. All of the above
Ans.D

Que.17)We can install sqlite3 in python by this way:


A. Install sqlite3
B. pip install sqlite3
C. pip sqlite3 install python
D. pip install sqlite3python
Ans.B

Que.18)A module will be available


A. Globally
B. In current namespace
C. Within Module only
D. Within Program only
Ans.B

Que.19)Python can find modules and packages within


A. Current Folder
303 - Database Handling Using Python SY BCA SEM 3

B. PYTHONPATH directory
C. Python’s Default Path
D. All of the above
Ans.D

Que.20)What is Namespace?
A. A namespace is a dictionary of variable names and their corresponding objects.
B. A namespace is a dictionary of Modules and their corresponding Paths
C. A namespace is a dictionary of Packages and their corresponding Modules
D. A namespace is a dictionary of Classes and their corresponding objects.
Ans.A

Que.21)What is the meaning of : sqlite3.connect(":memory:")


A. Open SQLite prompt without creating Database
B. Create Database in System Folder
C. Create temporary in-Memory Database
D. Open database in current folder
Ans.C

Que.22)___________ is an open source Python library for highly specialized data analysis.
A. Numpy
B. Pandas
C. Matplotlib
D. None of the above
Ans.C

Que.23)In python, a module may contain functions, but it cannot contain different type of variables.
A. True
B. False
C. Cannot be determined
D. Depends on type of module
Ans.B

Que.24)Which of the following is not the function of the sqlite3 in python ?


A. .connect()
B. .close()
C. .execute()
D. .raw()
Ans.D

Que.25)Correct way to run the query in Python sqlite3 is :


A. sqlite3.execute.query
B. sqlite3.execute(query)
C. sqlite.run.execute(query)
D. None of the above
303 - Database Handling Using Python SY BCA SEM 3

Ans.B

Que.26)Python allows usage of__________.


A. globals() and locals() functions
B. global() and local() functions
C. Both of the mentioned options
D. None of the mentioned
Ans.A

Que.27)Which keyword we use to fetch the data from the table in database ?
A. fetch
B. select
C. raw
D. All of the above
Ans.B

Que.28)In python, connect() returns _________.


A. Connection object
B. Database object
C. Database name
D. Connector class
Ans.A

Que.29)In python, execute() method can execute only ________ .


A. Only DQL & DML statements
B. Only DML statements
C. Only DQL statements
D. DDL, DML & DQL statements.
Ans.D

Que.30)fetchone() method belongs to _______ class.


A. Cursor
B. Connection
C. Cursor_connection
D. None of the mentioned
Ans.A

Que.31)Correct way to import the sqlite3 in the program ?


A. import sqlite3
B. import sqlite3 as s
C. from sqlite3 import *
D. All of the above
Ans.D

Que.32)A _______is used to group modules which are logically similar to one another
303 - Database Handling Using Python SY BCA SEM 3

A. cursor
B. Sequence
C. Package
D. Class
Ans.C

Que.33)The files containing functions, classes, variable declaration is called


A. Modules
B. Packages
C. Unit
D. Path
Ans.A

Que.34)The _______modules contains information related to system parameter


A. OS
B. System
C. sys
D. Pandas
Ans.C

Que.35)To get the individual module from a package


A. Form packageName import functionName
B. Form packageName import *
C. Import functionName
D. import packageName
Ans.A

Que.36)To make directory a package it is compulsory to include this file


A. start.py
B. begin.py
C. open.py
D. __init__.py
Ans.D

Que.37)Which character is used in Python to make a single line comment?


A. /
B. //
C. #
D. !
Ans.c

Que.38) Which one of the following syntaxes is the correct syntax to read from a simple text file
stored in ''d:\python1.txt''?
A. Infile = open(''d:\\python.txt'', ''r'')
B. Infile = open(file=''d:\\\python.txt'', ''r'')
303 - Database Handling Using Python SY BCA SEM 3

C. Infile = open(''d:\python.txt'',''r'')
D. Infile = open.file(''d:\\python.txt'',''r'')
Ans.A

Que.39)connect() function in sqlite3 is used for ?


A. To connect the database
B. To open the database 3.To create a database 4.All of the above
C. To create a database All of the above
D. All of the above
Ans.D

Que.40)import math abs(math.sqrt(49)) What will be the output of this code?


A. Error
B. -7
C. 7
D. 7
Ans.D

Que.41)Correct way to run the query in Python sqlite3 is :


A. sqlite3.execute.query
B. sqlite3.execute(query)
C. sqlite.run.execute(query)
D. None of the above
Ans.B

Que.42)Which of the following code snippets creates and connects to a new SQLite Database?
A. from sqlite3 import Connection connection = Connection("test_database.db")
B. import sqlite3 connection = sqlite3.create("test_database.db")
C. import sqlite3 connection = sqlite3.connect("test_database.db")
D. import sql connection = sql.connect("test_database.db")
Ans.C

Que.43)Which of the following are valid Cursor methods used to execute SQL statments and
retrieve query results?
A. cursor.execute()
B. cursor.fetchone()
C. C only
D. A and B both
Ans.D

Que.44)For fetch the data, which function we use to run the select query ?
A. fetch()
B. rawquery()
C. executequery()
D. execute()
303 - Database Handling Using Python SY BCA SEM 3

Ans.D

Que.45) Which of these definitions correctly describes a module?


A. Denoted by triple quotes for providing the specification of certain program elements
B. Design and implementation of specific functionality to be incorporated into a program
C. Defines the specification of how it is to be used
D. Any program that reuses code
Ans.B

Que.46) Which of the following is not an advantage of using modules?


A. Provides a means of reuse of program code
B. Provides a means of dividing up tasks
C. Provides a means of reducing the size of the program
D. Provides a means of testing individual parts of the program
Ans.C

Que.47)How we can call the function of sqlite3, if we import by import sqlite3 as sq ?


A. sqlite.function()
B. function()
C. sq.function()
D. None of above
Ans.C

Que.48)What the following query does ?, select count(*) from table


A. It return all rows data
B. It return number of rows in table
C. It return number of columns in table
D. It will give an error
Ans.B

Que.49)How to run a query??


A. 1.sqlite3.execute.query
B. 2.sqlite3.execute(query)
C. 3.sqlite.run.execute(query)
D. 4.None of the above
Ans.B

Que.50)To open or connect with the database, which function we used or call at runtime ?
A. 1.open()
B. 2.connect()
C. 3.database()
D. 4.All of the above
Ans.B

Que.51)Sqlite3 in python is the module by which we can handle


303 - Database Handling Using Python SY BCA SEM 3

A. Database
B. GUI
C. Connectivity
D. CLI
Ans.A

Que.52)connect() function in sqlite3 is used for ?


A. to connect the database
B. to open the database
C. to create a database
D. All of these
Ans.D

Que.53)Which of the following tool are provided by the python to manage the database ?
A. Sqlite3
B. MySQL
C. Infomix
D. All of above
Ans.4

Que.54)How we can call the function of sqlite3, if we import by import sqlite3 as sq ?


A. function(sqlite)
B. function()
C. sq.function()
D. None of these
Ans.C

Que.55)Which keyword we use to fetch the data from the table in database ?
A. Select
B. Fetch
C. Raw
D. All of above
Ans.A

Que.56)For fetch the data, which function we use to run the select query ?
A. fetch()
B. executequery()
C. execute()
D. select()
Ans.C

Que.57)Which of the following function is used to skip a row in a CSV file ?


A. next()
B. skip()
C. jump()
303 - Database Handling Using Python SY BCA SEM 3

D. goto()
Ans.A

Que.58)What is the use of commit


A. To undo all the data
B. To retrive all the tables
C. To save all the changes of the transaction
D. To exit from sqlite
Ans.C

Que.59)What is a use of __init__.py module?


A. to create python package
B. to initialize values for user defined function in python
C. to call interpreter in python
D. to take integer values in python
Ans.A

Que.60)To retrieve the data, which function is used to run the select query?
A. fetch()
B. execute()
C. executequery()
D. rawquery()
Ans.B

Que.61)Which statement is correct to import all modules from the package?


A. From package import all
B. From package import *
C. From package include all
D. From package include *
Ans.B

Que.62)connect() function in Sqlite is used for?


A. To connect the database
B. To open the database
C. To create the database
D. All of the above
Ans.D

Que.63)What is the extension of python file?


A. .pym
B. .py
C. .pyf
D. .pymode
Ans.B
303 - Database Handling Using Python SY BCA SEM 3

Que.64)What is the purpose of fetchall() ?


A. It returns a single record of the query result
B. It returns all records of the query result
C. It returns many records of the query result
D. It returns two records of the query result
Ans.B

Que.65)What is the default timeout parameter for SQLITE database transaction?


A. 1 seconds
B. 2 seconds
C. 5 seconds
D. 10 seconds
Ans.C

Que.66)What is the purpose of fatchone() method?


A. It returns multiple recoords
B. It returns two records
C. It returns a single record or none if no more rows are available
D. It returns many rows
Ans.C

Que.67)What does total_changes() returns?


A. It returns the number of database rows that have been modified, inserted or deleted
B. It returns the number of database columns that have been modified, inserted or deleted
C. Both of the above
D. None of the above
Ans.A

Que.68)close() is used for ____________


A. To close the query
B. To close the table
C. To close the database
D. None of the above
Ans.C

Que.69)Types of Name Space


A. Local Name Space
B. Global Name Space
C. Built-in Name Space
D. All of the above
Ans.D

Que.70)Correct way to run the query in Python sqlite3 is


A. sqlite3.execute.query
303 - Database Handling Using Python SY BCA SEM 3

B. sqlite3.execute(query)
C. sqlite.run.execute(query)
D. None
Ans.B

Que.71)Identify the package manager for Python packages, or modules.


A. Matplotlib
B. PIP
C. plt.show()
D. python package
Ans.B

Que.72)connect() function in sqlite3 is used for ?


A. To connect the database
B. To open the database
C. To create a database
D. All of the mentioned
Ans.A

Que.73)For fetch the data, which function we use to run the select query ?
A. fetch()
B. rawquery()
C. executequery()
D. execute()
Ans.D

Que.74)Which of the following are valid Cursor methods used to execute SQL statments and
retrieve query results? Select all that apply.
A. Cursor.run()
B. Cursor.execute()
C. Cursor.fetchall()
D. Cursor.fetchmany()
Ans.B

Que.75)Which of the following is not a valid namespace?


A. Global namespace
B. Public namespace
C. Built-in namespace
D. Local namespace
Ans.B

Que.76)Which of the variables tells the interpreter where to locate the module files imported into a
program?
A. local
B. import variable
303 - Database Handling Using Python SY BCA SEM 3

C. PYTHONPATH
D. current
Ans.C

Que.77)The collection of modules and packages that together cater to a specific type of applications
or requirements, is called ____.
A. module
B. library
C. classes
D. documentation
Ans.B

Que.78)For fetch the data, which function we use to run the select query ?
A. fetch()
B. rawquery()
C. executequery()
D. execute()
Ans.D

Que.79)A Python module has ___ extension.


A. .mod
B. .imp
C. .py
D. .mpy
Ans.C

Que.80)Which file must be a part of a folder to be used as a Python package?


A. package.py
B. __init__.py
C. __package__.py
D. __module.py__
Ans.B

Que.81)rows = cursor.fetchall() returns ?


A. The method fetches one(or all remaining) rows of a query result set and returns a list of
tuples. If no more rows are available, it returns an empty list.
B. The method fetches some (or all remaining) rows of a query result set and returns a list
of tuples. If no more rows are available, it returns an empty list.
C. The method fetches all (or all remaining) rows of a query result set and returns a list of
tuples. If no more rows are available, it returns an empty list.
D. The method fetches fews (or all remaining) rows of a query result set and returns a list of
tuples. If no more rows are available, it returns an empty list.
Ans.C
303 - Database Handling Using Python SY BCA SEM 3

Que.82)which method retrieves the next row of a query result set and returns a single sequence, or
None if no more rows are available.
A. row = cursor.fetchones()
B. row = cursor.fetch()
C. row = cursor.fetchone()
D. row = cursor.fetchall()
Ans.C

Que.83)________________ method closed the database connection & __________________ method commits
the current transaction.
A. connection.close() & connection.committed()
B. connection.close() & connection.commit()
C. connection.exit() & connection.commit()
D. connection.exit() & connection.committed()
Ans.B

Que.84)which command used for connect or open database successfully, it returns a connection
object.
A. sqlite3.conn(database [,timeout ,other optional arguments])
B. sqlite3.connect(database [,timeout ,other optional arguments])
C. sqlite3.connections(database [,timeout ,other optional arguments])
D. sqlite3.con(database [,timeout ,other optional arguments])
Ans.B

Que.85)A ____________can be define functions, classes and variables. It is a same a code library.
A. Function
B. Procedure
C. File
D. Module
Ans.D

Que.86)The _______________ defines the accessibility of the python object.


A. namespace
B. scope
C. package
D. None of the above
Ans.B

Que.87)Which of the following code snippets creates and connects to a new SQLite Database?
A. from sqlite3 import Connection connection = Connection("test_database.db")
B. import sqlite3 connection = sqlite3.connect("test_database.db")
C. import sqlite3 connection = sqlite3.create("test_database.db")
D. import sql connection = sql.connect("test_database.db")
Ans.B
303 - Database Handling Using Python SY BCA SEM 3

Que.88)Which of the following are valid Cursor methods used to execute SQL statments and
retrieve query results? Select all that apply.
A. Cursor.fetchall()
B. Cursor.fetchone()
C. Cursor.execute()
D. Cursor.execute()
Ans.C

Que.89)Sqlite3 in python is the module by which we can handle


A. Database
B. GUI
C. Connectivity
D. Both B and C
Ans.A

Que.90)What will be the result of fetchone( ) method if no row is left?Read more on Sarthaks.com -
https://www.sarthaks.com/1021157/what-will-be-the-result-of-fetchone-method-if-no-row-is-left
A. True
B. 2
C. Both A and B
D. None
Ans.D

Que.91)Which of the following is false for "import P1" in "P2" python file?
A. P1 is the module which is imported into P2 python file.
B. all functions of P1 module can be used within P2 file
C. P2 is the module which is imported into P1 python file.
D. None of above
Ans.C

Que.92)What is the meaning of "FROM P1 IMPORT gyan"?


A. P1 is a function of gyan module which is imported into another file.
B. Gyan is a function of P1 module which is imported into another file.
C. All functions of P1 module are imported into another file.
D. All functions of gyan module are imported into another file.
Ans.B

Que.93)Which method is used to establish connection with SQLite database?


A. connect()
B. execute()
C. SQLite3()
D. class()
Ans.A
303 - Database Handling Using Python SY BCA SEM 3

Que.94)____ method is used to extract single record from current position.


A. fetchone()
B. fetchmany()
C. fetchall()
D. None of above
Ans.A

Que.95)commit() method is not required with _____.


A. insert
B. update
C. select
D. delete
Ans.C

Que.96)Which of the following is correct when user input is in integer?


A. a=c.execute(f"select * from tblemp where eno={no}")
B. a=execute(f"select * from tblemp where eno={no}")
C. a=c.execute("select * from tblemp where eno={no}")
D. a=execute("select * from tblemp where eno={no}")
Ans.A

Que.97)What is an import?
A. It is a module
B. It is a function
C. t is a class
D. It is a statement
Ans.D

Que.98)Which of the following is the correct order for import?


A. Compile, find and execute a module
B. Find, Compile and Execute a module
C. Execute, find and compile a module
D. Compile, execute and find a module
Ans.B

Que.99)Which of the following DML statement requires commit while interacting with SQLite
through Python?
A. create table
B. select
C. insert into
D. All of the above
Ans.C

Que.100)Python first looks for the imported file in the __________.


303 - Database Handling Using Python SY BCA SEM 3

A. The home directory of the program


B. PYTHONPATH directories
C. Standard library directories
D. None of the above
Ans.A

Que.101)Which of the following force a module’s code to be reloaded and rerun?


A. import statement
B. from statement
C. reload built-in function
D. None of the above
Ans.C

Que.102)If we want to use function 'disp()' of user defined module 'calculate', then which of the
following syntax is correct to write in python ?
A. from calculate import disp; disp()
B. from calculate import *; disp()
C. import calculate as calc; calc.disp()
D. All of above
Ans.D

Que.103)Which of the following is default python attribute ?


A. **name**
B. __name__
C. $$name$$
D. &&name&&
Ans.B

Que.104)The directory inside of the Python path, which contain a file with which name, will be
treated as a package by Python.
A. __package__.py
B. __create__.py
C. __init__.py
D. __pkg__.py
Ans.C

Que.105)What is a use of __init__.py module?


A. to create python package
B. to initialize values for user defined function in python
C. to call interpreter in python
D. to take integer values in python
Ans.A

Que.106)A dictionary of variable names (keys) and their corresponding objects (values) is known
as ?
303 - Database Handling Using Python SY BCA SEM 3

A. namespace
B. function
C. class
D. path
Ans.A

Que.107)Python can find modules and packages within


A. Current directory
B. PYTHONPATH directory
C. Python’s Default Path
D. All of the above
Ans.D

Que.108)Python variables are searched in the following order of namespaces.


A. Enclosed -> Global -> Built-in ->Local
B. Local -> Enclosed -> Global -> Built-in
C. Built-in->Local -> Enclosed -> Global
D. Global ->Local ->Built-in ->Enclosed
Ans.B

Que.109)If you don't call this method, anything you did is not reflect in the database.
A. Rollback()
B. Connect ()
C. Commit()
D. None of the above
Ans.C

Que.110)Which method is used to read single row from the result set of Sqlite3?
A. fetchone()
B. readone()
C. retrieveone ()
D. Both A & B
Ans.A

Que.111)Which of the following is correct way of importing module?


A. Import Module_name
B. From Module_name import attribute
C. Import Module_name as Alias
D. All of the above
Ans.D

Que.112)What is the correct way to execute query in python sqlite3?


A. sqlite.execute.query
B. sqlite.execute(query)
C. sqlite.run.execute.query
303 - Database Handling Using Python SY BCA SEM 3

D. None
Ans.B

Que.113)sqlite3 in python is the module by which we can handle-


A. Database
B. GUI
C. CLI
D. Connectivity
Ans.A

Que.114)Which method among following is used for displaying only one resultset from database in
sqlite?
A. fetchmany( )
B. fetchno( )
C. fetchall( )
D. fetchone( )
Ans.D

Que.115)Which among following function is used to close the database from python?
A. exit( )
B. def( )
C. disconnect( )
D. close( )
Ans.D

Que.116)Which of the following is correct syntax of connect( ) function in sqlite3?


A. sqlite.connect( )
B. sqlite.connect.database
C. sqlite.connect(database)
D. None of above
Ans.C

Que.117)Which of the following is not the function of the sqlite3 in python?


A. connect( )
B. close( )
C. execute( )
D. many( )
Ans.D

Que.118)Correct way to import the sqlite3 in the program ?


A. import sqlite3
B. import sqlite3 as s
C. from sqlite3 import
D. All of the above
Ans.D
303 - Database Handling Using Python SY BCA SEM 3

Que.119)Correct way to run the query in Python sqlite3 is :


A. sqlite3.execute.query
B. sqlite3.execute(query)
C. sqlite.run.execute(query)
D. None of the above
Ans.B

Que.120)What is the correct statement about the RawQuery() function in sqlite3 in python ?
A. It is used to fetch the row from the table
B. It is used to execute the select query in the table
C. It is undefined function in python sqlite3
D. 1 and 2
Ans.C

Que.121)Which of the following function are used to close the database?


A. exit()
B. def()
C. disconnect()
D. close()
Ans.D

Que.122)Which of the following is not the function of the sqlite3 in python ?


A. connect()
B. close()
C. execute()
D. raw()
Ans.D

You might also like