Beruflich Dokumente
Kultur Dokumente
By:A.Shobharani
Shobha
What is Scripting Language?
• A scripting language is a “wrapper” language that integrates OS functions.
• The interpreter is a layer of software logic between your code and the
computer hardware on your machine.
Wiki Says:
• The “program” has an executable form that the computer can use directly to
execute the instructions.
• The same program in its human-readable source code form, from which
executable programs are derived (e.g., compiled)
• Python is scripting language, fast and dynamic.
• Python is called ‘scripting language’ because of it’s scalable interpreter, but
actually it
is much more than that
Shobha
What is Python?
Python is a high-level programming language which is:
Interpreted: Python is processed at runtime by the interpreter
Interactive: You can use a Python prompt and interact with the interpreter
directly to write your programs.
Object-Oriented: Python supports Object-Oriented technique of
programming.
Beginner’s Language : Python is a great language for the beginner-
level programmers and supports the development of a wide range of
applications.
Shobha
Job In Big Data space
Shobha
History of Python
Python was conceptualized by Guido Van Rossum in the
late 1980s.
Rossum published the first version of Python code (0.9.0)
in February 1991 at the CWI (Centrum Wiskunde &
Informatica) in the Netherlands , Amsterdam.
Python is derived from ABC programming language, which
is a general-purpose programming language that had
been developed at the CWI.
Rossum chose the name "Python", since he was a big
fan of Monty Python's Flying Circus.
Python is now maintained by a core development team at
the institute, although Rossum still holds a vital role in
directing its progress.
Shobha
Python Versions
Release dates for the major and minor
versions:
Python 1.0 - January 1994
Python 1.5 - December 31, 1997
Python 1.6 - September 5, 2000
Python 2.0 - October 16, 2000
Python 2.1 - April 17, 2001
Python 2.2 - December 21, 2001
Python 2.3 - July 29, 2003
Python 2.4 - November 30, 2004
Python 2.5 - September 19, 2006
Python 2.6 - October 1, 2008
Python 2.7 - July 3, 2010
Shobha
Python Versions
Release dates for the major and minor
versions:
Python 3.0 - December 3, 2008
Python 3.1 - June 27, 2009
Python 3.2 - February 20, 2011
Python 3.3 - September 29, 2012
Python 3.4 - March 16, 2014
Python 3.5 - September 13, 2015
Shobha
Key Changes in Python 3.0
Python 2's print statement has been replaced by the print() function.
Old: New:
Shobha
Basic Syntax
Indentation is used in Python to delimit blocks. The number of
spaces is variable, but all statements
within the same block must be
indented the same amount.
The header line for compound statements, such as if, while, def,
and
class should be terminated with a colon ( : ) Error!
Shobha
Web Frameworks
• Django
• Flask
• Pylons
• TurboGear
s
• Zope
• Grok
Shobha
Hello World
Shobha
The Python Interpreter
•Elements separated by
commas print with a space >>> print 'hello'
between them hello
•A comma at the end of the >>> print 'hello', 'there'
statement (print ‘hello’,) will hello there
not print a newline
character
Shobha
Documentation
The ‘#’ starts a line comment
Shobha
Comments in
• Python
Single Line
Comments
#To find the sum of two numbers
a = 10 # store 10 into variable a
Shobha
Comments in
• Python
Single Line
Comments
#To find the sum of two numbers
a = 10 # store 10 into variable a
Shobha
Comments in
• Python
When we want to mark several lines as comment, then we can write the previous
block of code inside ””” (triple double quotes) or ’’’ (triple single quotes) in the
beginning and ending of the block as.
”””
Write a program to find the total marks scored by a
student in the subjects
”””
’’’
Write a program to find the total marks scored by a
student in the subjects
’’’
Shobha
Comments in
• Python Python
supports only single line comments.
• Multiline comments are not available in Python.
• Triple double quotes or triple single quotes
are actually not multiline comments but they are regular
strings with the exception that they can span
multiple lines.
• Use of ’’’ or ””” are not recommended for comments as
they internally occupy memory.
Shobha
Datatypes in
• Python
A datatype represents the type of data
stored into a variable or memory.
• The datatypes which are already avaiable in
Python language are called Built-in
datatypes.
• The datatypes
which are created by the programmers
are called User-Defined datatypes
Shobha
Built-in
• datatypes
None Type
• Numeric
Types
• Sequences
• Sets
• Mappings
Shobha
None
• Typean object that does not
‘None’ datatype represents
contain
any value.
• In Java, it is called ‘Null’ Object’, but in Python it is
called ‘None’ object.
• In Python program, maximum of only one ‘None’
object is
provided.
• ‘None’ type is used inside a function as a default value of
the arguments.
• When calling the function, if no value is passed, then the
default value will be taken as ‘None’.
• In Boolean expressions, ‘None’
Shobhadatatype is represents ‘False’
Numeric
• int Types
• float
• comple
x
Shobha
int
• Datatype
The int datatype represents an integer number.
• An integer number is a number without
any decimal point or fraction part.
a = 10
b = -15
•
int datatype supports both negative and positive
integer numbers.
• It canstore very large integer
numbers conveniently.
Shobha
Float
• datatype
The float datatype represents floating point numbers.
• A floating point number is a number that contains a decimal
point.
#For example : 0.5, -3.4567, 290.08,0.001
num = 123.45
x = 22.55e3
#here the float value is 22.55 x 103
Shobha
bool
• Datatype
The bool datatype in Python represents
boolean values.
• There are only two boolean values True or
False that can be represented by this
datatype.
• Python internally represents True as 1 and
False as 0.
Shobha
Print
>>>print
Statement
“Python" Python
>>>print “Python
Programming" Python
Programming
Shobha
Print
>>> print 25
Statement
25
>>> print
2*2 4
>>> print 2 + 5 + 9
16
Shobha
Print
Statement
>>> print "Hello,","I","am",“Python"
Hello, I am Python
Shobha
Print
Statement
>>> print "Hello Python, " + "How are
you?" Hello Python, How are you?
>>> print "I am 20 Years old " + "and" + " My friend is 21 years
old.“ I am 20 Years old and My friend is 21 years old.
Shobha