Page 32 - PYTHON-12
P. 32
7. If student_info is a dictionary as defined below, then which of the following statements will raise an
exception? (1)
student_info = {'id': 101, 'name': 'John', 'grade': 'A'}
(a) student_info['name'] = 'Jane' (b) student_info['grade'] = 'B'
(c) print(student_info.get('id')) (d) print(student_info['age'])
8. What does list.sort() method do in Python? (1)
(a) It returns a new sorted list and leaves the original list unchanged.
(b) It sorts the original list in ascending order and returns None.
(c) It sorts the original list in descending order and returns the sorted list.
(d) It raises an exception if the list contains mixed data types.
9. EMPLOYEES table contains 4 rows and 3 columns: EmployeeID, EmployeeName and Position, while PROJECTS
table contains 3 rows and 2 columns: ProjectID and ProjectName. What will be the cardinality and degree
of the resultant table after applying a Cartesian Product to both the tables? (1)
10. Write the missing statement to complete the following code: (1)
file = open("data.txt", "r")
data = file.read(200)
_________________ # Move the file pointer to the 50th byte in the file
new_data = file.read(100)
file.close()
11. State whether the following statement is True or False: (1)
The process of fixing errors in a program is called debugging.
12. What will be the output of the following code? (1)
x = 15
def modify():
global x
x = x + 5
print("Inside function:", x)
modify()
print("Outside function:", x)
(a) Inside function: 20 (b) Inside function: 20
Outside function: 15 Outside function: 20
(c) Inside function: 15 (b) Inside function: 15
Outside function: 15 Outside function: 20
13. Which SQL command is used to delete the entire table from a database? (1)
14. What will be the output of the given query? (1)
SELECT COUNT(DISTINCT album_no) FROM Music WHERE artist_name IS NOT NULL;
(a) The total number of distinct album_no values in Music table, regardless of whether artist_name is NULL
or not.
(b) The total number of album_no values where artist_name is NOT NULL, including duplicates.
(c) The total number of distinct album_no values where artist_name is NOT NULL.
(d) The total number of rows in Music table where artist_name is NOT NULL.
15. Which of the following is NOT a valid SQL data type? (1)
(a) VARCHAR (b) TEXT
(c) BOOLEAN (d) STRING
16. If you want to find the average salary of the employees in a department, which function would you
use? (1)
(b) AVERAGE() (b) AVG()
(c) MEAN() (d) SUM()
17. Which protocol is used to send emails? (1)
(a) FTP (b) SMTP
(c) HTTP (d) ICMP
Appendices A.47