11 Beginner Tips For Learning Python Programming - Real Python
11 Beginner Tips For Learning Python Programming - Real Python
Programming
by Krishelle Hardson-Hurley 32 Comments basics python
Table of Contents
Make It Stick
Tip #1: Code Everyday
Tip #2: Write It Out
Tip #3: Go Interactive!
Tip #4: Take Breaks
Tip #5: Become a Bug Bounty Hunter
Make It Collaborative
Tip #6: Surround Yourself With Others Who Are Learning
Tip #7: Teach
Tip #8: Pair Program
Tip #9: Ask “GOOD” Questions
Make Something
Tip #10: Build Something, Anything
Tip #11: Contribute to Open Source
Go Forth and Learn!
Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with
the written tutorial to deepen your understanding: 11 Beginner Tips for Learning Python
We are so excited that you have decided to embark on the journey of learning Python! One of the most
common questions we receive from our readers is “What’s the best way to learn Python?”
I believe that the first step in learning any programming language is making sure that you understand how to
learn. Learning how to learn is arguably the most critical skill involved in computer programming.
Why is knowing how to learn so important? The answer is simple: as languages evolve, libraries are created,
and tools are upgraded. Knowing how to learn will be essential to keeping up with these changes and
becoming a successful programmer.
In this article, we will o er several learning strategies that will help jump start your journey of becoming a
rockstar Python programmer!
Make It Stick
Here are some tips to help you make the new concepts you are learning as a beginner programmer really
stick:
Check out the First Steps With Python Guide for information on setup as well as exercises to get you started.
Once you start working on small projects and programs, writing by hand can also help you plan your code
before you move to the computer. You can save a lot of time if you write out which functions and classes you
will need, as well as how they will interact.
To use the interactive Python shell (also sometimes called a “Python REPL”), first make sure Python is
installed on your computer. We’ve got a step-by-step tutorial to help you do that. To activate the interactive
Python shell, simply open your terminal and run python or python3 depending on your installation. You can
find more specific directions here.
Now that you know how to start the shell, here are a few examples of how you can use the shell when you are
learning:
Python >>>
The elements returned from dir() are all of the methods (i.e. actions) that you can apply to the element. For
example:
Python >>>
>>> my_string.upper()
>>> 'I AM A STRING'
Notice that we called the upper() method. Can you see what it does? It makes all of the letters in the string
uppercase! Learn more about these built-in methods under “Manipulating strings” in this tutorial.
Python >>>
>>> type(my_string)
>>> str
Python >>>
>>> help(str)
Python >>>
Python >>>
>>> import os
>>> os.system('ls')
python_hw1.py python_hw2.py README.txt
Breaks are especially important when you are debugging. If you hit a bug and can’t quite figure out what is
going wrong, take a break. Step away from your computer, go for a walk, or chat with a friend.
In programming, your code must follow the rules of a language and logic exactly, so even missing a
quotation mark will break everything. Fresh eyes make a big di erence.
When debugging, it is important to have a methodological approach to help you find where things are
breaking down. Going through your code in the order in which it is executed and making sure each part
works is a great way to do this.
Once you have an idea of where things might be breaking down, insert the following line of code into your
script import pdb; pdb.set_trace() and run it. This is the Python debugger and will drop you into
interactive mode. The debugger can also be run from the command line with python -m pdb <my_file.py>.
Make It Collaborative
Once things start to stick, expedite your learning through collaboration. Here are some strategies to help you
get the most out of working with others.
Don’t worry if you don’t know anyone. There are plenty of ways to meet others who are passionate about
learning Python! Find local events or Meetups or join PythonistaCafe, a peer-to-peer learning community for
Python enthusiasts like you!
Pair programming has many benefits: it gives you a chance to not only have someone review your code, but
also see how someone else might be thinking about a problem. Being exposed to multiple ideas and ways of
thinking will help you in problem solving when you got back to coding on your own.
G: Give context on what you are trying to do, clearly describing the problem.
O: Outline the things you have already tried to fix the issue.
O: O er your best guess as to what the problem might be. This helps the person who is helping you to not
only know what you are thinking, but also know that you have done some thinking on your own.
D: Demo what is happening. Include the code, a traceback error message, and an explanation of the steps
you executed that resulted in the error. This way, the person helping does not have to try to recreate the
issue.
Good questions can save a lot of time. Skipping any of these steps can result in back-and-forth conversations
that can cause conflict. As a beginner, you want to make sure you ask good questions so that you practice
communicating your thought process, and so that people who help you will be happy to continue helping
you.
Make Something
Most, if not all, Python developers you speak to will tell you that in order to learn Python, you must learn by
doing. Doing exercises can only take you so far: you learn the most by building.
What you build is not as important as how you build it. The journey of building is truly what will teach you
the most. You can only learn so much from reading Real Python articles and courses. Most of your learning
will come from using Python to build something. The problems you will solve will teach you a lot.
There are many lists out there with ideas for beginner Python projects. Here are some ideas to get you
started:
If you find it di icult to come up with Python practice projects to work on, watch this video. It lays out a
strategy you can use to generate thousands of project ideas whenever you feel stuck.
Contributing to an open-source Python project is a great way to create extremely valuable learning
experiences. Let’s say you decide to submit a bug fix request: you submit a “pull request” for your fix to be
patched into the code.
Next, the project managers will review your work, providing comments and suggestions. This will enable you
to learn best practices for Python programming, as well as practice communicating with other developers.
For additional tips and tactics that will help you break into the open-source world, check out the video
embedded below:
Watch Now This tutorial has a related video course created by the Real Python team. Watch it together with
the written tutorial to deepen your understanding: 11 Beginner Tips for Learning Python
🐍 Python Tricks 💌
Get a short & sweet Python Trick delivered to your inbox every couple of
days. No spam ever. Unsubscribe any time. Curated by the Real Python
team.
Email Address
A er 6 years of teaching high school math, Krishelle switched careers and now works as a Site
Reliability Engineer at Dropbox in San Francisco, CA.
Each tutorial at Real Python is created by a team of developers so that it meets our high quality standards. The
team members who worked on this tutorial are:
Real Python Comment Policy: The most useful comments are those written with the goal of learning
from or helping out other readers—a er reading the whole article and all the earlier comments.
Complaints and insults generally won’t make the cut here.
What’s your #1 takeaway or favorite thing you learned? How are you going to put your newfound skills to
use? Leave a comment below and let us know.
Keep Learning
🐍 Python Tricks 💌
— FREE Email Series —
Email…