Python_Info
Python_Info
1
Operators
1. Arithmetic Operators
Symbol Operation
+ Addition
- Subtraction
/ Division
// Integer Division
% Remainder
** Power
We can also use different Math Functions using the built-in math library such as:
• math.pi
• math.e
• math.sqrt
• math.pow
• math.sin
• math.cos
• math.tan
2
2. Boolean Operators
1) And
2) Or
3) Not
3. Comparison Operators
Symbol Operation
> Greater Then
< Less Then
>= Division
<= Integer Division
== Remainder
3
Lists
A list is a series of changeable elements
Syntax for list is [....]
1. Indexing
2. Slicing
4
3. Nested Lists
4. List Functions
Different functions can be used on list to change, delete or insert new elements
Tuples
Tuples are like lists, except that they cannot be modified once created, that is they are
immutable.
Syntax for tuples is (....)
5
Dictionaries
Dictionaries are also like lists, except that each element is a key-value pair.
syntax for dictionary is {key1 : value1, ......}
6
Annexure A - Python Installation and Jupyter Notebook
Python Installation and Jupyter Notebook
To start working with Python 3, you will need to have access to the Python interpreter.
Select a destination folder to install Anaconda and click Next. Install Anaconda to a directory
path that does not contain spaces or Unicode characters
8
Step 6: Launch Jupyter Notebook
Click on new notebook to create your first notebook and start using and learning python
9
Colab / Jupyter Notebook Interface
2. Files: Here you will be able to upload datasets and other files from both your computer
and Google Drive
3. Code Snippets: Here you will be able to find prewritten snippets of code for different
functionalities like adding new libraries or referencing one cell from another.
4. Run Cell: This is the run button. Clicking this will run any code that is inserted in the
cell beside it. You can use the shortcut shift+enter to run the current cell and exit to a
new one.
5. Table of Contents: Here you will be able to create and traverse different sections inside
of your notebook. Sections allow you to organize your code and improve readability.
6. Menu Bar: Like in any other application, this menu bar can be used to manipulate the
entire file or add new files. Look over the different tabs and familiarize yourself with
the different options. Make sure you know how to upload or open a notebook and
download the notebook (all these options are under “File”).
7. File Name: This is the name of your file. You can click on it to change the name. Do
not edit the extension (.ipynb) while editing the file name as this might make your file
unopenable.
8. Insert Code Cell: This button will add a code cell below the cell you currently have
selected.
9. Insert Text Cell: This button will add a text cell below the cell you currently have
selected.
10. Cell: This is the cell. This is where you can write your code or add text depending on
the type of cell it is.
11. Output: This is the output of your code, including any errors, will be shown.
12. Clear Output: This button will remove 10 the output.
12. Ram and Disk: All the code you write will run on Google’s computer, and you will
only see the output. This means that even if you have a slow computer, running big
chunks of code will not be an issue. Google only allots a certain amount of Ram and
Disk space for each user, so be mindful of that as you work on larger projects.
13. Link to Cell: This button will create a URL that will link to the cell you have selected.
14. Comment: This button will allow you to create a comment on the selected cell. Note
that this will be a comment on (about) the cell and not a comment in the cell.
15. Settings: This button will allow you to change the Theme of the notebook, font type,
and size, indentation width, etc.
16. Delete Cell: This button will delete the selected cell.
17. More Options: Contains options to cut and copy a cell as well as the option to add
form and hide code.
11