My guide to start learning programming in Python (for Business People)

Learning Python is easier thank you think. If you work in an office, it's also more valuable than you think. I wish I had started learning earlier. Here is my guide to help you get started.

Table of Contents

30 Mar 2020

learn-python

I believe everyone should learn programming as I wrote here:

everyone-should-learn-programming

And I have covered my story of how I came to learn programming aged 37 (never too late!) in:

#StartupPlaybook 01: How to bootstrap a Tech startup, without a Tech cofounder

Here I aim to share my guide of how to start learning Python in particular, coming from a business background. based on my own journey, trials and errors.

I will focus on the specific resources that have helped me the most to get into programming as a businessman, and a "business, man" (not sure everyone will get the reference 😂).

I wrote about the process I follow and the tools I use to learn - programming or other skills - in:

001-always-be-learning

Why learning to program with Python?

Learning to program, for business people, has direct and indirect benefits.

Direct benefits are what you can do and build with it.

Indirect benefits come in the form of understanding better the technology around you, and building or sharpening skills, that are very valuable in a business environment where Technology is everywhere.

What it can be used for

Knowing Python, or any similar programming language in general, is like a digital superpower. It enables you to:

  • do things you cannot do with existing programs
  • do some things faster than with existing programs
  • build things from scratch, doing just what you want it to do

"Things" is a broad term.

Because Python is a multi-purpose programming language, it can do a lot of digital "things". From simple scripts (tasks) on your own computer, building a website, web services or desktop applications.

If you are work with Excel and data a lot, learning Python will open a new world of possibilities to you.

What I have used it for

Let's be concrete though. Here are a few things I built in my 1st year of learning Python:

Automated invoice processing

Supplier sends PDF invoice to dedicated email address. A bot written in Python, extracts the data, checks a couple things, flags to a human if needed, and provides the data in a format that can be ingested by our system, and that of our client (accounting system or CRM).

Price engine & custom report generator.

Fetches data from various sources (e.g. in-house CRM database, in-house flight records database) to generate custom internal or external reports in XLSX format.

Data fetching

Daily login to a portal, download of a CSV file and parsing data into our database.

Hyper-personalised spam-safe emailing

Send hyper-personalised emails at scale, sent directly from the actual local email client (no difference with a manually written and sent email, so no more risk to be caught in spam filters).

Email finder

Find email addresses at scale with just first name, last name and company website (from excel list).

KPI Slackbot

Bot publishing in Slack daily metrics, with data fetched across various systems (e.g. in-house CRM, Dropbox, etc..).

Along with a flurry of useful scripts for my day-to-day, like:

  • splits PDFs with many pages into single page PDF files.
  • Formatting of Excel spreadsheets (so database exports look professional when sending to clients).
  • Happy password generator
  • etc..

Benefits for business people

Our world is getting more and more driven by or powered by Technology. By computers.

Computers have their own language - programming languages. (I won't go as low as the binary level, though you can get good explanations if you are interested with numerous articles online, for example "How Computers Work"

There are now more computers than human beings on Earth. If you imagine that computers "speak", programming languages are thus the most common language in the world.

Forget English, Chinese, French and Spanish :)

Computer languages power almost everything around us - and will do even more so in the future from autonomous driving to widespread office automation.

While I started to learn because of a critical need - I felt I was cornered and wanted my startup to work - I wish I had done so years (or even decades) earlier.

And believe now everyone should learn programming.

I see now all the benefits of learning to program. It helps you:

  • think more logically
  • structure things in a way that are more efficient
  • automate simple tasks yourself
  • see opportunities for automation and digitalisation you could not see before
  • understand how computers and programs work
  • understand the complexities and challenges of building software (and "Software is eating the world"!)
  • communicate better with technical people, and programmers in particular
  • hire programmers more wisely (be it freelancers or employees)
  • manage programmers
  • behave in a safer way with computers and on the internet

And understanding how machines (computers) work and communicate between each other, helps understand their potential and (current) limitations, while alleviating fears.

It's empowering.

And the key thing is:

You don't need to become a professional programmer to enjoy the benefits. Knowing even the basics of programming will already help you a lot.

