> For the complete documentation index, see [llms.txt](https://ga0-2.gitbook.io/seifxr10anz-content/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ga0-2.gitbook.io/seifxr10anz-content/week-7/day-1-intro-to-python/python.md).

# Python

## Why learn Python?

![Relevant XKCD](https://imgs.xkcd.com/comics/python.png)

Python is a general purpose programming language. In addition to web application development, Python is widely used in Data Science, Artificial Intelligence, and Machine Learning.

It is also a popular teaching language partly because of the simplicity and high-readability of its syntax. MIT and UC Berkeley, among others, use it as their introductory language for Computer Science.

Python is often described as a batteries-included language because it ships with a comprehensive standard library. And if a feature you need is not in the standard library, there will most likely be a mature and battle-tested library for it on the Python Package Index (PyPi).

#### Popular Packages

#### Web Application Development

* [Django](https://www.djangoproject.com)
* [Flask](https://flask.palletsprojects.com/)
* [FastAPI](https://fastapi.tiangolo.com/)

#### Data Science

* [Pandas](https://pandas.pydata.org/)
* [Matplotlib](https://matplotlib.org/)
* [SciPy](https://scipy.org/)

#### Artificial Intelligence/Machine Learning

* [PyTorch](https://pytorch.org/)
* [Scikit-learn](https://scikit-learn.org/)
* [PyTorch](https://pytorch.org/)

#### Learning a New Language

Since you already know JavaScript, you will find it much easier to learn new languages by comparing how similar concepts are implemented differently. Here's a small example of how the same function with the same logic is written in both JavaScript and Python. This is just a sneak peek. We will discover more of these differences as we dive deeper into Python.

**JavaScript**

```javascript
const fibonacci = (num) => {
  let a = 1, b = 0, temp
  while (num >= 0) {
    temp = a
    a = a + b
    b = temp
    num--
  }
  return b
}
```

**Python**

```python
def fibonacci (num):
    a, b = 0, 1
    while num >= 0:
        a, b = a + b, a
        num -= 1
    return b
```
