Saturday 28 February 2015

Introduction to python programming language

Python is the most powerful, ideal, flexible, easy and user friendly language to use especially in bioinformatics. It is released in 1991 by Guido Van Rossum and is named after Monty python.It is used mainly in bioinformatics because it is easy as compared to other languages and contain libraries for bioinformatics.
Python programming has object oriented programming capability but lack multithreading programming support.Apart from that keywords are case sensitive but syntax is easy as compared to other programming languages.Most important thing while writing a program is you must take care of indentation. Write program with proper indentation other wise it will give error in the output.

How to use python and write program??
Here are few steps to write program in python.
Step 1:
Install python form the web :www.python.org and install python 3.4.3
step 2:
open  IDLE(python 3.4 GUI) . A window will appear on your screen just start to write your program on it.



Python basics
Comments
In python programming language comments are written using #.
comments can be written in new line or in front of any code by using #
2a+2b   # Mathematical calculation
Variables
There is no need to declare  data type of variables in python. The type of variable is declared automatically by the type of value you are assigning to variable.
msg="hello world"
x=5
Variable names are case sensitive and they must not start with a number.
keywords
keywords in python are case sensitive and they are always in lower case.
e.g if, elif, else, and, or, in ,return, break
Operators for comparison
Comparison operators are mainly same to the operators used in other programming languages. some of the comparison operators are given below.
x==y
x!=y
x<y
x<=y
x>y
x>=y
Function definition and function calling
General syntax to define and call a function is given below.
dna= "agtggtggtcaaa"
def msg()
    print(dna)
print("program to print DNA sequence")
msg()
print("end of my program")
while writing a program take care of the indentation.
Program output
program to print DNA sequence
agtggtggtcaaa
end of my program






No comments:

Post a Comment