Page 17 - PYTHON-12
P. 17
10. Write the missing statement to complete the following code. (1)
fileobj = open("filehandling.txt", "r")
content = fileobj.read()
____________________ #Moving the cursor back to the beginning of the file
first_line = fileobj.readline()
print("First line:", first_line)
fileobj.close()
(a) fileobj.seek(0)
(b) fileobj.close()
(c) fileobj.readline()
(d) fileobj.seek(1)
Ans. (a) fileobj.seek(0)
11. State whether the following statement is True or False:
You can use multiple except blocks to handle different types of exceptions separately. (1)
Ans. True
12. What will be the output of the following code? (1)
def add_to_total():
global total
total += 50
def reset_total():
total = 100
total = 0
reset_total()
add_to_total()
print("Total:", total)
(a) Total: 150
(b) Total: 100
(c) Total: 50
(d) Error
Ans. (c) Total: 50
13. Which SQL command would you use to delete a database named COMPANY? (1)
Ans. DROP DATABASE command will be used to delete the database, i.e., DROP DATABASE COMPANY;
14. What will be the output of the given query? (1)
SELECT * FROM employees WHERE email LIKE '%@gmail.com';
(a) Details of employees with email addresses that contain ‘@gmail.com’
(b) Details of employees with email addresses starting with ‘@gmail.com’
(c) Details of employees with email addresses that end with ‘@gmail.com’
(d) Details of employees with email addresses that contain ‘gmail’
Ans. (c) Details of employees with email addresses that end with ‘@gmail.com’
Model Test Paper (Solved) A.3