# Creating a dictionary with at least 3 keys
my_dict = dict(fruit="apple", color="red", quantity=5)
# Printing the dictionary
print(my_dict)
# Starting dictionary
person = {"name": "Alice", "age": 30}
# Updating the age to 31
person.update({"age": 31})
# Printing the updated dictionary
print(person)
# Step 1: Create a dictionary
snack = {
"name": "popcorn",
"flavor": "butter",
"quantity": 10
}
# Step 2: Update the 'quantity' item
snack["quantity"] += 5
# Step 3: Add a new item for 'price'
snack.setdefault("price", 3.50)
# Print the updated dictionary
print(snack)
# Function to add two integers
def add_two_numbers(a, b):
sum_result = a + b
return sum_result
# Define the integers
num1, num2 = 5, 7
# Call the function and print the result
result = add_two_numbers(num1, num2)
print(f"The sum is: {result}")
{'fruit': 'apple', 'color': 'red', 'quantity': 5}
{'name': 'Alice', 'age': 31}
{'name': 'popcorn', 'flavor': 'butter', 'quantity': 15, 'price': 3.5}
The sum is: 12