Page 10 - PYTHON-12
P. 10
31. Predict the output of the following code: (3)
(a) products = {
"Laptop": 1000,
"Smartphone": 600,
"Tablet": 300,
"Headphones": 150
}
discounted_products = {}
for product, price in products.items():
discounted_price = price * 0.9 # Apply a 10% discount
discounted_products[product] = discounted_price
print(discounted_products)
OR
(b) matrix = [
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]
result = []
for i in range(len(matrix)):
row_sum = 0
for j in range(len(matrix[i])):
row_sum += matrix[i][j]
result.append(row_sum)
print(result)
Ans. (a) {'Laptop': 900.0, 'Smartphone': 540.0, 'Tablet': 270.0, 'Headphones': 135.0}
OR
(b) [6, 15, 24]
Section D
32. Consider the given table STUDENT: (4)
Table: STUDENT
Note: The table contains more records than shown here.
(a) Write the following queries:
(i) To display the records in alphabetical order as per the name of the student.
(ii) To display the average marks of Delhi students.
(iii) To display the details of students whose names end with the letter ‘a’.
(iv) To display the total number of students studying in class XI or XII.
OR
(b) Write the output:
(i) Select * from STUDENT where gender = 'F' and marks>350;
(ii) Select RollNo, DOB, City from STUDENT where Marks between 200 and 300;
(iii) Select Min(Marks ) from STUDENT;
(iv) Select Name, Marks from STUDENT where city IN ('Agra', 'Dubai');
Appendices A.41