# A.7: Python

## Learning Objectives

1. Python is more commonly used than JavaScript for data and algorithm-related work due to its built-in data manipulation libraries and simpler syntax
2. Learn basic Python syntax to be able to use Python for algorithm problems that are easier solved with Python's built-in libraries, such as algorithms involving queues and heaps

## Introduction

Python is commonly used in data and algorithm-related work due to its built-in data manipulation libraries and simpler syntax. Luckily, Python is conceptually very similar to JavaScript, and most translations from Python to JavaScript and vice versa are purely syntactical translations.

This submodule aims to help us learn Python through exercises to solve algorithm problems that are easier solved with Python, such as algorithms involving queues and heaps.

## Python Quirks

1. Python variables adhere to [function scope](https://www.w3schools.com/python/python_scope.asp), which means all local variables are accessible within the function in which they are declared. This is different from the [block scope](https://dev.to/sandy8111112004/javascript-introduction-to-scope-function-scope-block-scope-d11#:~:text=A%20block%20scope%20is%20the,only%20within%20the%20corresponding%20block.) that applies to `let` and `const` vars in JavaScript.
2. Python `==` works like JS `===`, in that both operators compare both value and data type.

## Exercises

The following are a collection of concise exercises from [learnpython.org](https://learnpython.org) (powered by [datacamp.com](https://datacamp.com)) that we believe will be helpful in learning Python for algorithms.

1. [Hello, World!](https://www.learnpython.org/en/Hello%2C_World!)
2. [Variables and Types](https://www.learnpython.org/en/Variables_and_Types)
3. [Lists](https://www.learnpython.org/en/Lists)
4. [Basic Operators](https://www.learnpython.org/en/Basic_Operators)
5. [String Formatting](https://www.learnpython.org/en/String_Formatting) (Here's a [nice article on String Interpolation](https://www.programiz.com/python-programming/string-interpolation))
6. [Basic String Operations](https://www.learnpython.org/en/Basic_String_Operations)
7. [Conditions](https://www.learnpython.org/en/Conditions)
8. [Loops](https://www.learnpython.org/en/Loops)
9. [Functions](https://www.learnpython.org/en/Functions)
10. [Classes and Objects](https://www.learnpython.org/en/Classes_and_Objects)
11. [Dictionaries](https://www.learnpython.org/en/Dictionaries)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://bc.rocketacademy.co/algorithms/a.6-python.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
