October 31, 2020

Learn Python – Free Python Tutorial

Python is a general-purpose programming language that is becoming ever more popular for data science. Companies worldwide are using Python to harvest insights from their data and gain a competitive edge.

Welcome! Is it true that you are totally new to programming? On the off chance that not, at that point we assume you will be searching for data concerning why and how to begin with Python. Luckily an accomplished software engineer in any programming language (whatever it might be) can get Python rapidly. It’s additionally simple for novices to utilize and learn, so hop in!

The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python Web site, https://www.python.org/, and may be freely distributed. The same site also contains distributions of and pointers to many free third party Python modules, programs and tools, and additional documentation.

The Python interpreter is easily extended with new functions and data types implemented in C or C++ (or other languages callable from C). Python is also suitable as an extension language for customizable applications.

This tutorial introduces the reader informally to the basic concepts and features of the Python language and system. It helps to have a Python interpreter handy for hands-on experience, but all examples are self-contained, so the tutorial can be read off-line as well.

For a description of standard objects and modules, see The Python Standard Library. The Python Language Reference gives a more formal definition of the language. To write extensions in C or C++, read Extending and Embedding the Python Interpreter and Python/C API Reference Manual. There are also several books covering Python in depth.

Learn Python - Free Interactive Python Tutorial

Real Python is a repository of free and in-depth Python tutorials created by a diverse team of professional Python developers. At Real Python you can learn all things Python from the ground up. Everything from the absolute basics of Python, to web development and web scraping, to data visualization, and beyond.

 

Python Basics

pythonbasics.org is an introductory tutorial for beginners. The tutorial includes exercises. It covers the basics and there are also in-depth lessons like object oriented programming and regular expressions.

Python for Beginners

thepythonguru.com is a tutorial focused on beginner programmers. It covers many Python concepts in depth. It also teaches you some advanced constructs of Python like lambda expressions and regular expressions. And last it finishes off with the tutorial “How to access MySQL db using Python”

Installing

Installing Python is generally easy, and nowadays many Linux and UNIX distributions include a recent Python. Even some Windows computers (notably those from HP) now come with Python already installed. If you do need to install Python and aren’t confident about the task you can find a few notes on the BeginnersGuide/Download wiki page, but installation is unremarkable on most platforms.

Downloading Python

Before you start, you will need Python on your computer.

Check whether you already have an up to date version of Python installed by entering python in a command line window. If you see a response from a Python interpreter it will include a version number in its initial display. Generally any Python 3.x version will do, as Python makes every attempt to maintain backwards compatibility within major Python versions. Python 2.x and Python 3.x are intentionally not fully compatible. If python starts a Python 2.x interpreter, try entering python3 and see if an up to date version is already installed.

On Windows, try py first – this is the relatively recent Python Launcher, which has a better chance of avoiding some of the path problems that might occur because on Windows programs don’t install into any of the small set of common locations that are searched by default. The Python launcher can also let you select any of the various versions you may have installed from a single command.

If you need to install Python, you may as well download the most recent stable version. This is the one with the highest number that isn’t marked as an alpha or beta release. Please see the Python downloads page for the most up to date versions of Python. They are available via the yellow download buttons on that page.

https://www.youtube.com/watch?v=mawiTPo9prE

Windows

The most stable Windows downloads are available from the Python for Windows page. On Windows you have a choice between 32-bit (labeled x86) and and 64-bit (labeled x86-64) versions, and several flavors of installer for each. The Python core team thinks there should be a default you don’t have to stop and think about, so the yellow download button on the main download page gets you the “x86 executable installer” choice. This is actually a fine choice: you don’t need the 64-bit version even if you have 64-bit Windows, the 32-bit Python will work just fine.

If you’re running Windows XP: a complete guide to installing ActivePython is at Python on XP: 7 Minutes To “Hello World!”. ShowMeDo has two videos for downloading, installing and getting started with Python on a Windows XP machine – this series talks you through the Python, ActivePython and SciPy distributions. Note that the python.org releases only support versions of Windows that are supported by Microsoft (at the time of the release), so no recent release from python.org can be used on WIndows XP.

 

Mac

