Annachi Kadai
In Tamil Nadu there was shop called Annachi Kadai. The owner of the shop is Pandiyan. Now we learn Python using this case study.
Morning:
In the early morning the goods for shop will come. Then Pandiyan will take a note on the goods.
One day the goods came to his shop and he take a note on it. They are:-
inventory = {
"apples": 20,
"bananas": 30,
"carrots": 15,
"milk": 10
}
He want to check the list.
print(inventory)
{
'apples': 20,
'bananas': 30,
'carrots': 15,
'milk': 10
}
Noon:
As the time going the delivery also increases. So he add more inventories.
inventory["bread"] = 25
inventory["eggs"] = 50
Then he want to check the list
print("Updated Inventory:", inventory)
Updated Inventory: {'apples': 20, 'bananas': 30, 'carrots': 15, 'milk': 10, 'bread': 25, 'eggs': 50}
Afternoon:
Then in the afternoon the quantities of the goods is going less. So he buyed some goods and he want that to add it on the list.
inventory["apples"] += 10
inventory["milk"] += 5
Then he want to check the list
print("Inventory after Restocking:", inventory)
Inventory after Restocking: {'apples': 30, 'bananas': 30, 'carrots': 15, 'milk': 15, 'bread': 25, 'eggs': 50}
Evening:
In evening many of goods have sold. So he want to remove it from the list.
del inventory["carrots"]
then he want to check the list.
print("Inventory after Removal:", inventory)
Inventory after Removal: {'apples': 30, 'bananas': 30, 'milk': 15, 'bread': 25, 'eggs': 50}
Night:
Before closing the shop. He wants to check the inventory is the inventories are correct.
is_bananas_in_stock = "bananas" in inventory
is_oranges_in_stock = "oranges" in inventory
print(f"Are bananas in stock? {is_bananas_in_stock}")
print(f"Are oranges in stock? {is_oranges_in_stock}")
Are bananas in stock? True
Are oranges in stock? False
This things only we learnt in the python class.
Thank You
Top comments (0)