Help on Python IDE Selection, find the best IDE as per your requirement.

Find the best Python IDE as per your requirement

Help on Python IDE Selection

Python integrated development environment (IDE) selection for your development work is one of the primary and important work you should do. A good IDE can improve your performance of coding and can also help you to write clear robust code. Here is few choice and ups and downs of those IDEs –

  1. IDLE
  2. eclipse – pydev
  3. anaconda – heavy weight software around 1.5 GB
  4. JetBrains – PyCharm
  5. Sublime

Hope this Video will help you to choose your IDE for python development. Feel free to give comment in comment section of video.

Python hello world program video tutorial.

Video Tutorial on Python hello world program

Video Tutorial of Hello world program in Python

This is Video tutorial uploaded on youtube to understand how to write first python program. This also includes

  1. From where you can download Python setup
  2. How to install it
  3. How to open IDLE script
  4. How to write code in interactive mode of IDLE.

Hope you will like this video and will give your valuable suggestion on this video link.

Insertion Sort in Python

Insertion Sort in Python

Insertion sort is also one of the common sorting technique used. In this technique sorting place after each element encounter. Story of sorting is very simple. Very first node is ignored as it is known as sentinel node. Now from second element will be chosen for sorting. The insertion sort technique checks it position in 0 to n-1 element in the same list where n is the current position and insert the element. This works get repeated till the last element gets sorted. So you will observe that after every elements sorting the list get sorted till the element position. Here is the code and example of Insertion sort.

lst = [15, 6, 13, 22, 3, 52, 2]
print("original list is - ", lst)
for i in range(1, len(lst)):
    key = lst[i]
    j = i - 1
    while j >= 0 and key < lst[j] :
        lst[j + 1] = lst[j]
        j = j - 1        
    else :
        lst[j + 1] = key
    print("List after {0} pass - ".format(i),lst)
print('Now sorted list is - ', lst)

Now we will see the output of the code –

original list is – [15, 6, 13, 22, 3, 52, 2]
List after 1 pass – [6, 15, 13, 22, 3, 52, 2]
List after 2 pass – [6, 13, 15, 22, 3, 52, 2]
List after 3 pass – [6, 13, 15, 22, 3, 52, 2]
List after 4 pass – [3, 6, 13, 15, 22, 52, 2]
List after 5 pass – [3, 6, 13, 15, 22, 52, 2]
List after 6 pass – [2, 3, 6, 13, 15, 22, 52]
Now sorted list is – [2, 3, 6, 13, 15, 22, 52]

Thank you. If you have any query you can ask and post comments to me. I will try to reply.


Bubble Sort in Python

Bubble sort is one of the import sorting technique which is implemented in many languages. Here we can implement Bubble Sort technique in Python as well. For this we need an array (Same Data element) which is nothing but a List in Python. The technique is to sort the adjacent element in order (ascending or descending). It you will do so, the largest element in the array will get sorted in every pass. So after every pass one largest element will get sorted in ascending order if sorting is done in ascending order. Here is the sample code for bubble sort and its output after every pass.

Created on Jan 10, 2020<br>
Bubble sort implemented in Python in ascending<br>
order using List.<br>
lst = [56, 778, 87, 55, 11, 33, 97]
print('Original list is - ', lst)
n = len(lst)
for i in range(n):
     for j in range(0, n - i - 1):
         if lst[j] > lst[j + 1] :
             lst[j], lst[j + 1] = lst[j + 1], lst[j]    
     print('Sorted list after {0} - {1}'.format(i+1,lst))
 print('Sorted list is - ', lst)

Output of above code will look like –

Original list is – [56, 778, 87, 55, 11, 33, 97]
Sorted list after 1 – [56, 87, 55, 11, 33, 97, 778]
Sorted list after 2 – [56, 55, 11, 33, 87, 97, 778]
Sorted list after 3 – [55, 11, 33, 56, 87, 97, 778]
Sorted list after 4 – [11, 33, 55, 56, 87, 97, 778]
Sorted list after 5 – [11, 33, 55, 56, 87, 97, 778]
Sorted list after 6 – [11, 33, 55, 56, 87, 97, 778]
Sorted list after 7 – [11, 33, 55, 56, 87, 97, 778]
Sorted list is – [11, 33, 55, 56, 87, 97, 778]

Thank you . Please post comment you have any query based on Bubble sorting.

Palindrome String check using recursion in Python

Palindrome String check using recursion in Python

