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 –
Hope this Video will help you to choose your IDE for python development. Feel free to give comment in comment section of video.
]]>This is Video tutorial uploaded on youtube to understand how to write first python program. This also includes
Hope you will like this video and will give your valuable suggestion on this video link.
]]>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 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> @author: admin@pythonport.com<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.
]]>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 @author: admin@pythonport.com ''' 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.
]]>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(
host=”localhost”,
user=”root”,
passwd=”bokaro”,
database=”jnvbokaro”
)
mycursor = mydb.cursor()
sql = “SELECT * FROM student”
mycursor.execute(sql)
myresult = mycursor.fetchall()
for x in myresult:
print(x)
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.
]]>In Python the Fibonacci numbers, commonly denoted F_{n} 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.
Thank you, your comments are appreciated.
]]>Navodaya Vidyalaya Samiti invites applications for admission in Class-IX against vacant seats in Jawahar Navodaya Vidyalayas for the session 2020-21. Online submission of applications starts from 25 October, 2019. Application may be submitted free of cost by accessing NVS website: www.navodaya.gov.in (or) nvsadmissionclassnine.in
CBSE has given sample questions for class Xth and class XIIth final exam -2020 much before time expected in last week of September 2019. This year CBSE has changed question pattern for all the subjects. So this is very important to students and teachers to go through the sample paper given. Most of the common change across the subject what I found is that 20-30% questions are going to be objective type (one marks each) across all subject.
This will definitely going to make question paper yet conceptual. Because to solve these objective type you need to read whole book or syllabus properly. Now here is the link to get the question papers from CBSE Website.
Click here for Sample papers for class XII all subject
Click here for Sample papers for class X all subject
Hope you will get benefited with this information. Best of luck for your preparation for examination.
]]>