Page 24 - PYTHON-12
P. 24
(II) To display DONATIONS table sorted by Date of Donation in descending order.
(III) To display the distinct name of the donor from DONATIONS table.
(IV) To display the sum of Amount of all donations where Date of Donation is NULL.
OR
(B) Write the output of the following.
(I) SELECT Organization, SUM(Amount) AS Total_Donations FROM DONATIONS
GROUP BY Organization;
(II) SELECT * FROM DONATIONS WHERE Organization LIKE '%m%';
(III) SELECT Donor_ID, Donor_Name, Organization, Amount FROM DONATIONS
WHERE Amount BETWEEN 25000 AND 55000;
(IV) SELECT MAX(Amount) FROM DONATIONS;
Ans. (A) (I) Select Organization, sum(Amount) from donations group by
organization having sum(Amount)< 40000;
(II) Select * from donations order by Date_Of_Donation desc;
(III) Select distinct Donor_Name from donations;
(IV) Select sum(Amount) from donations where Date_Of_Donation IS NULL;
OR
(B) (I) Organization Total_Donations
Bless Orphanage 80000
Blinds' Society 65000
Mid-Day Meal Society 80000
(II) Donor_ID Donor_Name Organization Amount Date_of_Donation
D1123 Shreya Mid-Day Meal 80000 2024-02-10
Sharma Society
(III) Donor_ID Donor_Name Organization Amount
D1121 Sandeep Bansal Bless Orphanage 35000
D1124 Rahul Malhotra Bless Orphanage 45000
(IV) Max (Amount)
80000
33. A CSV file, ‘StudentGrades.csv’, contains the data of a survey. Each record of the file contains the following
data: (4)
• Student Name • Subject
• Grade (A, B, C…) • Percentage Score
For example, a sample record of the file may be:
[‘Manisha’, ‘Mathematics’, ‘A’, 92]
Write the following Python functions to perform the specified operations on this file:
(I) Read all the data from the file in the form of a list and display the records of students who scored more
than 85%.
(II) Count the number of records in the file.
A.10 Computer Science–XII