Font size
WorksheetsPYTHON PROGRAMMING
Total questions: 20
Worksheet time: 10mins
The elements of a tuple are enclosed by ________ .
array bracket
square brackets
parenthesis
Curley brace
The __________ function is used to create Tuples from a list.
tuple
set()
list()
tuple( )
Which of the following is true for a tuple?
Tup = 1,2,3
Tup = (""1,"2)
Tup = (1,2,3,4)
None of the above
In a nested tuple, each tuple is considered as an ------------ .
element
variable
parameter
none of these
The ____________ will be useful to access all the elements in a nested tuple.
if condition
if...elif..else
switch case
for loop
Mandatory arguments required to connect any database from pyton
username, password, hostname, port , database name
user name, password
user name, password, host name
user name, password, host name, database name
Which method of cursor class is used to fetch records from the table
cur.fetchall()
cur.fetchone()
cur.fetchmnay()
cur.fetch()
What is the full form of SQL
Structured Quick Language
Structured Query Language
Structured Query Linking
Structured Query List
SQL command for list databases.
show all;
show all databases;
show databases;
show database;
select the correct statement in python to check SQL connectivity status.
if con_is.connected():
if con.is_connected():
if con_isconnected()
if con.is_connected
select the correct statement to install sql connector library
pip install mysql
pip install mysql.connect
pip install mysql-connector
pip install mysql-connect-python
Which library is used to connect python with MySQL? Write an import statement
import mysql _connector.connect
import mysql.connector() as msq
import mysql.connector
import mysql.connector()
Which function is used to create a cursor object?
cur=concursor()
cur=con.cursor()
cur=con.cursor
cur=con.mycurosr
select the correct sql statement for print records from a database table emp
select all from emp
select * from emp
select * from emp;
select * from emp( );
Examples for list data type
[1,2,3,4,5]
['S','H','R','U','T','H','I']
{1:"a",2:"b",3:"c",7:"d"}
('A','B','C','D')
colors = ["red", "green", "burnt sienna", "blue"]
print(colors[2])
What is the output of the above python code?
'blue'
It causes a run-time error.
'burnt sienna'
'green'
colors = ("red", "green", "burnt sienna", "blue")
print("yellow" in colors)
What is the result of the yellow in colors expression?
ValueError: 'yellow' is not in list
4
False
True
What’s the main difference between Python lists and tuples?
Lists can hold any data type and tuples can only contain int and str objects.
Lists are immutable and tuples are mutable.
Lists are mutable and tuples are immutable.
Lists are faster and tuples are slower.
Check Your Answer »
Identify the DDL commands
create,insert,drop,
update
Insert,update,delete,
select
create,alter,drop,
trucate,rename
grant,revoke
In Python, what happens if you don't commit changes after executing SQL queries?
The changes are automatically committed.
The changes are lost and not saved to the database.
The database connection is closed.
The cursor becomes unresponsive.