Recursion of function is one of the interesting feature of any function of recursive nature. Benefit of using recursion is 1. Less line of code for implementation. 2. No need to write iterative statement multiple time. and easy to learn. In case of recursion the function use to call itself again and again till it reaches at bottom and returns to its caller(self) with calculated value. The self will again calculate next level of value and return to its caller. It goes to continue till it comes out from the very fist call of function. Here We have implemented Palindrome String check using Recursion function.

Created on Jan 8, 2020
word = input("Enter word to check palindrom string - ")
def palindromCheck(word):
    length = len(word)
    if length == 0 or length == 1:
        return "Palindrom String"
    elif word[0] == word[length - 1] :        
        return palindromCheck(word[1:length - 1])        
    else :
        return "Not Palindrom String"

status = palindromCheck(word)    
print("{0} is {1}".format(word, status))

Here function palindromCheck() is a recursive function which is called from main once by passing the word to check palindrome. Now this function is called again and again by passing current words first position and last-1 position data. If every thing goes well it will return palindrome string else it will return not a palindrome string. Check your self for the output. Hope it helps.

Please comment if you want your valuable feedback or code improvement advice to be added by me.

Sample code to connect python with database

Connect Python with MySql

Python having feature to connect any of the database with the help of different database connection packages. Like to connect Python with MySql we can use mysql.connector package. Which can be downloaded from pip package of Python very easly. Here is the example of Python connection with MySQL.

import mysql.connector
mydb = mysql.connector.connect(

mycursor = mydb.cursor()
sql = “SELECT * FROM student”
myresult = mycursor.fetchall()

for x in myresult:

Here you need to import mysql.connector if already installed in your machine else you need to download and install using pip command. You can google it for installation process using pip. Once imported connector then you need to create connection using connect function by passing host, user, passwd and database name. Once the connection is ready you can call cursor and execute query on cursor. Once the function fetchall() called the result need to store in variable and at last iterate the result and get desire output. That’s it. You are done.

Fibonacci Series using recursion.

Fibonacci Series using recursion

In Python the Fibonacci numbers, commonly denoted Fn form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. Here is the example of Fibonacii Series using Recursion in Python.

Fibonacii using Recursion in Python

Thank you, your comments are appreciated.

Object Oriented Code in Python

Object Oriented Code in Python

This is time to go through the code to demonstrate the concept of OOP in Python. This is well known fact that OOP can not be done without Class and Object. So here is the example of Class and Object in Python.

Code of OOP in Python

Output of above code is –

Output of two Students Object

Now lets start understanding the code line by line. First line to Fourth line nothing but class level comment. Make it as clear and understandable as you can. Line no 8 is the beaning of class structure [class student(object): ]. It says that we are going start a class named Student and (object) is saying that this is new style of writing class and at last : is for starting the block statement. This is similar to { } sign in Java or C++

Next is [def __init__(self, name, marks):]. Here init is a function to initialise the object of class. If you are adding it well and good, if you left it don’t worry Python will insert it with default argument self on behalf of you. But here I used two extra parameters (name and marks), that means when ever user will try to create the object of Student class he/she have to pass these two parameters. After that and self.marks are two instance variables which are getting initialised by parameters of init method. Remember the style of writing init method, it starts with two underscore sing and ends with the same two underscore sign.

Now you can write N numbers of methods a per your business requirement. Remember that if the function takes self as parameter are instance method and will get called by the object directly. [def getStudent(self):] this is the only function we are heving right now.

Lastly we need to create object and call method associated with that. [s1 = student(‘Robin’, 98)] will create one object s1 of student class. As my init method takes two parameters except self. So need to pass. and lastly call getStudent() on s1. You will get output as above. I created two Objects, you can create as much as you want.

That’s it. You are done with basic example of Class and Object in Python. Comments and feedback are always welcome. Bye bye…

Basic Object Oriented Concept in Python

Object Oriented Concept in Python

Object oriented programming in Python is easy most then other OOP languages. Object oriented programming concept relates the programming to real world entities. You can reuse your code by creating multiple instance. Here import thing is to understand the concept of class and object.

Concept of Class and Object

Class – Classes are blueprint of real world situation, if you want to represent students details in terms of programming then you create a class named Student and add attributes to it as per your requirement like sname, fname, class, rollno, contactno, addr etc or any information that you want to get from Student.

Object – Objects are real instance of class created earlier (Student). You can create as much as object as per your requirement. Each object will have its own attribute associated and if you call the object you will able to get all the attributes detail associated with that object. Suppose rahul is the object of Student then rahul will carry all other infomations [sname-paul, fname-john, classs-9, addr- xyz colony]. Lets understand with code using Python in next post.