So you’ve decided to learn a new programming language, you’ve done a bit of research, and you’re wondering whether Python is right for you? Or maybe you’ve determined to learn Python but aren’t really sure how to get started?
Rest assured, you’ve come to the right place! In this article, we’ll walk you through everything you need to know about Python, including what it is, why it’s useful, how to start coding in Python, and where to go from here.
What Is Python?
Python is a programming language that’s both compiled and interpreted. Python source files (.py) are run through a compiler and turned into bytecode files (.pyc), which are then executed in real-time by an interpreter.
This makes Python a high-level language, which means, in practical terms, you don’t have to write as much code to get as much done when compared to lower-level languages, and most Python code can be run on most platforms.
The benefits of this include greater code readability, more compact syntax, lots of flexibility in structuring your code, and faster development cycles. The trade-off is slower execution speed and less access to system-level calls.
Why Learn Python?
The best reason to learn Python is that its commitment to simplicity makes it one of the easiest programming languages to learn. One of the design principles behind Python is a commitment to making the act of programming as enjoyable as possible.
In short, Python is fun. For what other languages can you really say the same?
Of the many reasons to learn Python, standout ones include the vast number of tutorials available online, the fact that it enables rapid development, and the great demand for Python coders in the programming job market.
What Is Python Used For?
So much can be done with Python. Not only is it a fun language, it’s an intensely practical one that’s useful for creating all kinds of scripts and software.
We have several tutorials and resources you may find useful:
- Read and write to Google Sheets using Python
- Create GIMP automations with Python
- Develop and deploy websites with Python
- Build a basic web crawler using Python
- Code and control Arduino projects with Python
- Generate dummy data for testing products using Python
Overall, Python is used in web development, data analysis, microcontrollers, machine learning, game development, utility scripts, and rapid prototyping of software that will eventually be implemented in other languages.
Is Python Free?
Yes, Python is completely free and open source.
One of the best aspects of Python is its community-driven development, which is mainly done through GitHub (for checking out the language’s source code and submitting patches) and IRC (where users can discuss bugs, features, and other Python-related topics).
If you’re interested in contributing, check out the Python Developer’s Guide.
How Long Does It Take to Learn Python?
As with any programming language, it depends. The more experience you have and the more serious you are about learning, the faster it’ll be. But relatively speaking, it’ll take you less time to learn Python than most other languages.
On average, assuming daily practice, I’d expect 1-2 months for a beginner to start grasping the fundamental concepts of Python and 8-12 months to become proficient. An experienced programmer could probably pick up Python and be comfortably fluent within 3 months.
What’s the Difference Between Python 2.x and 3.x?
When Python 2.0 first came out in 2000, the language wasn’t too popular yet. As more developers started picking it up and using it seriously, flaws in the language became more apparent, but they couldn’t be fixed without major changes.
When Python 3.0 first came out in 2008, those major changes were introduced which led to several new features and improvements, but the language became incompatible with Python 2.x. This meant developers needed to refactor their code to take advantage of Python 3.0, and many of them weren’t willing to do that—including the developers of many popular third-party libraries and frameworks.
As a result, Python essentially split into two supported versions: the 2.x “legacy” branch and the 3.x “present” branch. The 3.x branch is the focus of active development, whereas the 2.x branch only receives bug fixes and security updates.
Nowadays, most of the community has moved on to Python 3.x, and that’s the version I recommend using. The only reason to use Python 2.x today is if your project relies on a library or framework that still doesn’t support Python 3.x.
How to Install Python on Windows
Installing Python on Windows is as simple as running the official installer:
- Download Python 3.x and run the installer.
- When prompted, make sure you tick the “Add Python 3.x to PATH” checkbox before clicking Install Now. I also recommend keeping the “Install launcher for all users” checkbox ticked.
- When prompted, click Yes for UAC permissions.
- Wait for installation to finish.
- At the end, click Disable path length limit, then click Yes for UAC permissions, then click Close to complete installation.
How to Install Python on Mac
Most Mac systems already come with Python installed, but it’s usually an outdated version that you shouldn’t use, especially if you’re planning on doing serious development (as opposed to just fiddling around for a hobby).
I recommend installing the latest version of Python 3.x using a tool called Homebrew, which is a Mac package management that lets you install software using Terminal.
- Open Terminal.app (using Spotlight is quickest).
- Visit the Homebrew site, copy the installation command, paste it into Terminal, and hit Enter. Follow the prompt to complete installation.
- Install Python with this command:
brew install python
- If you experience any issues with Python, you may need to re-link it using this simple command:
brew unlink python && brew link python
That’s it! If you’re interested, learn more about installing software with Homebrew.
How to Install Python on Linux
Not all Linux distributions come with Python included, but many of them do. For the ones that don’t, Python is often available in the distribution’s package manager, and installation is as simple as running one or two simple commands.
On Ubuntu 16.10 and later:
sudo apt update sudo apt install python3
On older versions of Ubuntu, I recommend this third-party PPA:
sudo apt-get install software-properties-common sudo add-apt-repository ppa:deadsnakes/ppa
Once added, update, then install Python.
sudo apt-get update sudo apt-get install python3.7
We covered Ubuntu because it’s the most common Linux distribution for desktop users. Unfortunately we can’t cover every other distribution out there, but a simple Google search will reveal that it’s just as easy on them too. This is one of the main reasons why Linux is the preferred OS for programmers.
How to Check Python Version
If you aren’t sure if Python is already installed, or if you know it is but aren’t sure which version you have right now, just run this command in your operating system’s relevant command-line terminal:
Some operating systems may need this command instead:
What Are the Best Python IDEs?
When working with Python, or any kind of programming in general, a solid code editor can make the difference between an enjoyable coding experience or weeks of hair-pulling frustration. To me, a good Python editor can either be a text editor with extensions or a dedicated Python IDE.
If you don’t know the difference, see our article on the difference between text editors and IDEs for programmers. I recommend going with an IDE.
There’s only one Python IDE worth mentioning, and that’s PyCharm. It’s available in a free Community version as well as a paid Professional version, which costs $9/mo (with discounts for yearly subscriptions).
The free Community version is more than enough for solo developers, equipped with features like smart syntax highlighting, code navigation, code refactoring, code inspections, graphical debugging, and integration with version control.
The paid Professional version adds advanced support for business-oriented web development, including code profiling, integration with web frameworks, remote development, and support for databases.
Python Text Editors
VS Code is an open-source and cross-platform text editor by Microsoft that’s built for both performance and productivity. Out of the box, it supports features like syntax highlighting, code debugging, code refactoring, code navigation, integration with version control, and more.
But its real power comes from third-party extensions like:
Sounds good? Start with these essential productivity tips for Visual Studio Code.
Python Online Shells
If you’ve come this far and still aren’t sure if Python is the right language for you, don’t go through the hassle of installing a bunch of software that you may not end up using. Instead, you’d be better off playing with Python in an online interactive shell.
An online interactive shell is basically just a website that lets you write Python code, execute it, and see what it does in real-time.
Note that interactive shells are nowhere near as full-featured as proper text editors or IDEs. I don’t recommend them for long-term projects—these are strictly for testing code and playing around. That said, here are a few nifty Python shells to try.
Learn Python and Take Things Even Further
Despite being one of the easier programming languages, Python isn’t easy. In addition to checking out these Python tutorial websites, you may want to try this 30-day Python challenge that’ll teach you the basics in no time at all.