Chapter 1 – Python
What is Python?
• Python is a general purpose programming
language and a scripting language.
• Often, it is applied in scripting roles.
• It’s also called an interpreted language.
Difference between Programming and
Scripting language
Programming Language Scripting Language
Program is executed. (Source Script is interpreted
is compiled then result is
shown)
Program is a sequence of Script is written in scripting
instructions of a task for a language. It’s a type of
computer to perform. programming language in
which we can write code to
control another application.
History of Python
• Invented in early 90s by Guido Van Rossum in
Netherlands.
• It was conceived in 1980s and its
implementation was started in December, 1989.
• Guido Van Rossum is a fan of “Monty Python’s
Flying Circus” TV show.
• Named after Monty Python.
• Open sourced from the beginning.
Scope of Python
• Science → Bio-informatics
• System administration
◦ Unix
◦ Web Logic
◦ Web Sphere
• Web Application Development
◦ CGI
◦ Jython
• Servlets Testing
◦ Scripts
What can I do with Python
• System programming
• Graphical User Interface Programming
• Internet Scripting
• Component Integration
• Database Programming
• Gaming, Images, XML, Robot, etc.
Who uses Python today?
Python is being applied by real revenue-generation
companies:-
• Google uses Python in its web search system
and employed its creator
• Intel, Cisco, IBM, etc. use Python for hardware
testing.
• ESRI use Python as an end-user customization
tool for its popular GIS mapping system.
• YouTube use Python for video sharing service.
Why do people use Python?
• It is object oriented:-
◦ It supports polymorphism, operation
overloading and multiple inheritance
• It’s free (open source):-
◦ Downloading and installation is free and
accessible.
• It’s Powerful:-
◦ Dynamic Typing
◦ Built-in types and tools
◦ Library utilities
◦ Third party utilities
• It’s Portable:-
◦ It runs virtually on every major platform.
◦ It will run perfectly same if you have the
compatible interpreter installed.
Interactive vs Scripting Mode
Interactive Mode Script Mode
• Instructions are given in • Saves all commands as
python prompt shell programs
• Does not save commands • Executes separately in
as a program python shell window.
• Used for testing code
Operators in Python
// → Returns the whole part after division
** → Exponent
Data Types
• Booleans
• Numbers (Int, Float, Fractions)
• Strings
• Lists
• Tuples
• Sets
• Byte, Byte arrays
type() function tells the data type of the variable.
Eg:-
a = “DK
Pattammal”
print(type(a))
O/P:
<type ‘str’>
Function Does
sum() Returns sum of all value is list/tuple
min() Returns smallest value in list/tuple
max() Returns largest value in list/tuple
len() Returns the no. of values in list/tuple
list()/tuple() Converts list/tuple to tuple/list
Tuples are immutable Python object whose value
cannot be changed.
SYNTAX
List:-
a = [1, 2, 3]
Tuple
a = (1, 2, 3)
Chapter 3 – Introduction to
Turtle module
Modules are files containing Python definitions and
statements:-
• They can define functions, classes, variables
• They can include runnable code
• They make code easier to understand by
grouping related code
• They logically organize the code
SYNTAX:-
import <module>
(or)
from <module> import
*
Types of functions in Python:-
•