See the Python for Mac OS X page. MacOS from 10.2 (Jaguar) to 10.15 (Catalina) includes a system version of Python 2, but it is best not to consider this the Python to use for your programming tasks – install a current Python 3.x version instead. MacOS after 10.15 (Catalina) will not include a default system Python.

 

Linux

For Red Hat, CentOS or Fedora, install the python3 and python3-devel packages.

For Debian or Ubuntu, install the python3.x and python3.x-dev packages.

For Gentoo, install the ‘=python-3.x*’ ebuild (you may have to unmask it first).

For other systems, or if you want to install from source, see the general download page.

Learning

Before getting started, you may want to find out which IDEs and text editors are tailored to make Python editing easy, browse the list of introductory books, or look at code samples that you might find helpful.

There is a list of tutorials suitable for experienced programmers on the BeginnersGuide/Tutorials page. There is also a list of resources in other languages which might be useful if English is not your first language.

The online documentation is your first port of call for definitive information. There is a fairly brief tutorial that gives you basic information about the language and gets you started. You can follow this by looking at the library reference for a full description of Python’s many libraries and the language reference for a complete (though somewhat dry) explanation of Python’s syntax. If you are looking for common Python recipes and patterns, you can browse the ActiveState Python Cookbook

Figure Out What Motivates You to Learn Python

Before you start diving into learning Python online, it’s worth asking yourself why you want to learn it. This is because it’s going to be a long and sometimes painful journey. Without enough motivation, you probably won’t make it through. For example, I slept through high school and college programming classes when I had to memorize syntax and I wasn’t motivated. On the other hand, when I needed to use Python to build a website to automatically score essays, I stayed up nights to finish it.

Figuring out what motivates you will help you figure out an end goal, and a path that gets you there without boredom. You don’t have to figure out an exact project, just a general area you’re interested in as you prepare to learn Python.

Pick an area you’re interested in, such as:

  • Data science / Machine learning
  • Mobile apps
  • Websites
  • Games
  • Data processing and analysis
  • Hardware / Sensors / Robots
  • Scripts to automate your work

Figure out one or two areas that interest you, and you’re willing to stick with. You’ll be gearing your learning towards them, and eventually will be building projects in them.

 Learn the Basic Syntax

Unfortunately, this step can’t be skipped. You have to learn the very basics of Python syntax before you dive deeper into your chosen area. You want to spend the minimum amount of time on this, as it isn’t very motivating. 

Here are some good resources to help you learn the basics:

I can’t emphasize enough that you should only spend the minimum amount of time possible on basic syntax. The quicker you can get to working on projects, the faster you will learn. You can always refer back to the syntax when you get stuck later. You should ideally only spend a couple of weeks on this phase, and definitely no more than a month.

Also, a quick note: learn Python 3, not Python 2. Unfortunately a lot of “learn Python” resources online still teach Python 2, but you should definitely learn Python 3. Python 2 is no longer supported, so bugs and security holes will not be fixed!

 
 

Make Structured Projects

Once you’ve learned the basic syntax, it’s possible to start making projects on your own. Projects are a great way to learn, because they let you apply your knowledge. Unless you apply your knowledge, it will be hard to retain it. Projects will push your capabilities, help you learn new things, and help you build a portfolio to show to potential employers.

However, very freeform projects at this point will be painful — you’ll get stuck a lot, and need to refer to documentation. Because of this, it’s usually better to make more structured projects until you feel comfortable enough to make projects completely on your own. Many learning resources offer structured projects, and these projects let you build interesting things in the areas you care about while still preventing you from getting stuck.

Let’s look at some good resources for structured projects in each area:

Data science / Machine learning

  • Dataquest — Teaches you Python and data science interactively. You analyze a series of interesting datasets ranging from CIA documents to NBA player stats. You eventually build complex algorithms, including neural networks and decision trees.
  • Python for Data Analysis — written by the author of a major Python data analysis library, it’s a good introduction to analyzing data in Python.
  • Scikit-learn documentation — Scikit-learn is the main Python machine learning library. It has some great documentation and tutorials.
  • CS109 — this is a Harvard class that teaches Python for data science. They have some of their projects and other materials online.

Mobile Apps

  • Kivy guide — Kivy is a tool that lets you make mobile apps with Python. They have a guide on how to get started.

