How to learn Python 22

Where do I learn Python? How can I learn Python basics? Can I learn Python? What is the best online plasource to learn Python?

how to learn python

These types of questions get very often asked day on community forums like Quora and Reddit.

My answer to the big question of “How to learn Python” would be this:


Yes, learn Python in this moment.

In this article.

Do it before you get busy with the next thing you’re doing.

Here are the steps:

  1. Download and install Python.
    Whether you are on a Windows, Mac or Linux, you can download Python from the Python official website. A good idea is to download version 3 of Python (e.g. Python 3.5.1).
    Once you’ve downloaded the latest Python, go ahead and install it.
  2. Create and execute your first Python program.
    Once you have installed Python, you can create your first Python program following these steps:

    1. Create an empty file and inside the file type in this:
      print("It's working")

      Name the file something like where .py is the file extension associated with Python programs.

    2. That’s it.
      To execute your program, open the terminal/command line and type in python and the full path to your file. For instance, if your file is located in a folder called test which is in your C drive, you would need to type this in your command line:

      python C:\test\

      So, you’re telling your computer what program to use (i.e. python) to execute the file (i.e.
      And that’s how you execute a Python program. You should now see the program output in the command line:

      It's working

      As you see, this was just a simple script that was programmed to print out some text on the screen. Very basic, but that’s how you start.

      If you just want to test things out, you can just type your code in the interactive Python shell which can be opened by typing this in the command line:


      Be aware though that the code you type in the interactive shell is lost when you close the shell. If you want to save the scripts, you should create a Python file as you did previously. The interactive shell is best suited when you’re learning, testing or exploring things.

  3. Next, learn variables
    Variables are like containers where you can store every Python object. They are used to transport objects and values between different parts of the program.Start creating some variables and assigning some values to them. You can either type them in the interactive shell or inside a Python script if you like.

    a_list=[1,2,"Hi there", 3]

    Want to do something with the variables you created? How about printing their values out? For instance:


    Or just do some math:


    So, that’s how you create and access variables. Let’s learn some more stuff.

  4. Learn the various datatypes you can use in Python.
    When you created variables above, we assigned  objects of various types to them because every object in Python has a certain datatype. Here are the main datatypes:Strings (e.g. “Friday”)
    Integers (e.g. 10)
    Floats (10.2)
    Lists ([1,2,”Hi there”, 3])
    Dictionaries ({“Name”:”John”,”Profession”:”astrolog”,”age”:172})All of them may have methods associated with them. For instance:


    That will replace letter a with letter e.

    To see a full list of available methods that you can apply to an object, use the dir method and pass the object whose methods you want to explore:

    dir("any string here")
  5. Next, learn to create custom functions.
    There are two types of functions in Python – built-in and custom.
    Print() is a an example of a built-in function that prints out text on the screen. However, you may want to create your own custom functions for specific tasks.Here is how to create a function that gets euros and the current currency exchange rate as input values, and returns dollars as function output.

    def currency_converter(rate,euros):
        return dollars

    That’s how you define a function.

    Notice that the lines below the def line are indented with white space. When you indent lines, you are telling Python that those indented lines belong to the unindented line above them. In our case all the indented lines belong to the function you are creating. Indentation needs to be consistent. If you indented four spaces for the first line after def, you should indent the same amount for the next line after that. A good practice is to indent four spaces.

    Once you have created your blueprint – your function, you can generate outputs from it. Here is how you execute an instance of the function:


    There we printed out the function output, but you can do whatever you like with it:


    That will multiply the function output by 20 and store it inside the product variable.

  6. Then, learn loops.
    You will soon run across scenarios where you will need to execute the same action multiple times. Let’s say you would want to generate multiple outputs of your currency converter function given a range values. Instead of writing the function call multiple times, you could use a for loop instead:

    for rate_value in [96,94,99]:
  7. Now learn conditionals.
    Conditionals are what make your program able to take decisions. They are expressions that evaluate a condition and execute something based on the whether the condition evaluates to true or false.

    if v<3:
    elif v==3:

    That’s a complete conditional block. The code is quite human readable. Just pay close attention to the indentation. That’s where most of the Python novices fail. A wrong indented line will throw an error and the execution will be interrupted.


    Alright, now you know how to write simple scripts of Python code.

    You can certainly solve some trivial problems with Python now.

    However, you are still a bit far from writing your first real world program. For that you will need to practice the fundamentals you learned above and also learn to use third party libraries that make available specialized code for specific coding activities. For instance, if you want to build websites with Python, you would need to learn how to use the Flask library.

    If you’re not sure what to do next, we would recommend taking the following 21-hour complete Python course which teaches how to develop advanced applications with Python.

    The course covers web and desktop applications, web scrapping, data analysis and visualization, image processing and more and you learn how to build the following 10 applications:

    Course Content Infographic

    As a reader of PythonHow you can get get the course on Udemy for $19 instead of its $195 list price:

    The Python Mega Course: Build 10 Python Applications

Leave a comment

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

22 thoughts on “How to learn Python

  • Paul Gan

    Hello, im interested in using your programming course in a school? I would like to know how to get in contact with you so we can further discuss the possibilities of working together.

    Thank you

  • JC Worth

    Don’t really understand this question:
    ‘Find the total number of characters, convert that number to letters of alphabet (0->a, 1->b, etc.) and you get the key word for the next level.’

    Is it to find the number of each letter character used?? As in find the number of “a’s” then the number of “b’s”, and so on.

  • quoit

    Hi – I saw your Python Mega course on Udemy. I am very interested in enrolling but there is no topic for Machine Learning using python. In future will you be uploaded any videos regarding ML in Mega Course?

  • fustration

    i’ve been learning programming for 2 days (10 hours sleep) now. i know how to code (within a certain capacity; be mindful)

    ive used the python powershell (did help, know how to work with variable and such forth)
    i’m having an easier time with the long winded language (why?)
    i followed your step (i do have python in path)
    the directory does exist (the script file py)
    yet python shell wont acknowledge its existence,so wont cmd/powershell so i’m back to square one.

    incapable of uniting my text editor or any editor to my powershell or to follow any string that is outside my powershell (and ofc if i close powershell, everything would be lost)

  • Mathew

    I am interested in learning “pyspark” or anything related to “using python in spark”?
    Do you have any such course built for this purpose? or can you guide me to right direction in this regard?


  • Jerome

    OK, here a comment from a non-programmer following the course. It’s really good 🙂

    So far, EVERY programming tutorial I tried goes on forever on how to download something and click install, does “hello world” and – and the next step it’s a supercomplex whatnot with barely a explanation on what’s going on, I just copy and paste stuff without comprehension until something doesn’t work and that’s it.

    Not this one.

    Each section is reasonably sized and covers a topic well, and Ardit really EXPLAINS what’s going on. He doesn’t assume everything is obvious. So, after each section I learned something that I actually am able to reproduce and apply, and dig deeper based on what I’ve learned.

    I’m like halfway through now, I’m not seeing myself jotting down machine learning projects on a napkin – but I’m very confident that I’ll be able to develop, and it’s really fun to learn programming!

  • pitzertad

    checking in, obviously got to section 8 lecture 65 : )
    Thank you.
    using python 3.5 on win10-64 and mac 10.6.8
    ide both platforms: sublime2
    of course im doing it ‘the hard way’ which means typing all code examples in. you wont learn it unless you practice it.

  • Gaurav Singh

    Hi, We are two guys would like to learn Python on weekends. What’s the probability for you to provide the training?

    • Mrinal

      Hi Gaurav, try registering for Ardit’s Python course on udemy. It’s affordable and fun. There are some demo videos that you can see before registering for the full course.

  • Rahul Masal

    i started Python Mega Course on udemy, in application 2 that is maps i got error but i cant fix it please tell me the solution for that,
    i checked all syntax and little littel things but something goes wrong..

    i got following error :
    Traceback (most recent call last):
    File “D:\Programs\learning\mapping\”, line 27, in
    style_function=lambda x: {‘fillColor’:’green’ if x[‘properties’][‘POP2005’] < 10000000
    File "C:\Users\hp\AppData\Local\Programs\Python\Python36-32\lib\site-packages\folium\", line 495, in __init__
    raise ValueError('Unhandled object {!r}.'.format(data))
    ValueError: Unhandled object .

    • Ardit Post author

      Hi, please use the course Q&A to ask this question and please make sure to post your code there as well, and not just the error.

  • Dario

    Ok, that was not cool.

    I finished your python challenge and at the end there was just “Challenge completed!” Not even “Good work, bravo, you are so smart!”?

    or even: Djbbi!