In a world where jobs are being disrupted by Technology, those who will thrive most are those able to think and bridge the gap between Business and Technology.

Automate repetitive office tasks

This is what I think is the most valuable reason for office workers to learn programming.

As knowledge workers, a lot of daily tasks, but also wider processes in companies, rely on doing "things" with computers.

Understanding how programming works, opens the mind to what could be done more efficiently. What could be automated.

You can start by automating some of your own small tasks. But rapidly you will also start seeing what can be automated around you - so you can lead and contribute to the digital transformation and optimisation of your company.

Make sense of the data world

Data rules the business world now.

You might not want to become a Data Scientist (you would not be reading this), but knowing how to crunch a dataset, what can be done with data, and how, empowers you massively in the workplace.

So, let's start with Python...

Why Python?

When I decided to start learning, in August 2017, I looked at the different programming languages available.

I am here simplifying things:

The hierarchy of languages: high-level and low-level

A programming language can be "low-level" or "high-level".

Low-level languages

Low-level means it is very close to the binary language (0s and 1s) which is the "native language" of ALL computers. A low-level language will be fast to execute because it "talks" directly to the core of the computer.

A program written with a low-level language needs to be compiled. Meaning it needs to be packaged ("dressed" would be an analogy that comes to mind), so that the computer can execute it.

High-level languages

High-level means that the language will rely on a "translator" (an interpreter in Python speak) to translate the code you wrote (relying on English-based commands) for the computer to understand it in its "native language".

The execution will be slower because of the translation time, but fast enough for most applications.

High-level languages are therefore called "interpreted languages". Most of them can also be called "scripting languages" - because they are based on a script with logical steps to execute, just like a human would read a script to execute a task. Each script is like a small program (up to a few thousands lines of code).

If you are reading this, you will want to choose a high-level language.

Here are the main candidates:

An overview of high-level languages

You can see here the popularity of programming languages - current and historical:

PYPL PopularitY of Programming Language index

The tool is "analysing how often language tutorials are searched on Google. The more a language tutorial is searched, the more popular the language is assumed to be. It is a leading indicator. The raw data comes from Google Trends."

Each language has strengths and weaknesses, depending on what you want to achieve.

Some of the popular options are (popularity as of Mar 2020, worldwide):

Java (19%)

learn-python_popularity_java.png
It was designed to follow the “Write Once, Run Anywhere” principle.

It's the language of choice for Android devices. It is/was also the coding language of choice for enterprise-level software. It’s a good multi-purpose coding language because it can be used cross-platform (meaning it’s just as easily used on smartphone apps as on desktop apps)

Javascript (8%)

learn-python_popularity_javascript.png
Don't get the name to fool you (it had me for years!), Javascript is nothing like Java. It's a scripting language stemming from C (a popular low-level language) and is used mainly in browsers.

It allows developers to make their websites interactive and dynamic. It’s easy to get started with since it’s already built into most web browsers. There are also a lot of useful JavaScript libraries to make development easier.

PHP (6%)

learn-python_popularity_php.png
PHP was designed as a language for Web Servers and has been prevalent for web development and as a general-purpose programming language, it’s relatively easy to learn, flexible, and can be used in collaboration with HTML. It’s often used in data-heavy websites and is the language behind Facebook and WordPress.

PHP is an open source code, primarily used for web development (a.k.a. creating web pages.) PHP was created to streamline web page creation. It’s a fairly simple programming language that can be picked up quickly.

R (3%)

learn-python_popularity_r.png
Launched in the early 90s, R is for statistical computing. It is widely used among statisticians and data scientists for developing statistical software and data analysis.

Swift (2%)

learn-python_popularity_swift.png
Apple's programming language, introduced in 2014, to foster the development of apps for its ecosystem of products.

Go (1%)

learn-python_popularity_go.png
Go has been developed at Google and released in 2009.

Perl (0.5%)

learn-python_popularity_perl.png
Developed in the late 80s to make report processing easier. It was very popular a decade or more ago, but its popularity has steadily decreased.

Ruby - and Ruby on rails (1%)