Websites

  • Flask tutorial — Flask is a popular web framework for Python. This is the introductory tutorial.
  • Bottle tutorial — Bottle is another web framework for Python. This is how to get started with it.
  • How To Tango With Django — A guide to using Django, a complex Python web framework.

Games

Hardware / Sensors / Robots

Scripts to Automate Your Work

Once you’ve done a few structured projects in your own area, you should be able to move into working on your own projects. But, before you do, it’s important to spend some time learning how to solve problems.

Work on Python Projects on Your Own

Once you’ve completed some structured projects, it’s time to work on projects on your own to continue to learn Python better. You’ll still be consulting resources and learning concepts, but you’ll be working on what you want to work on. Before you dive into working on your own projects, you should feel comfortable debugging errors and problems with your programs. Here are some resources you should be familiar with:

  • StackOverflow — a community question and answer site where people discuss programming issues. You can find Python-specific questions here.
  • Google — the most commonly used tool of every experienced programmer. Very useful when trying to resolve errors. Here’s an example.
  • Python documentation — a good place to find reference material on Python.

Once you have a solid handle on debugging issues, you can start working on your own projects. You should work on things that interest you. For example, I worked on tools to trade stocks automatically very soon after I learned programming.

Here are some tips for finding interesting projects:

  • Extend the projects you were working on previously, and add more functionality.
  • Check out our list of Python projects for beginners.
  • Go to Python meetups in your area, and find people who are working on interesting projects.
  • Find open source packages to contribute to.
  • See if any local nonprofits are looking for volunteer developers.
  • Find projects other people have made, and see if you can extend or adapt them. Github is a good place to find these.
  • Browse through other people’s blog posts to find interesting project ideas.
  • Think of tools that would make your every day life easier, and build them.

Remember to start very small. It’s often useful to start with things that are very simple so you can gain confidence. It’s better to start a small project that you finish that a huge project that never gets done. At Dataquest, we have guided projects that give you small data science related tasks that you can build on.

It’s also useful to find other people to work with for more motivation.

If you really can’t think of any good project ideas, here are some in each area we’ve discussed:

Data Science / Machine Learning Project Ideas

  • A map that visualizes election polling by state.
  • An algorithm that predicts the weather where you live.
  • A tool that predicts the stock market.
  • An algorithm that automatically summarizes news articles.

Mobile App Project Ideas

  • An app to track how far you walk every day.
  • An app that sends you weather notifications.
  • A realtime location-based chat.

Website Project Ideas

  • A site that helps you plan your weekly meals.
  • A site that allows users to review video games.
  • A notetaking platform.

Python Game Project Ideas

  • A location-based mobile game, where you capture territory.
  • A game where you program to solve puzzles.

Hardware / Sensors / Robots Project Ideas

  • Sensors that monitor your home temperature and let you monitor your house remotely.
  • A smarter alarm clock.
  • A self-driving robot that detects obstacles.

Work Automation Project Ideas

  • A script to automate data entry.
  • A tool to scrape data from the web.

My first project on my own was adapting my automated essay scoring algorithm from R to Python. It didn’t end up looking pretty, but it gave me a sense of accomplishment, and started me on the road to building my skills.

The key is to pick something and do it. If you get too hung up on picking the perfect project, there’s a risk that you’ll never make one.

Keep working on harder projects

Keep increasing the difficulty and scope of your projects. If you’re completely comfortable with what you’re building, it means it’s time to try something harder.

Here are some ideas for when that time comes:

  • Try teaching a novice how to build a project you made.
  • Can you scale up your tool? Can it work with more data, or can it handle more traffic?
  • Can you make your program run faster?
  • Can you make your tool useful for more people?
  • How would you commercialize what you’ve made?

At the end of the day, Python is evolving all the time. There are only a few people who can legitimately claim to completely understand the language, and they created it.

You’ll need to be constantly learning and working on projects. If you do this right, you’ll find yourself looking back on your code from 6 months ago and thinking about how terrible it is. If you get to this point, you’re on the right track. Working only on things that interest you means that you’ll never get burned out or bored.

Python is a really fun and rewarding language to learn, and I think anyone can get to a high level of proficiency in it if they find the right motivation.

3+

Leave a Reply

Your email address will not be published. Required fields are marked *