2. Disclaimer:This presentation is prepared by trainees of
baabtra as a part of mentoring program. This is not official
document of baabtra –Mentoring Partner
Baabtra-Mentoring Partner is the mentoring division of baabte System Technologies Pvt .
Ltd
3. PYTHON
Ashwin Anand V
Email/facebook id:ashwinanand99@gmail.com
5. What is Python?
• A programming language with strong
similarities to PERL, but with powerful
typing and object oriented features.
– Commonly used for producing HTML content
on websites. Great for text files.
– Useful built-in types (lists, dictionaries).
– Clean syntax, powerful extensions.
6. Use an integrated development environment (IDE)
Source
file
Execution
shell
7. Why Python?
• Natural Language Tool Kit
• Ease of use; interpreter
• AI Processing: Symbolic
– Python’s built-in data types for strings, lists, and more.
– Java or C++ require the use of special classes for this.
• AI Processing: Statistical
– Python has strong numeric processing capabilities:
matrix operations, etc.
– Suitable for probability and machine learning code.
8. Compiling and interpreting
• Many languages require you to compile (translate) your
program into a form that the machine understands.
compile execute
source code byte code output
Hello.java Hello.class
• Python is instead directly interpreted into machine
instructions.
interpret
source code output
Hello.py
9. Python features
no compiling or linking rapid development cycle
no type declarations simpler, shorter, more flexible
automatic memory management garbage collection
high-level data types and fast development
operations
object-oriented programming code structuring and reuse, C++
embedding and extending in C mixed language systems
classes, modules, exceptions "programming-in-the-large"
support
dynamic loading of C modules simplified extensions, smaller
binaries
dynamic reloading of C modules programs can be modified without
stopping
10. Python features
universal "first-class" object model fewer restrictions and rules
run-time program construction handles unforeseen needs, end-
user coding
interactive, dynamic nature incremental development and
testing
access to interpreter information metaprogramming, introspective
objects
wide portability cross-platform programming
without ports
compilation to portable byte-code execution speed, protecting source
code
built-in interfaces to external system tools, GUIs, persistence,
services databases, etc.
11. Variables
Variables are names for values
Created by use: no declaration necessary
>>> planet = 'Pluto' variable value
>>> print planet
Pluto planet 'Pluto'
>>> moon = 'Charon'
>>> p = planet moon 'Charon'
>>> print p
Pluto p
>>>
12. A variable is just a name
Does not have a type
>>> planet = 'Pluto' variable value
>>> planet = 9
planet 'Pluto'
>>>
9
Values are garbage collected
If nothing refers to data any longer, it can be recycled
13. Expression
Print : Produces text output on the console
Syntax:
print "Message"
print Expression
Prints the given text message or expression value on the console, and
moves the cursor down to the next line.
print Item1, Item2, ..., ItemN
Prints several messages and/or expressions on the same line.
Examples:
print "Hello, world!"
age = 45
print "You have", 65 - age, "years until retirement"
Output:
Hello, world!
You have 20 years until retirement
14. Input
• input : Reads a number from user input.
– You can assign (store) the result of input into a variable.
– Example:
age = input("How old are you? ")
print "Your age is", age
print "You have", 65 - age, "years until retirement“
Output:
How old are you? 53
Your age is 53
You have 12 years until retirement
15. Uses of Python
• shell tools
– system admin tools, command line programs
• extension-language work
• rapid prototyping and development
• language-based modules
– instead of special-purpose parsers
• graphical user interfaces
• database access
• distributed programming
• Internet scripting
16. What not to use Python (and kin)
for
• most scripting languages share these
• not as efficient as C
– but sometimes better built-in algorithms (e.g.,
hashing and sorting)
• delayed error notification
• lack of profiling tools
18. • If this presentation helped you, please visit
our page facebook.com/baabtra and like it.
Thanks in advance.
• www.baabtra.com | www.massbaab.com |ww
w.baabte.com