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:
- Takes your python code.
- Read the first line.
- Translate it to what computers understand.
- Execute the translated result.
- Computer act upon it.
- It goes to the next line.
- If there is more code, it repeats steps 3 to 6 until it finishes executing your python code.
[!NOTE]
Number systems: binary, octal, decimal, hexadecimal
Windows
After it finished downloading, open the downloaded file.
Then you must check the option to add python to your path:
Allow python installer make changes on your device:
Confirm python installation:
Open CMD:
Type python --version
and hit enter:
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
- Download it from here.
-
Open it and accept terms of service:
-
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”:
.
-
Create its icon on desktop if you like, but those two other options will make your life much much easier:
Configurations
-
Choose a theme:
-
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
-
Create a new directory/folder on your desktop and call it “projects”:
-
Open it and inside it create a new directory called “HelloWorld”.
# BTW these are naming conventions are commonly used by many developers:
-
Open “HelloWorld” with VSCode.
You can do it inside file explorer:
Or through VSCode:
Creating a virtual environment
- For your Python projects we need to create what is called virtual environment which is necessary.
- You can have multiple Python project which use different version of Python, thus you cannot every time for every project just reinstall it, right?
- We also might install 3rd party libraries, in which we do not wanna pollute our global environment.
- Open Command Palette and type “Python create Environment”:
- Press enter.
- Wait until it is done creating your virtual environment:
- You can see that now your virtual env is dictating which Python version should be used in that project:
VScode shortcut keys
- Press
ctrl + z
to undo your changes. - Press
ctrl + y
to redo. - Press
ctrl + d
to kill a REPL. - Press
ctrl + `
to open terminal (it is called command prompt in windows): -
Press
ctrl + shift + p
to open “command palette”..
-
Here we can do things like opening a REPL (learn more about REPL here).
-
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:
- Install VSCode on windows: search in google “Install VSCode on Windows”.
- How to configure newly installed VSCode for Python in Windows: Search in Google: “VSCode + windows + python”.
- How to know which short cut does what in VSCode. Google “VSCode shortcuts” or “VSCode shortcuts cheat sheet”.
YouTube/Aparat
Python
- “Python” is actually a category of snakes:
- It’s not the name of a specific species.
- It refers to a family of snakes called Pythonidae.
- Known for their large size & non-venomous constriction method of hunting.
- But here we are talking about a programming language :).
- BTW the language is named after the BBC show “Monty Python’s Flying Circus”.
Why Python
Powerful
-
Can be extended/combined with other programming languages.
Imagine you have a big Lego set with pieces that build almost anything, but there are a few things you want to make that need super-special pieces that aren’t in the set. So, you ask someone who has those special pieces (like shiny or super-strong ones) to build those parts for you. Then, you add them to your Lego set, and now you can build even cooler stuff!
-
# Extensive standard library; i.e. large collection of modules and packages built into the language.
Versatile
-
Can be used in different fields, domains, or types of applications.
-
Runs everywhere.
Easy to learn
- Some blogs, podcasts:
- Here are some online courses:
- And if you had any question you can ask in:
Talk more technical
- Is equipped with efficient high-level data structures.
-
Has an effective approach to Object-Oriented Programming.
-
Simplicity and readability: no steep learning curve.
- Flexibility with multiple paradigms: sometimes you need to mix and match.
-
# Built-in support for OOP principles.
-
-
Dynamically typed: no need to explicitly declare variable types, resulting in a faster and easier development experience.
- Interpreted programming language.
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
- https://checkio.org.
- https://www.afterhoursprogramming.com/tutorial/python/python-quiz.
- https://www.practicepython.org.
- https://pychallenger.com.
Refs
- https://wiki.python.org/moin/BeginnersGuide.
- https://docs.python.org/3/tutorial/index.html.
- https://wiki.python.org/moin/BeginnersGuide/Overview.