Home Introduction to Python
Post
Cancel

Introduction to Python

Python can be used as a calculator

1
1 + 1
1
## 2
1
2-3
1
## -1
1
6 / 2
1
## 3.0
1
3 * 4
1
## 12

Since Python is so widely used, there are many people who contribute to continuously improving and developing it. Let’s imagine Python as a base version. It can do basic calculations, but it requires extra efforts to do more complicated things. People have created extras or add-ons to help create shortcuts for more complicated specific tasks or functions. These ‘add-ons’ are called packages. Packages can be imported to use to help make things easier. For example, there is a Python package called math that helps with basic mathematical operations. Let’s look at an example here of calling the package using the import command.

1
2
import math
math.sqrt(9)
1
## 3.0

Once it has been imported, it does not need to be re-imported for the rest of this document. You can also import multiple packages within the same document. We will get into more useful packages later on!

1
math.log(100)
1
## 4.605170185988092

For now, practice typing basic calculations into your Python terminal to get used to the syntax, and see how easy it is to calculate things!

This post is licensed under CC BY 4.0 by the author.