Find the output of the following Python Code: def FruitMob(): stock =…

2026

Find the output of the following Python Code:

def FruitMob():
stock = {"Apple": 50, "Banana": 20}
info = ("Fruit", "Inventory")
# Update dictionary
stock["Apple"] = stock["Apple"] - 10
stock["Orange"] = 30
# Loop and logic
for key in sorted(stock.keys()):
if stock[key] > 25:
print(key, ":", "High")
else:
print(key, ":", "Low")
print("Category:", info[0])

FruitMob()

Show answer & explanation
  • Dictionary stock = {"Apple":50, "Banana":20} and tuple info = ("Fruit","Inventory") are defined.

  • stock["Apple"] = stock["Apple"] - 10 ⇒ Apple value becomes 40.

  • stock["Orange"] = 30 ⇒ a new key-value pair is added.

  • sorted(stock.keys()) ⇒ keys in alphabetical order: Apple, Banana, Orange

  • Loop with condition:

    • Apple (40) ⇒ High

    • Banana (20) ⇒ Low

    • Orange (30) ⇒ High

  • info[0] ⇒ prints "Fruit"

  • Final Output:

    Apple : High  
    Banana : Low  
    Orange : High  
    Category: Fruit

Explore the full course: Hpsc Pgt Computer Science