Lab Sheet 1
Lab Sheet 1
# Remove an item
shopping_list.remove("Bananas")
while True:
# Display menu options
print("\nMenu:")
print("1. Add a student and their grade")
print("2. Update the grade of a student")
print("3. Print all students with their grades")
print("4. Exit")
if choice == "1":
# Add a student and their grade
name = input("Enter the student's name: ")
grade = input("Enter the student's grade: ")
if name in student_grades:
print(f"{name} already exists with grade {student_grades[name]}.")
else:
student_grades[name] = grade
print(f"Added {name} with grade {grade}.")
else:
print("Invalid choice. Please select a valid option.")
# Usage
account = BankAccount("John Doe", 1000)
account.deposit(500)
account.withdraw(200)
account.display_balance()
# Usage
numbers = [10, 20, 30, 40, 50]
result = process_numbers(numbers)
print(f"Minimum: {result[0]}, Maximum: {result[1]}, Average: {result[2]:.2f}")
def display_inventory(self):
print("Current Inventory:")
for item, qty in self.items.items():
print(f"{item}: {qty}")
# Usage
inventory = Inventory()
inventory.add_item("Laptop", 10)
inventory.add_item("Mouse", 25)
inventory.remove_item("Laptop", 3)
inventory.display_inventory()