# Task 1: Create a dictionary with at least 3 keys and print it
# Explanation: This dictionary represents a person with a name, age, and city of residence.
my_dict = {
"name": "John", # The person's name
"age": 25, # The person's age
"city": "New York" # The person's city
}
print("Initial dictionary:", my_dict) # Printing the dictionary to see its contents
# Task 2: Start with a given dictionary, update the age, and print it
# Explanation: We start with the given dictionary, then update the age and print the updated dictionary.
person = {
"name": "Alice", # The person's name
"age": 30 # The person's current age
}
# Update age to 31
person["age"] = 31 # Modifying the 'age' key's value from 30 to 31
# Print the updated dictionary
print("Updated dictionary:", person) # Printing the updated dictionary to confirm the change
Initial dictionary: {'name': 'John', 'age': 25, 'city': 'New York'}
Updated dictionary: {'name': 'Alice', 'age': 31}
The length of the entered string is: 5
{'name': 'Ahaan', 'age': 25, 'is_student': False, 'Thomas': {'name': 'Thomas', 'age': 23, 'is_student': True}}