learn-python_popularity_ruby.png
Ruby was developed in the mid 90s in Japan. It is one of the simpler programming languages to learn and is often used as a stepping stone to Ruby on Rails (a framework that makes it easy to build apps and websites in Ruby).

It was developed to be both fun to code, and to increase productivity. It is known for being easy to read, and as a result many programmers recommend learning Ruby as your first coding language.

As I had been exposed to Ruby on Rails for a side project I worked on back in 2015 (TheSalesStack - a software discovery platform for Sales), I hesitated to go with Ruby to start with.

But the case for Python was much stronger, for me.

Python (30%)

Python is a powerful yet versatile, multi-purpose language. It can be used to do many things, from building automations, integrating systems, crunching big datasets, creating websites, and much more.

Python was released in 1990, and has gained popularity ever since. In the last couple of years it has become the most popular language in the world (in part due to its ease of learning, power and applications for businesses):

learn-python_popularity.png
In the last decade, it has become the de facto language for a lot of things in data science, AI and machine learning.

But it's also used my major Tech players, like Instagram, Pinterest, Spotify and Google.

Dropbox (a critical service for me over the last 10+ years), is built with Python. And it's where the original creator of the language ("BDFL" in the community - for Benevolent Dictator for Life, though he stepped down in 2018), Guido Van Rossum, currently works.

If you're curious, the name Python originates from the British surreal comedy group Monty Python, of which Guido was a fan. That is also why you will encounter a lot of Monty Python references when learning the language (eg using spam as name example, not related with the type of emails you hate, but with Monty Python's 1970 sketch.

Being a very high-level language, it is simple to learn and use, though quite slow.

Let's put "slow" in perspective though. It is slow compared to low-level languages, but still very fast for us humans. It can process a task in a fraction of the time it would take you to do something manually. You can test the free bots - written in Python - that I have released so far at OfficeBots.io (my 2nd startup).

