The document discusses Python as a programming language. It explains that Python is an interpreted, object-oriented, high-level scripting language. While Python code is first compiled and then interpreted, Python is considered a scripting language. The document provides examples of Python code and discusses why Python is easy to read and use for tasks like printing output and iterating with loops. It also briefly mentions some organizations that use Python.
2. 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
4. 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.
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
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?
8. 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 !!
9. Why not Python?
Its dynamic nature costs more memory usage.
Its execution is slower than other compiled language
like C and java.
14. How to use Python?
Installation
Download python 2.7 interpreter from http://www.python.org/download/
and install it.
15. 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.
16. How to use Python?
Basic Syntax
#print something on screen
print “something”
17. 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
18. How to use Python?
Basic Syntax
#for loop
for count in range(10):
do something for 10 times starting from 0-9
19. 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
20. 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
21. 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”
22. 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‟‟‟
23. 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…………
24. 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…………