The Friendly Code: Python Tips for Beginners

Posted on - Last Modified on

We can all agree that anyone who wants to learn programming should learn Python. It is easy to learn for English speakers, and is possibly the BASIC of the 21st century - even though the name doesn't sound very approachable.

If you're new to the syntactically-weird world of computing, Python will be a pleasant introduction to it. It powers Google and Nokia. It is the most popular first computer language at US universities, and you can keep compiling and running code in Python until you fix your errors. Not all programming languages are this forgiving, but Python is because it's a scripting language.

How should you learn this excellent general-purpose scripting language? The only way to learn any language is by hard work. It involves learning to read and write, to pay attention to details, and to spot differences between two pieces of similar-looking code. Python has a large and helpful community of people who can help you while you learn, but here are some tips speed you along.

1. Type while you learn

It is important not to cut and paste bits of Python you find on tutorials around the Internet, and believe you know the code. You must type code as you learn. It is the only way to teach your mind to see the code, and pay attention to detail. Attention to detail is what separates a good programmer from the rest. If you don't work on this aspect, you'll end up with code that is inefficient, or worse; buggy.

2. Don't start by only learning a bunch of syntaxes

Many schools teach Python to high schoolers in a boring and rote way. They will give the kids a group of syntax to memorize. They will assign very generic exercises the kids don't care about. It is not the way to learn any language, let alone a programming language. It will make the process boring, and you're more likely to quit. But there are many types of projects you can start in Python - you can pick a project for yourself, and you'll discover it's more fun to learn by doing.

3. Spend a little time - not too much - on basic syntax

While it's not good to start learning Python by poring over its grammar, you should still pay some attention to learning the basic syntax. Don't spend a lot of time on it, but learn enough to use in a project of your choice.

Many online resources will teach you syntax. Some of the best are:

Don't forget that once you're working on a project, you can always go back to refer to the syntax if you're stuck.

4. Find a context

When learning a new language, you’re bound to pick it up faster if you have a context. Why are you trying to learn Python? Do you want to create web pages? Or a text-based video game? Do you want to make an application for mobile phones? Or are you simply interested in Python for data science?

When you learn within a context, you learn more useful skills than in a general way without direction. The observation can apply to the process of learning any new language. If you have context, you'll get engaged with problems and solutions that mean something to you. Think about it. What will motivate you to learn Python - a problem you feel you have to solve with it, or cut and dry grammar?

Here’s an example of someone approaching Python the right way. A writer wanted to create visual novels with the Ren'Py engine and didn't know anything about programming languages. After a couple of months of using Ren'py documentation and samples as a template for his visual novels, he realized he was intrigued by programming and wanted to have greater control over his digital creations. At this point, he couldn't write a code snippet without the reliance of a template, even if he was given a complete list of Python keywords.

Having sent off his visual novels to readers, he began systematically going through Python tutorials and exercises, and typing everything he came across in an editor with syntax highlighting. He maintained a notebook on his PC, with solutions to little problems he faced in his quest to make a solid text-based game. In a few months, he was well on his way to creating a game from scratch!

When you’re knee-deep in Python, you can look for projects to take up on Freelancer.com. If you search hard enough, you may find a job that will suit your level of competency.

5. Speed up reading and writing

It goes without saying that if you're learning to code in Python or any other language, you need to be reasonably fast at typing. If you're still searching for the 'T' on your keyboard, you may need to practice typing before you can tackle the often-irregular symbols you'll come across.

Giving an hour or two a day to typing practice can help you reach a stage where you don't even have to look at the keyboard to type Python code. And when you practice typing with code samples, you may kill the two proverbial birds with one stone! You will become increasingly familiar with the keywords and symbols Python commonly uses.

6. Learn to spot differences

With time and hours of practice, you'll develop the ability to look at two different but similar snippets of code, and tell them apart. Certain tools will help you spot these differences. But learning to do so manually will be good for you. It will prepare you for identifying bugs and mistakes.

7. Find resources

There are great online resources to help you dig your teeth into Python. You'll probably want to start at resources that teach you syntax, reading inputs, printing outputs, numerical algorithms, etc. and have you solve problems.

The best of these resources include:

  • Codecademy - An excellent resource that will take you through some easy games and teach you how to write them.

  • Pygame Tutorials - Another good list of tutorials for those who want to make games.

  • Bottle Tutorial - If you want to make websites, you can use Bottle, Flask, or Django for web frameworks. Bottle is the easiest web framework to break in your Python for web designing.

  • Kivy Guide - If you want to make mobile applications using Python, check out the useful Kivy guide while you do.

  • Python for Data Analysis - If you want to use Python for data analysis, this ebook can be an exceptional introduction.

8. Find people to learn with

Find a group of like-minded people, and you'll find you learn faster. Look for Python meet-ups near you, or set up one of your own. You'll probably be surprised by how many people are passionate about learning Python, and want to talk about their projects and the problems they are facing.

9. Challenge yourself

After you have gotten the hang of the initial exercises in Python, and have worked on your website or game long enough to be comfortable, you should slowly increase the scope and difficulty of your project. Think about ways to make your program run faster, for instance, or how you can teach a newbie to run your current project.

Learning Python can be rewarding, but only if you've learned the right way. Try not to lose motivation as you learn, and engage with projects that interest you. If, after six months, you look back at your old Python programs and see how terrible they are, you're on the right track!

How was your experience with Python? First time doing it? Let us know in the comments section below!

Posted 11 August, 2017

LucyKarinsky

Software Developer

Lucy is the Development & Programming Correspondent for Freelancer.com. She is currently based in Sydney.

Next Article

35 Java Programming Tips And Best Practices For Beginners