11 Beginner Tips for Learning Python Programming

Posted on

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.

3: Go Interactive!

Whether you are learning about basic Python data structures (strings, lists, dictionaries, etc.) for the first time, or you are debugging an application, the interactive Python shell will be one of your best learning tools. We use it a lot on this site too! To use the interactive Python shell, 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 python3depending on your installation.

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:

Learn what operations can be performed on an element by using dir():


>>> my_string = 'I am a string'
>>> dir(my_string)
['__add__', ..., 'upper', 'zfill']  # Truncated for readability

The elements returned from dir() are all of the methods (i.e. actions) that you can apply to the element. For example:


>>> my_string.upper()

Notice that we called the upper() method. Can you see what it does? It makes all of the letters in the string uppercase!

Learn the type of an element:


>>> type(my_string)
>>> str
Prev2 of 6Next

Leave a Reply

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