Sujit Shakya
Python
Programming Language?
Language is a tool to perform certain task.
Categories:
Compiled language & Interpreted/Scripting
Language
C, C++ are the example of Compiled Language.
PHP, Perl are the example of Scripting Language
What is Python?
Compiled Language or Scripting Language?
What is Python?
Compiled Language or Scripting Language?
Python was developed by Guido van Rossum in the
late 1980s.
It is an Object Oriented High Level Language.
Python is a scripting language, but in principle, it is first compiled and
then interpreted.
Guido Van Rossum
Why Python?
print “hello” #display hello in the screen
include<stdio.h>
include<conio.h>
void main()
{
printf(“Hello World”); /*display hello in the screen*/
getch();
}
Python focuses on user readability and
simplicity
pi = 3.14
for r in range(4):
area = pi * r*r
print r, area
print “End of Program”
Python is dynamic in nature.
#include<stdio.h>
#include<conio.h>
void main(){
float pi = 3.14;
int r;
float area = 0;
for(r=0; r<5; r++){
area = pi * r*r;
printf(“%d %f”, r, area);
}
printf(“End of Program”);
}
Why Python?
Why Python?
 Beautiful is better than ugly.
 Explicit is better than implicit.
 Simple is better than complex.
 Complex is better than complicated.
 Readability counts.
Lots of documentation and resources are
available in internet for FREE !!
Why not Python?
 Its dynamic nature costs more memory usage.
 Its execution is slower than other compiled language
like C and java.
Who uses Python?
Who uses Python?
Who uses Python?
Who uses Python?
How to use Python?
Installation
Download python 2.7 interpreter from http://www.python.org/download/
and install it.
How to use Python?
Installation
Download python 2.7 interpreter from http://www.python.org/download/
and install it.
Getting Started
Open python shell from start menu.
Open the new window from file menu, write some python code and
press F5.
Or, simply type your python code and press enter.
How to use Python?
Basic Syntax
#print something on screen
print “something”
How to use Python?
Basic Syntax
#print something on screen
print “something”
#if condition
if some_condition_1:
statements 1
elif some_condition_2:
statement 2
else:
statement 3
How to use Python?
Basic Syntax
#for loop
for count in range(10):
do something for 10 times starting from 0-9
How to use Python?
Basic Syntax
#for loop
for count in range(10):
do something for 10 times starting from 0-9
#while loop
i=0
while i<5:
print “hello”, i
i+=1
How to use Python?
Basic Syntax
#list
num_list = [0,1,2,3,4,5]
print num_list[0] #prints 0
print num_list[9] #Error: index out of range
How to use Python?
Basic Syntax
#list
num_list = [0,1,2,3,4,5]
print num_list[0] #prints 0
print num_list[9] #Error: index out of range
#exception handling
try:
print num_list[9]
except:
print “Oops something went wrong”
How to use Python?
Basic Syntax
#function
def sample_function:
„‟‟some code written here. Where triple quote is a
multiple line comment and also a documentation for
your function‟‟‟
GUI application using Python.
Python has a huge number of GUI framework (or
toolkit).
Some of them are:1. Tkinter
2. PyQt
3. PyGTK
4. PyUI
and many more…………
Web Application using
Python.
Python has a huge number of web framework.
Some of them are:
1. Django Web Framework
2. Cherry Py
3. Web2py
4. Zope2
and many more…………
Thank You!!!!

Ctrc python

  • 1.
  • 2.
    Programming Language? Language isa tool to perform certain task. Categories: Compiled language & Interpreted/Scripting Language C, C++ are the example of Compiled Language. PHP, Perl are the example of Scripting Language
  • 3.
    What is Python? CompiledLanguage or Scripting Language?
  • 4.
    What is Python? CompiledLanguage or Scripting Language? Python was developed by Guido van Rossum in the late 1980s. It is an Object Oriented High Level Language. Python is a scripting language, but in principle, it is first compiled and then interpreted.
  • 5.
  • 6.
    Why Python? print “hello”#display hello in the screen include<stdio.h> include<conio.h> void main() { printf(“Hello World”); /*display hello in the screen*/ getch(); } Python focuses on user readability and simplicity
  • 7.
    pi = 3.14 forr in range(4): area = pi * r*r print r, area print “End of Program” Python is dynamic in nature. #include<stdio.h> #include<conio.h> void main(){ float pi = 3.14; int r; float area = 0; for(r=0; r<5; r++){ area = pi * r*r; printf(“%d %f”, r, area); } printf(“End of Program”); } Why Python?
  • 8.
    Why Python?  Beautifulis better than ugly.  Explicit is better than implicit.  Simple is better than complex.  Complex is better than complicated.  Readability counts. Lots of documentation and resources are available in internet for FREE !!
  • 9.
    Why not Python? Its dynamic nature costs more memory usage.  Its execution is slower than other compiled language like C and java.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
    How to usePython? Installation Download python 2.7 interpreter from http://www.python.org/download/ and install it.
  • 15.
    How to usePython? Installation Download python 2.7 interpreter from http://www.python.org/download/ and install it. Getting Started Open python shell from start menu. Open the new window from file menu, write some python code and press F5. Or, simply type your python code and press enter.
  • 16.
    How to usePython? Basic Syntax #print something on screen print “something”
  • 17.
    How to usePython? Basic Syntax #print something on screen print “something” #if condition if some_condition_1: statements 1 elif some_condition_2: statement 2 else: statement 3
  • 18.
    How to usePython? Basic Syntax #for loop for count in range(10): do something for 10 times starting from 0-9
  • 19.
    How to usePython? Basic Syntax #for loop for count in range(10): do something for 10 times starting from 0-9 #while loop i=0 while i<5: print “hello”, i i+=1
  • 20.
    How to usePython? Basic Syntax #list num_list = [0,1,2,3,4,5] print num_list[0] #prints 0 print num_list[9] #Error: index out of range
  • 21.
    How to usePython? Basic Syntax #list num_list = [0,1,2,3,4,5] print num_list[0] #prints 0 print num_list[9] #Error: index out of range #exception handling try: print num_list[9] except: print “Oops something went wrong”
  • 22.
    How to usePython? Basic Syntax #function def sample_function: „‟‟some code written here. Where triple quote is a multiple line comment and also a documentation for your function‟‟‟
  • 23.
    GUI application usingPython. Python has a huge number of GUI framework (or toolkit). Some of them are:1. Tkinter 2. PyQt 3. PyGTK 4. PyUI and many more…………
  • 24.
    Web Application using Python. Pythonhas a huge number of web framework. Some of them are: 1. Django Web Framework 2. Cherry Py 3. Web2py 4. Zope2 and many more…………
  • 25.