CBSE Class 12 Informatics Practices
Question 14 of 18
Practice Paper — Question 7
Back to all questions 7
Question Consider the dataframe SHOP given below:
Item Qty City Price
101 Biscuit 100 Delhi 10
102 Jam 110 Kolkata 25
103 Coffee 200 Kolkata 55
104 Sauce 56 Mumbai 55
105 Chocolate 170 Delhi 25
Write commands to:
(i) Write short code to show the information having city = "Delhi".
(ii) Calculate Qty * Price and assign to column 'Net_Price'.
(iii) Display Items of all rows.
(i)
info = SHOP[SHOP['City'] == 'Delhi']
print(info) Item Qty City Price
101 Biscuit 100 Delhi 10
105 Chocolate 170 Delhi 25
(ii)
SHOP['Net_Price'] = SHOP['Qty'] * SHOP['Price']
print(SHOP) Item Qty City Price Net_Price
101 Biscuit 100 Delhi 10 1000
102 Jam 110 Kolkata 25 2750
103 Coffee 200 Kolkata 55 11000
104 Sauce 56 Mumbai 55 3080
105 Chocolate 170 Delhi 25 4250
(iii)
items = SHOP['Item']
print(items)101 Biscuit
102 Jam
103 Coffee
104 Sauce
105 Chocolate
Name: Item, dtype: object