Inventory System

Medium Dictionaries PRO
🔒 Login to Unlock

Problem Statement

Write a Python program to simulate an inventory system that updates item quantities and prints the sorted inventory dictionary.

Input Format

Item name and quantity to add/update separated by space.

Output Format

Print the updated inventory sorted by item names.

Constraints

Valid item string and integer quantity

Sample Input

pen 50

Sample Output

{'books': 10, 'pen': 50, 'pencils': 20}

Explanation

Preload inventory `{'books': 10, 'pencils': 20}`, update or add the new quantity, and sort.

Starter Code

def update_inventory(item, qty):
    inv = {'books': 10, 'pen': 30, 'pencils': 20}
    # Write your code here
    pass

item, qty = input().split()
qty = int(qty)
print(update_inventory(item, qty))

Limits

  • Time Limit: 1s
  • Memory Limit: 256MB

Embedded C Programming

Updated: March 15, 2026
Intermediate

Embedded systems rely on efficient low-level programming to interact directly with hardware. In this course, you will learn how to write practical Embedded C programs used in real microcontroller-based systems. Rather than focusing only on theory, this course follows a practice-driven approach. Each lesson includes hands-on coding exercises that simulate real firmware development tasks used