Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Extraction of Information | Dictionary
Python Data Structures
course content

Course Content

Python Data Structures

Python Data Structures

1. List
2. Dictionary
3. Tuple
4. Set
5. For deleting

bookExtraction of Information

Let's build a dictionary called student.

12
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} print(student)
copy

This dictionary includes three key-value pairs:

KeyValue
'first name''Ann'
'last name''Elliot'
'city''New York'

In the dictionary, you can retrieve an item using its key. Here's an example.

123
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} city_of_student = student['city'] print(city_of_student)
copy

In the code provided, Python searches for the value associated with the 'city' key in the student dictionary and assigns this value to the city_of_student variable.

Time to get hands-on!

Task

You're working with the following dictionary:

Display the values for the keys Turkey and Malta.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 3
toggle bottom row

bookExtraction of Information

Let's build a dictionary called student.

12
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} print(student)
copy

This dictionary includes three key-value pairs:

KeyValue
'first name''Ann'
'last name''Elliot'
'city''New York'

In the dictionary, you can retrieve an item using its key. Here's an example.

123
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} city_of_student = student['city'] print(city_of_student)
copy

In the code provided, Python searches for the value associated with the 'city' key in the student dictionary and assigns this value to the city_of_student variable.

Time to get hands-on!

Task

You're working with the following dictionary:

Display the values for the keys Turkey and Malta.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Section 2. Chapter 3
toggle bottom row

bookExtraction of Information

Let's build a dictionary called student.

12
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} print(student)
copy

This dictionary includes three key-value pairs:

KeyValue
'first name''Ann'
'last name''Elliot'
'city''New York'

In the dictionary, you can retrieve an item using its key. Here's an example.

123
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} city_of_student = student['city'] print(city_of_student)
copy

In the code provided, Python searches for the value associated with the 'city' key in the student dictionary and assigns this value to the city_of_student variable.

Time to get hands-on!

Task

You're working with the following dictionary:

Display the values for the keys Turkey and Malta.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

Let's build a dictionary called student.

12
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} print(student)
copy

This dictionary includes three key-value pairs:

KeyValue
'first name''Ann'
'last name''Elliot'
'city''New York'

In the dictionary, you can retrieve an item using its key. Here's an example.

123
student = {'first name': 'Ann', 'last name': 'Elliot', 'city': 'New York'} city_of_student = student['city'] print(city_of_student)
copy

In the code provided, Python searches for the value associated with the 'city' key in the student dictionary and assigns this value to the city_of_student variable.

Time to get hands-on!

Task

You're working with the following dictionary:

Display the values for the keys Turkey and Malta.

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Section 2. Chapter 3
Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
some-alt