A Brief Introduction to Python.

I will try to make it as easy as possible , let’s see what we end up with . Note this tutorial is targeted towards audience who have acquired knowledge on C/C++ programming language.


Many of the recent Operating Systems comes with python Pre Installed , but it’s okay if your pc don’t have python installed , you can easily install it yourself.

From this link : https://wiki.python.org/moin/BeginnersGuide/Download , you can download and install Python on your computer , follow the instructions provided for your device.

Getting started with IDE :

There is a bunch of IDE to pick from , if you are beginner you should look for IDE’s that are tailored to make it easier for you to make Python Coding easy.

In this tutorial we will use PYcharm . You can download it from this link : https://www.jetbrains.com/pycharm/ .

If you have completed Installation and done setting up the IDE , you are good to get started with Python.

The Properties of Python:

Python is strongly typed (i.e. types are enforced), dynamically, implicitly typed (i.e. you don’t have to declare variables), case sensitive (i.e. var and VAR are two different variables) and object-oriented (i.e. everything is an object).

Python Syntax :

If you have experience with C++ ,which you should have by now , you must be habituated with using “ ; “ this as your termination character but you will have to change that habit while using Python because Python does not have any mandatory termination character . Indentation specifies a block , indent to begin , dedent to end. Comments start with the pound (#) sign and are single-line, multi-line strings are used for multi-line comments. Just like C++ , values are assigned with an equal “=” sign and equality is defined by double equal sign “==”. Also “+=” or “-=” works just like c++. This works on many data-types, strings included. You can also use multiple variables on one line.

Data Types in Python :

Lists ,Tuples and Dictionaries are available as Data Structures in Python , sets are available in sets library. Lists are like One Dimensional arrays , dictionaries are associative arrays and tuples are immutable one-dimensional arrays.

In Python Arrays can be of any type , you can mix up an array with Integer , string or lists etc. The first index of every Array is set to 0 by default.Negative numbers count from the end towards the beginning, -1 is the last item. Variables can point to functions.

To access array ranges you can use Colon “:” , like print List [0::2] will print the first and 3rd item of an array. If you leave the left part empty , compiler will assume it’s the first item. is inclusive-exclusive, so if you specify print(list[0:2]) it will only print O’th item.

Exercise : Try to access 3rd and 4th item using negative index.

Strings in Python :

You should also know what String is by now . If were into C++ , you are probably used to using string with a double quotation mark, in python you can use both single and double quotation and if you can use one kind of quotation inside another one as well. For multiline strings , double or triple quotes can be used. Strings in Python are Unicode, bytestrings are represented with b prefix.Modulo (%) and a tuple is used to fill strings with values.It is important to note that every %s gets itself replaced by an item from the tuple , it happens left to right , Dictionary subs can also be used .

Flow Control in Python:

For flow control python has if , for and while statement and it works just like c++ but python does not have switch , so for selection we will have to used if , number lists can be obtained by range(<number>).


We can declare functions in Python using def keyword . Arguments can be set to function , they can be mandatory or optional . Mandatory arguments are set with default values. Parameters can be passed by reference . but immutable types (tuples, ints, strings, etc) cannot be changed in the caller by the callee.

Class in Python

Python is an Object Oriented Programming language , almost everything in python is an object.Class is a blueprint for creating object.

Create a class by using the class keyword and we create an object like objectName = classname().

Now we know how to create object is simplest form but it is not enough for any real life usage , there is a built in __init__() function in python which is fundamental to Python Classes.

__init__() function is used to object property assignment.

Exercise : Make a class student with a function that will greet the student .

Importing :

You can import library by using keyword import followed by the library name. Python has a ton of libraries with tons of different functionalities which makes working with python more interesting .


Python has several functions for creating, reading, updating, and deleting files. The Open function in python takes two parameters, the file name and mode. For reading just specifying the name is enough.

Write files using file.write

A file can be deleted using the os module .

I hope you learned something about python from it , Thank you.

Prepared by Masud Imran


Leave a comment

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