How to write and execute Python code in 2022
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
To run Python code, you will need to execute the script from your terminal using the Python Interpreter.
The latest version of the Python interpreter can be installed from the main Python website here.
Python can be written with any text editor out there.
However, the vast majority of natively installed text editors won't be the best solution for you to write code.
There are many great text editors made especially for coding.
Those "made for coding" text editors are called integrated development environments or IDE.
Here is a list of the few that are great for coding in Python as of today:
- Visual Studio Code (Free) - Made by Microsoft
- Atom (Free) - Made by Google
- Sublime Text (Free / Paid)
- PyCharm (Free / Paid)
Visual Studio Code is great and the IDE that a lot of beginner falls back to.
Write .py files
What are .py files? It's basically the same thing as .txt files but ends with .py.
It gives the information to your operating system that those files contain Python code and that they can be run by the Python interpreter.
We usually call a .py file a Python script.
Here is an example of Python script
How to execute a Python script
Once we have our Python script ready, we execute it in terminal like so:
Here you are! You now know how to write Python code and how to execute it.
More on fundamentals
If you want to know more about Python fundamentals without headaches... check out the other articles I wrote by clicking just here:
Land Your First Data Science Job
A proven roadmap to prepare for $75K+ entry-level data roles. Perfect for Data Scientist ready to level up their career.
Related Articles
Continue your learning journey with these related topics
Master Data Science in Days, Not Months 🚀
Skip the theoretical rabbit holes. Get practical data science skills delivered in bite-sized lessons – Approach used by real data scientist. Not bookworms. 📚