Python Friday #1: Let’s Learn Python

With the New Year comes a new series of posts in my blog. I want to lean Python and try to document the steps as I go along. I hope this will help me better to remember all the obstacles I hit on the way. Let us see how this experiment turns out.

 

Motivation

I have these three reasons to learn Python and not any other language:

  1. It is nearly 4 years since I spend time learning a new language.
  2. I want to understand the Python code in the projects at work.
  3. Python is the most important language for machine learning.

With the blog series Python Friday, I enforce a deadline on myself so that I keep learning enough to create a blog post at the end of every workweek. I hope this will help me focus on learning and prevent me from getting too distracted along the way.

 

Python 2 or 3?

For a long time it looked as if the support for Python 2.x would finally end on the 1st January 2020. This date is now moved to April 2020. As far as it concerns my approach to learn Python, I will ignore Python 2 completely and only focus on Python 3.

 

Download and install Python

You find the official downloads at python.org/downloads/. I use Version 3.8.1 for Windows. The installer is small, but it has two things to look for. You should select the option to add Python to your PATH:

Check the option to add Python to the PATH variable

When the installation is finished, you can select if you want to disable the path length limit. I asked Google for what this means and found this answer on StackOverflow. You have to decide for yourself if you want to disable this limit or not:

Decide if you want to change the path limitation

You can now open a cmd window and type this to see if everything works:

At the first run this command printed 2.7.17. On my machine was already an older version of Python installed, that I had to remove first (using the add/remove software feature from Windows) until I got the expected version.

 

The Python Shell

Starting python without any parameter gives you the Python Shell, where you can execute Python code in an interactive environment (like irb for Ruby or the Immediate Window in the Visual Studio debugger). A HelloWorld does not need much code:

To not type the program over and over again, I can put the Python code into a file (Hello.py):

To execute this little program I only need to call python Hello.py in the command line:

 

Next

Now I have the basic setup ready to start learning the language itself. Getting at this point may look like not much, but it is the precondition for everything else. For next week, I want to find a tutorial that shows me the basic syntax of Python.

3 thoughts on “Python Friday #1: Let’s Learn Python”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.