Python

Write an awesome doc for Python. A very nice an practical one extracted from Python official documentation.

View on GitHub

Installing Python Interpreter

What is an Interpreter?

You might wanna ask what is interpreter, in the layman’s terms (tell me like i am 5), it is a software that:

  1. Takes your python code.
  2. Read the first line.
  3. Translate it to what computers understand.
  4. Execute the translated result.
  5. Computer act upon it.
  6. It goes to the next line.
  7. If there is more code, it repeats steps 3 to 6 until it finishes executing your python code.

Interpreter as translator

[!NOTE]

Number systems: binary, octal, decimal, hexadecimal

Number systems

Windows

Downloading Python for Windows

After it finished downloading, open the downloaded file.

Opening file

Then you must check the option to add python to your path:

First page of python installer

Allow python installer make changes on your device:

allow installer to install python

Confirm python installation:

Open run

Open CMD:

Open CMD

Type python --version and hit enter:

Printed python version in terminal

IDE – VSCode

There might be others who use things like PyCharm, Intellij IDEA. BTW Python wiki also has somethings to say about this. So if you’re interested in their recommendations please read this.

[!NOTE]

IDE stands for Integrated Development Environment.

Download & installation

  1. Download it from here.
  2. Open it and accept terms of service:

    accepting terms of service

  3. Pick a location on your hard drive if you like, but like I’ve already suggested in the folowing screenshot, do not change if you do not have any reason to do so and just click on “Next”:

    VSCode install location

  4. Click next.
  5. Create its icon on desktop if you like, but those two other options will make your life much much easier:

    Add some actions to your right click

  6. CLick on Install
  7. alt text

Configurations

  1. Choose a theme:

    Choose a theme

  2. Install “Python” extension for VSCode. This will give you stuff like:

    • Intellisense.
    • Debugging.
    • Formatting, linting, code navigation, refactoring, variable explorer, test explorer, and other convenience you might need while coding.

    Learn more about necessary extension in VSCode for coding in Python here.

Create a new python project

  1. Create a new directory/folder on your desktop and call it “projects”:

    alt text

  2. Open it and inside it create a new directory called “HelloWorld”.

    # BTW these are naming conventions are commonly used by many developers:

    naming conventions

  3. Open “HelloWorld” with VSCode.

    You can do it inside file explorer:

    alt text

    Or through VSCode:

    alt text

Creating a virtual environment

  1. Open Command Palette and type “Python create Environment”: Create venv
  2. Press enter.
  3. Wait until it is done creating your virtual environment: Create venv in process
  4. You can see that now your virtual env is dictating which Python version should be used in that project: alt text

VScode shortcut keys

Final words

Do not be afraid of reading docs. I wanna show you how you could accomplish same results by just reading VSCode’s official documentations:

  1. Install VSCode on windows: search in google “Install VSCode on Windows”.
  2. How to configure newly installed VSCode for Python in Windows: Search in Google: “VSCode + windows + python”.
  3. How to know which short cut does what in VSCode. Google “VSCode shortcuts” or “VSCode shortcuts cheat sheet”.

YouTube/Aparat

Python

Why Python

Powerful

Versatile

Easy to learn

Talk more technical

So what now?

First we’re gonna touch the most noteworthy aspects of Python. By the end of this journey we will be able to read and understand Python. Then we can jump into next section which is libraries that we need.

[!NOTE]

My goal here is to equip you with as much as arsenal I can so when you’re out fighting your own battle you know how to read docs, ask questions, solve your problems and be a good developer.

Download and print this cheatsheet

Resources to practice Python

Refs

YouTube/Aparat