Page 382 - Informatics_Practices_Fliipbook_Class12
P. 382
Section D
31. Preeti manages database in a blockchain start-up. For business purposes, she created a table named BLOCKCHAIN.
Assist her by writing the following queries: [4]
TABLE: BLOCKCHAIN
+----+----------+-------+--------+-------------------+
| id | user | value | hash | transaction_date |
+----+----------+-------+--------+-------------------+
| 1 | Steve | 900 | ERTYU | 2020–09–19 |
| 2 | Meesha | 145 | @345r | 2022–03–23 |
| 3 | Nimisha | 567 | #wert5 | 2020–05–06 |
| 4 | Pihu | 678 | %rtyu | 2022–07–13 |
| 5 | Kopal | 768 | rrt4% | 2021–05–15 |
| 6 | Palakshi | 534 | wer@3 | 2022–11–29 |
+----+----------+-------+--------+-------------------+
a. Write a query to display the year of oldest transaction.
b. Write a query to display the month of most recent transaction.
c. Write a query to display all the transactions done in the month of May.
d. Write a query to count total number of transactions in the year 2022.
32. Ekam, a Data Analyst with a multinational brand has designed the DataFrame df that contains the four quarter's
sales data of different stores as shown below: [4]
Store Qtr1 Qtr2 Qtr3 Qtr4
0 Store1 300 240 450 230
1 Store2 350 340 403 210
2 Store3 250 180 145 160
Answer the following questions:
a. Predict the output of the following python statement:
(i) print(df.size)
(ii) print(df[1:3])
b. Delete the last row from the DataFrame.
c. Write Python statement to add a new column Total_Sales which is the addition of all the 4 quarter sales.
OR
(Option for part c only)
Write Python statement to export the DataFrame to a CSV file named data.csv stored at D: drive.
Section E
33. Write suitable SQL queries for the following: [5]
a. To calculate the exponent for 3 raised to the power of 4.
b. To display current date and time.
c. To round off the value -34.4567 to 2 decimal place.
d. To remove all the probable leading and trailing spaces from the column userid of the table named user.
e. To display the length of the string 'FIFA World Cup'.
368 Touchpad Informatics Practices-XII

