

fruits = ["apple", "banana", "cherry"]
print(fruits[0]) # 'apple'

dict = {"key 1": "value 1", "key 2": "value 2"}

person = {"name": "Ali", "age": 20}
print(person["name"]) # 'Ali'


student = {"name": "Ali", "age": 20}
student["major"] = "Software Engineering" # add
student["age"] = 21 # modify
print(student) # {'name': 'Ali', 'age': 21, 'major': 'Software Engineering'}


person = {}
person['first_name'] = 'Lina'
person['last_name'] = 'Chen'
person['age'] = 19
print(person) #{'first_name': 'Lina', 'last_name': 'Chen', 'age': 19}


alien = {"color": "green", "points": 5}
del alien["points"]
print(alien) # {'color': 'green'}


alien = {"color": "green", "points": 5}
print(alien["planet"])  # KeyError: 'planet'

alien = {"color": "green", "points": 5}
planet = alien.get("planet", "No planet assigned.")
print(planet) # No planet assigned.


# not good!
student = {"name": "Ali", "age": 21, "major": "Software Engineering"}
print(student["name"])
print(student ["age"])
print(student["major"])


# good!
student = {"name": "Ali", "age": 21, "major": "Software Engineering"}
for key, value in student.items():
    print(key, value)

student = {"name": "Ali", "age": 21, "major": "Software Engineering"}
for key in student.keys():
    print(key)

student = {"name": "Ali", "age": 21, "major": "Software Engineering"}
for value in student.values():
    print(value)

favorite_languages = {
'jen': 'python',
'sarah': 'c',
'edward': 'rust',
'phil': 'python'
}

for language in set(favorite_languages.values()):
    print(language.title())

for key in sorted(student.keys()):
    print(key)



"""
Task 1
Make a dictionary with 3 people and their favorite number.

Task 2
Print each person and their favorite number.

Task 3
Add one more person and their favorite number to the dictionary using assignment (=).

Task 4
Change the favorite number of one existing person.

Task 5
Delete one person from the dictionary using del.

Task 6
Loop through all people and print their names only (keys).

Task 7
Loop through all favorite numbers only (values).

Task 8
Add a new entry where one person has more than one favorite number (a list of numbers).

Task 9
Loop through the dictionary and print each person with all their favorite numbers.

Task 10
Add new information for each person: their country and major.
Now each person should have a small nested dictionary (person : {info}).

Task 11
Loop through the dictionary and print formatted sentences with each person’s name, country, and major.

Task 12
Add one more student with all details, then sort the names alphabetically and print them.

"""


