Python Programming for absolute beginners

Want to learn Python programming for absolute beginners? Read on, for you are in great luck today!

Python is a multipurpose programming language that is used in various software endeavours. From web development using frameworks like Flask and Django to game development with Pygame and Panda-3D, and data science and machine learning using libraries like NumPy, Pandas, Matplotlib, scikit-learn, etc, Python is the Swiss army knife of programming languages.

It is extremely easy to write – when compared to its contemporaries – and can be learnt quite easily, especially for those who have never programmed before. Therefore, if you are someone who wants to learn Python from scratch, we have a comprehensive guide for you

Follow the steps stated below to acquire the requisite knowledge and build your confidence in the world’s favourite programming language!

Python from scratch – Table of Contents

  • Step #0: What’s your calling?
  • Step #1: Set up the environment
  • Step #2: Say Hello to Python
  • Step #3: Variables and Operators
  • Step #4: Conditionals and Loops
  • Step #5: Functions
  • Step #6: Data Structures
  • Conclusion

Python Programming for absolute beginners – Step #0: What’s your calling?

Before you even start learning Python from scratch, give yourself a moment and contemplate why you’re forsaking your time and effort. 

  • Do you want to get into software development, data science or some other modern career?
  • Is it for an exam/course at school or college which is your reason?
  • You have no clear aim in mind – you just want to do it for fun and see where it goes.

Whichever option you choose, do keep in mind that having a target is extremely important. Programming can get pretty overwhelming, just like any other subject. And, if you are not motivated to continue, you might flail away in your journey very soon.

Credit – QuoteFancy

Python Programming for absolute beginners – Step #1: Set up the environment

There are two things you would need to write code in Python:

  • Python is an interpreted language. This means that you need to install an interpreter which can break down the code you write for the computer to understand. Install Python3 from the official website.
  • Writing code requires a text editor. Therefore, you can choose to install Visual Studio Code, Sublime Text, Atom or any other option out there, whichever you prefer.


Alternately, you can install an Integrated Development Environment (IDE). Jupyter Notebook (using Anaconda) is the most preferable one out there if your aim is to do data science. PyCharm and Spyder are other popular options.

Python Programming for absolute beginners – Step #2: Say Hello to Python

A baby’s first words are always memorable. In a very similar fashion, all programmers begin their coding journeys from the simple Hello, World! Program. In fact, every new language they learn begins with this one same program, whose objective is to output the message “Hello, World!” on the screen.


In Python, one can simply do so by writing:


print (‘Hello, World!’)


Any message you write between those two quotes will be displayed as it is on the screen.


Python Programming for absolute beginners – Step #3: Variables and Operators

To take things up by a notch, you can now start thinking about what you can do with strings and numbers (the two kinds of data) in terms of their storage and the operations you can perform on them. To elucidate with an example:

x = 512

print(x + 10)


Since Python is dynamically-typed, you can also do something like this:

x = 23

x = “Twenty three”                  #no error generated


To demonstrate what the Python operators would look like, try running the following code snippet:

x = 12

x = ((x – 2)*13)/10 ** 2

print (x)                                       # Output: 169


Note that Python follows an order of precedence for all operations, just like Maths has BODMAS. As you study more, you’d also get to know about various other operations, boolean data types etc.

Python Programming for absolute beginners – Step #4: Conditionals and Loops

Depending upon whether a given set of conditions are met or not, we would want different pieces of code to execute. This is performed using the if…else construct. We also use elif statement to write more conditions into the branching.


Here’s an example of the same:

age = int(input())                      #integer input

name = input()                           #string input   
if age < 0 or age > 100:

    print(‘You have entered an invalid age’)

elif if age < 18:

    print(‘Sorry ‘ + name + ‘, you are a minor’)


    print(‘License issued for ‘ + name)

Depending on the inputted age, you’d get the specific output on your screen.


Now, think of a situation where you would like to have a piece of code execute repeatedly for you, until a premeditated condition is met. This is where iterative constructs like while and for are used in Python. A simple example is shown below:

num = 341
while num > 0:                                                   # executes until num is non-zero

    print(num % 10, end = ”)                           # displays the remainder left on dividing num by 10 

    num = num//10                                             # num is divided integrally by 10 and reassigned 

The output generated is attached below:

The number has been reversed, effectively.

Python Programming for absolute beginners – Step #5: Functions

You can write hundreds of lines of code one after other, on the basis of what we have discussed so far. However, assume that there’s a some code written between lines 10 and 16 which is wanted again at line 100.


It is not a simply unfeasible to repeat instructions. In fact, DRY (Do not repeat yourself) principle is a tenet of programming and to implement it, we utilize functions. These are written once and can be used any number of times during the program’s execution.


These are declared using the def keyword and can have one, more or no arguments (inputs sent to a function). They can return (send back to the caller) one/no value to the caller. To understand better with an example:

def isPrime(x):                         # checks if a number is prime

    if x < 2:                                   # 0 and 1 are not prime

        return False

    if x == 2 or x == 3:               # 2 and 3 are prime

        return True

    for i in range(2, int(x**0.5)):       # for ‘n’ having a factor between 2 and √n, it’s not prime

        if x % i == 0:

            return False

    return True
print(isPrime(12))                    # False

print(isPrime(131))                  # True

print(isPrime(38))                     # False


The isPrime(x) function is declared once but can now be used anywhere in the program. In case you are wondering, we can write functions that call themselves. These are known as recursive functions and are used widely to write readable code.

We won’t explain it here but this picture might familiarise you aptly:

Credit: Reddit

Python Programming for absolute beginners – Step #6: Data Structures

Storing millions of rows of data (yes, we regularly do so in Python!) cannot be accomplished with variables. We leverage Python’s in-built data structures in such a scenario, wherein a single name refers to more than one values. Indexing is used for referring to specific values.


There are four built-in data structures in Python:

  • Lists – structures that have modifiable and ordered values, without restrictions
  • Tuples – lists that cannot be modified
  • Sets – lists with unique values
  • Dictionaries – key:value pairs


You can read more about them by clicking here.

Python Programming for absolute beginners – Conclusion

Learning Python from scratch is not difficult. All it needs is a lot of dedication and practice. Make sure to go and practice what you have learned on platforms like Hackerrank, CodeChef and LeetCode. Further, you can choose to pursue topics like OOPS, web development, app development and data science after finishing these sections. can help you learn Python the way it is meant to be! Learn Python from scratch and be the Pythonista you always aspired to be!

Comments are closed