Back in 2017, as my goal was to build process automations (my first big project at my first startup was to build an invoice processing automation, and I have a keen interest in AI & ML, combined with the need to start with an easy to learn language, Python was a no-brainer for me.

And so for the last 3 years, I have been a Pythonista (the name given to people who use the Python programming language).

Starting can feel tough - but the rewards are quick to come

I you have already tried learning programming, and quit - I understand.

But do not despair.

Like with meditation, just accept that sometimes you'll wander off the learning path. Acknowledge it, don't feel bad about it, and get back to it.

Python is easy to learn and rewarding, because it empowers you to build powerful things, with little code.

Here is what unlocked it for me:

Learn by reading

My approach when I start learning a new skill is to read about it.

Here are my recommendations.

The 1 book that "did it" for me - an eye-opening moment

The 1 book that changed everything for me was

Automate the Boring Stuff
by Al Sweigart

I wrote a blog post about it here:

Automate the Boring Stuff with Python

It was actually the 3rd book I read. The first two were very confusing, and I did not understand most of it.

So I'd suggest you to start with this one, as it is the only one I found, that helps put all the theory of other books in the context of business people.

Other books

After that:

"Learn Python 3 the Hard Way" - while you can buy it as a hard copy, you can also access all of its content here:

https://learnpythonthehardway.org/python3/

Which is helpful to navigate, and for copying/pasting snippets of code for you to try yourself.

Another one is:

"Learn Python in One Day and Learn It Well (2nd Edition): Python for Beginners with Hands-on Project"
https://www.amazon.co.uk/Learn-Python-One-Well-Hands/dp/1546488332/ref=tmm_pap_swatch_0

Labelled as "The only book you need to start coding in Python immediately", it does somewhat live up to its promise.

Learn with online courses

Using online courses, and in particular on Udemy, is a big part of my learning process.

I tried a few Python courses on the platform. One teacher in particular stood out for me with well designed courses, clearly articulated and explained: José Portilla.

You can see his courses here:

"Jose Portilla | Head of Data Science, Pierian Data Inc.| Udemy"
https://www.udemy.com/user/joseportilla/

I bought 9 courses from him đŸ€“

You can start with this one:

"Python Bootcamps: Learn Python Programming and Code Training"
https://www.udemy.com/course/complete-python-bootcamp

And/or this one:

"Complete Python 3 Masterclass Journey"
https://www.udemy.com/course/complete-python-3-masterclass-journey

The approach here is not to spend 10+ hours in a row glued to your screen, but take short lessons at your own pace (you can accelerate the videos), while either doing the exercises as he does them, or implement the learnings in your own small project (critical to have one to support your learning and have a personal goal).

Learn with websites

For some reason, I have not learned myself using these, but I know they are very popular. I guess my approach to learning is more to understand the basics, and then start learning by doing (ie working on a project).

Here are the main ones though - they all provide interactive lessons with daily practice.

"Learn to Code - for Free | CodecademyLearn the technical skills you need for the job you want."

(/)

"Learn Python - Free Interactive Python Tutorial"
https://www.learnpython.org/

"W3 Schools - Python Tutorial"
https://www.w3schools.com/python/

"Sololearn Python Course"
https://www.sololearn.com/Course/Python

Learn with mobile apps

At the beginning of my journey, the excitement of learning took over, and I wanted to learn any free time I had.

I used a couple apps that were both fun and useful for that:

SoloLearn / Learn Python

A learning app, based on short tutorials, quizzes, and the ability to see other students' comments when you get it wrong:

learn-python_sololearn01.jpeg
learn-python_sololearn02.jpeg
learn-python_sololearn03.jpeg
learn-python_sololearn04.jpeg
learn-python_sololearn05.jpeg

Available on your favourite app store.

Pythonista

If you want to use some of your commute time to keep learning, you can also use an IDE (more on that later) on your phone. It has some restrictions, but its handy to just test some snippets of code while on the move.

Here is an example of script I was writing and testing on the go back then:

learn-python_pythonista.jpeg

Learn with freelancers

Another approach I have used to learn various skills - programming included - is to hire low-cost freelancers (with a good command of english), as my online teachers.

Having a proficient person "on tap" to do screensharing sessions (I use Whereby these days, or Skype) or helping out when stuck on a particular challenge is very helpful and efficient.

Doing so, the focus is on writing code for a specific project, which helps put the learning in context.

I wrote more about how to find and hire freelancers here:

#CareerPlaybook 009: Outsourcing Tasks (are you still doing everything yourself?

Though I have always used Upwork so far to find online teachers, I might try soon this platform focusing on this use case (on-demand code mentoring):

"Codementor | Get live 1:1 coding help, hire a developer, & more"
https://www.codementor.io/

What you need

To just learn, you do not need to install anything. You can test short pieces of code within the learning app or website usually.

To get started doing though (ie your first project) - beyond logic, perseverance and curiosity - you will also need to install a few things on your computer.

  • The programming language's interpreter on your computer
  • Modules, as needed
  • An IDE (Integrated Development Environment), to help you code
  • A good text editor (one that at least highlights your code in colours), to quickly open files for inspection or small corrections

If some words in the list above throw you off, don't worry - they will make sense soon.

Let's dive into each of them:

Python

As mentioned above, Python is a high-level, interpreted language. So your computer needs to have the interpreter (translator) installed.

If you are on Mac (or Linux), it's preinstalled. Though you can start by ensuring it's up to date.

If you are on Windows, you need to install it.

In any case, you can find it here:

https://www.python.org/downloads/

Or if you are looking to learn Python specifically for data science, you can opt to install Anaconda instead, which installs Python, but also a bunch of other components that can be useful:

https://www.anaconda.com/distribution/

learn-python_anaconda.png

Though no worries, if you "just" install Python, you can later install selectively what you will need.

You can see https://docs.python.org/3/using/mac.html what gets installed when you install Python, but basically it adds a bunch of files to your computer, that will be used to interpret what you write in Python to translate it into commands to your computer:

learn-python_pathfinder.png

Note that I am showing here invisible files on my computer, so normally you wouldn't even see these.

Versions

The current version is 3.7. There are some major differences with version 2.x, so if you use the pre-installed version on your computer, just make sure it is a 3.x version.

IDE

Programming is really just writing text files with instructions.

So you can definitely write code just by using a text editor (more about them below).

But using a good Integrated Development Environment (or IDE for short) makes it so much easier.

An integrated development environment (IDE) is a software application that provides comprehensive facilities to computer programmers for software development. An IDE normally consists of at least a source code editor, build automation tools and a debugger.

https://en.wikipedia.org/wiki/Integrated_development_environment

Ensure you use a good IDE to make your first steps easier.

PyCharm

I use PyCharm myself (update since 2021, I'm using VS Code, much better - see NN: VS Code):

"PyCharm: the Python IDE for Professional Developers by JetBrains"
https://www.jetbrains.com/pycharm/

They have a free, open-source, Community Edition which has all you need to get started.

There is a bit of a learning curve, but it is very helpful, as it highlights code in colours that make it easier to understand it, makes all functions accessible easily, shows errors as you type, enables you to navigate your code quickly and much more.

Here is how it looks like:

learn-python_PyCharm01.png

(This is a small program I wrote to send emails on my behalf, using my email client/own server, and a spreadsheet to manage/keep track)

Jupyter Notebooks

Though I have not used it myself much, you can also use Jupyter Notebooks, especially when starting:

"Project Jupyter - The Jupyter Notebook is a web-based interactive computing platform. The notebook combines live code, equations, narrative text, visualizations, interactive dashboards and other media."
https://jupyter.org/

Here is a basic example of the interface:

learn-python_jupyter-notebook.png

Basically, this gives you the ability to write code and test it like by line, within your browser. Like a playground (or sandbox) where you can easily write and see results of what you are coding.

You can test it without having to install anything:

https://jupyter.org/try

Or directly install it on your computer, so everything runs locally (ie not on a web server):

https://jupyter.org/install.html

It is free, open-source, and often used by online teachers (like José Portilla) to illustrate their lessons.

Text editor

As mentioned, you could (and some pros do), write code solely with a text editor.

While I do not recommend it to beginners, having a good text editor is still very useful in many cases.

The default text editor that comes with your PC or Mac can be used, though specialist text editors will be much more helpful. For example by highlighting your code in different colours, depending on its properties (what it does).

Atom

After testing a few text editors over time, I settled on Atom:

"Atom - a hackable text editor for the 21st Century" (built by GitHub)
https://atom.io

At first, it does look like a standard text editor:

learn-python_atom01.png

But it has tons of settings that help you customise your experience with it:

learn-python_atom02.png

Along with packages you can install, to enhance it. Like to colour your Python code for better overview:

learn-python_atom03.png

Websites

There are a number of websites you will be regularly coming across in your learning journey. Here are a few:

Official Python documentation

"Welcome to Python.org - The official home of the Python Programming Language!"
https://www.python.org/doc/

This is a good starting point - after reading/learning the basics via books and online courses - where you can get more insights into each component (function) of Python.
It can be a bit obscure for the non-initiated though (or even the initiated), so it is just one resource in your arsenal.

Stackoverflow

The most popular Questions & Answers website for programming.

Basically, whatever question or issue you are facing as you learn programming, chances are someone else has posted a question about it and the answer(s) will help you.

"Stack Overflow | The World’s Largest Online Community for Developers!"
https://stackoverflow.com/questions

You can search directly there, but again, chances are that whatever coding-related question you ask to your favourite search engine, a Stackoverflow answer will be in the top results.

The community is incredibly helpful - though as mentioned, you might not even need to post your own questions often, as the answers probably already exists.

Library (or module) documentations

As we'll see, there are lot of libraries (or modules) in Python you can use freely.

First to clarify, a "library" in programming language is a generic term referring to code written by someone, to be reused by someone else. Just like... a library! :)

In Python speak, a module refers to a file containing Python functions, which you can import in your own code.

Each module has its own online documentation.

For example, I use the openpyxl module a lot in Python, which has been created to deal with Excel files (XLSX). So I have checked the documentation a lot, especially in the early days:

https://openpyxl.readthedocs.io/en/stable/

Finding the documentation of a module is as easy as using your search engine - just type "python module name doc".

Github

You probably have heard of Github (acquired by Microsoft in 2018).

https://github.githubassets.com/favicon.ico
"Github - Build software better, together. GitHub is where people build software. More than 40 million people use GitHub to discover, fork, and contribute to over 100 million projects."
https://github.com

ou might wonder what it is exactly.

GitHub provides hosting for software development version control using Git.

What is Git you might ask? Let me quote Wikipedia here: "Git is a distributed version-control system for tracking changes in source code during software development. It is designed for coordinating work among programmers, but it can be used to track changes in any set of files."

Basically Github where you can host your code in the cloud, sync it with your IDE, and it ensures updates to your code are done properly.

It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.

It is not necessary to use Github (or similar Git tool) when you start, but I still wanted to list it here, as it becomes critical as soon as you start collaborating with others (eg freelancers or friend), even if just for a learning project.

Some fundamentals of Python

We discussed how programming languages can be low-level or high-level. Though one thing to clarify first, is that the programs you use on your computer on a daily basis (from Excel, Outlook, Safari, etc..) are all HIGHER level. Meaning that they have been programmed to do specific things, that you can action via their UI (User Interface).

Python enables you to do things "under the hood", so you gain a lot of flexibility in what you can do.

Let's review a few fundamentals, that took me a while to get my head around.

Python scripts

A script, the most basic way to execute code on a computer, is simply a text file, written in a way that the interpreter can understand and convert to commands the computer will understand and run.

In Python, those text files end with .py

So you can open .py files with any text editor, and inspect its code.

Or if you wrote Python code in a text editor, and mistakenly saved it as .txt, just rename it to .py to make it a Python script.

Running a script

When you've written your first line of code, the question is "how do you run this?".

Running the script basically means commanding the computer to read and execute your .py file.

There are basically 2 methods:

With the Terminal

The Terminal is a way to give commands to your computer directly, without going through any (higher level) app.

It is very powerful when you know your way.

(Though never type sudo ****** (redacted for security) as this could wipe out your entire hard drive ;)

On Windows, Press WinKey+R, then type cmd and press Enter to open the Terminal.

On Mac, Cmd+Space, start typing Terminal and press Enter once it's the first highlighted result.

Using the Terminal can be a bit scary at first. It should not be - though there are a few commands to learn and plenty of free tutorials online.

For the purpose of running a simple script, all you have to know are the cd(and ls) commands:

ls is used to display the files and (sub)folders of where you are at with the Terminal. Just type ls and enter at any time, to see where you are (though there are fancier commands to help, see here), like that:

learn-python_terminal_ls.gif

cd is used to Change Directory, ie to go into one of the folders that ls shows are available where you are. You can just type cd followed by the exact name, or just start typing the folder name and press tab for it to autocomplete (works only if 1 match available for autocompletion), then press Enter:

learn-python_terminal_cd.gif

Once you are in the folder where your Python script is, simply use the command python (or python3 if you have multiple versions of Python installed), instead of cd or ls, followed by your script's name to execute it:

learn-python_terminal_run.gif

Within your IDE

If you are within your Integrated Development Environment, it's much simpler:

learn-python_ide_run.gif

Modules, and how to install them

Once you know the basics and start writing code for a specific (small) project, you will want to use functions that would be out of your reach to code yourself.

There is no need to reinvent the wheel, and thanks to the open source community, there is a lot of existing code you can use for common (and uncommon) tasks.

The way to use functioning code that others have written, is via modules (or "libraries" if you use the generic term).

You can think of modules as add-ons, that will extend your interpreter's capabilities.

Instead of writing functions from scratch, you can just call upon the "add-on" with 1 line of code to add it to your script (import) and 1 line of code to use it.

Built-in modules

Some modules are built-in, so they have been installed with Python, and all you need is to import them in your script.

Examples of built-in modules I use a lot myself include:

csv to deal with CSV files

requests to make connections to other systems via internet (eg a website, or API)

time for timestamping

re for regular expressions (when searching for words based on a pattern)

os for commands to the computer's operating system (like loop through all files in a given folder)

webbrowser for commands to my browser (eg for scraping data

Modules to be installed first

Other modules need to be installed on your computer first. These modules are "packaged" to ease installation.

Examples of modules that need installing that I use myself include:

openpyxl to deal with Excel files in XLSX format: https://openpyxl.readthedocs.io/en/stable/

xlrd and xlrt to deal with Excel files in XLX format: https://xlrd.readthedocs.io/en/latest/

PyPDF2 to deal with PDF files: https://pythonhosted.org/PyPDF2/#

pandas for data analysis: https://pandas.pydata.org/

To install a new module, it's fairly easy. Python has a central repository of packages (PyPI - the Python Package Index), with currently offers more than 220k+ projects to choose from:

"PyPI · The Python Package IndexThe Python Package Index (PyPI) is a repository of software for the Python programming language."
https://pypi.org/

Installing modules with pip

Modules can be installed on your computer with a single line of code in your Terminal using the package installer for Python (named pip). You will come across that quite a bit, and though the thought of needing to use the Terminal can be scary, it's pretty straightforward after a quick learning curve.

So for example, to install openpyxl, I will simply enter:

learn-python_pipinstall.gif

Note that I use pip3 and not pip as I use Python 3.

To be completely honest, that's not true.

I do not install modules mainly via Terminal, but rather straight from PyCharm (my IDE) - this makes it even easier, as all you need is to add it in your project, under Preferences > Project Interpreter:

learn-python_pycharminstall.gif

The import command (or statement)

Once the module is available within your project, all you need is to use the import statement at the beginning of your script, to benefit from its code and functions.

Here for example, I have imported the (built-in) time module and use it to timestamp the beginning of the script (and other things within it) with its time() function:

learn-python_time.png
Yes, sometimes it can be confusing, like here when the function's name is the same as the module's name.

You can import entire modules with import {ModuleName} or selected functions within the module with from {ModuleName} import {FunctionName}.

Another example:

Here I can access a webpage (eg the text it contains) with a couple lines of code:

import requests
res = requests.get('https://officebots.io')
print(res.text)

The requests module I use for that contains hundreds of lines of code - but I can use its capabilities by just writing a couple lines myself.

Start small, but have a project

Just remember to start with a small project in mind - this will create a drive and goal for your learning.

And I'm not talking about the small projects usually suggested by the programming books. Building a "Rock, Paper, Scissors Game", "Guess the Number"

If you can, find a small project that is related to your work, or an existing passion of yours.

It could be analysing datasets (https://www.dataquest.io/blog/free-datasets-for-projects/ is a list of free datasets), scraping web data, building a website or automating a small task, personal or business.

Getting Help

Along your journey, you will need help. A lot.

Here are some support methods I used:

Search engines

Any query you make, just start with "python" and add your question or copy/paste the error message you are getting. This is usually the quickest way to get unstuck.

learn-python_duckduckgo.png

Stackoverflow

As mentioned above, Stackoverflow is the go-to website for any programming-related question - and the community is very helpful.

Here is an example of Question and Answer:

https://stackoverflow.com/questions/423379/using-global-variables-in-a-function

Notes:

  • sometimes it is not the most upvoted answer that will help you most (or at all)
  • make sure to skim/read the comments of each answer, as they provide good insights sometimes (ie clarifying the answer, or invalidating it).

Just make sure your question has not already been answered before you post it, and write a concise question, yet providing all the necessary context.

Support from online course teacher

When you buy a course on Udemy, it gives you access to the course's Q&A section where you can ask your question. Either the teacher, or one of the other students can help you further.

Your dedicated Python support

As mentioned above, using a freelancer to help you learn (or codementor.io) comes with the benefit of having someone available to help you get unstuck. And someone who knows both your current knowledge, and what you are working on.

If you can afford it, I recommend it!

Me

Last, if you have any question, I'm also here to help! :)

Conclusion, for now

I won't go into more details about Python in this post - congrats if you have made it through already!

You can pick up Automate the Boring Stuff, or start a course with José Portilla on Udemy if you want to take it further.

Remember that it's critical to have a project (reason) - a grander long-term goal is great, a small project to start with at minima.

This ended up becoming a longer post than expected. As it's my first attempt at sharing knowledge around Python, I am not sure what areas need more or less clarifications.

If you have any inputs, please let me know!

Hope to see you become a Pythonista!

python-logo-official.svg


Additional resources

Programiz | Learn Python Programming

https://www.programiz.com/python-programming

links

social