Python for AI, Data Science

Python is developed by Guido van Rossum. It is very powerful object oriented programming language. The syntax of python is very simple.

Let’s Learn the basic construct of python programming language:


A variable is a reserved memory location to store values. A variable name must begin with alphabet/underscore followed by alphabets/numbers/underscores. you can not use keywords as variable, keywords are reserved word used which convey special meaning to python compiler like class, for, if, else etc. Comment improve the readability of a code. We use # character to start the comment.


Different type variable

Python has three basic data type. To check type of variable use in-built type function.

Types of variable

isinstance function: checks whether a variable belongs to a particular class and return true and False based on the result.

Python Built in Data Structures


List function
List compression


tuple error





Control Structure

if….else statement: are control flow statement which run particular code only when a certain condition is satisfied otherwise another set of statements. The syntax of if else statement:

if condition:
block of code_1
block of code_2

For statement: is a looping statement in which set of statement execute repeatedly. The syntax of for statement:

for variable in sequence:
block of code

Break statement: is used to terminate the loop when a certain condition is met.

Continue statement: is used inside a loop to skip the rest of the statements and jump to the beginning of the loop.


def function_name(function_parameter):
block of code
return # optional

OOPs(object oriented programming language):

class phone and object iphone_X

Yield: statement halt function’s execution and return a value to caller, after returning value function resumed where it left off. We should use this in place of return, when data is large and memory less as yield don’t store the entire sequence in memory.


To view whole code file click here.

Keep learning and be innovative.



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store