Kickstart to Python 3 (Extract)

Page 19

Chapter 2 • Built-in Data Structures

Chapter 2 • Built-in Data Structures In the previous chapter, we installed Python 3 on various platforms. We wrote a simple introductory program and learned how to run it in various ways. We also learned how to work with the interpreter (interactive) mode. This chapter was introductory and was not very heavy on programming. This chapter is a little bit more focused on programming (also known as coding). We will be introduced to various built-in data structures in Python. We will be focusing on the following topics in detail: • • • • •

IPython List Tuple Set Dictionary

Following this chapter, we will be comfortable with IPython and built-in data structures in Python.

2.1 IPython IPython means Interactive Python Shell. It is a program that provides us with more facilities than python's built-in interactive shell. We have to install it separately using the following command: pi@raspberrypi:~ $ pip3 install ipython

The command is the same for Windows and macOS. If you are installing it on a Linux distribution (like me), you may see the following message in the installation log: The scripts iptest, iptest3, ipython, and ipython3 are installed in '/ home/pi/.local/bin' which is not on PATH. Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location. This means we need to add the mentioned directory location to ~/.bashrc and ~/.bash_ profile files. We have to add the following line to both the files (so it works for login and non-login shells): PATH=$PATH:/home/pi/.local/bin

It will show a similar message for Windows too. We have to add the path of the directory mentioned in the installation log to the PATH variables (User and System variables, both) in Windows too.

● 19


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.