INTRODUCTION
TO
PYTHON
What is Python ?
Interactive
01
Interpreted
02
Object Oriented Scripting
03 Language
04
High Level Programming
Language
Difference between Programing language &
Scripting language
Hello GKTCS
Java
Class
Hello GKTCS
Python
PYTHON 2 PYTHON 3
Legacy Future
Library Library
0000
0100 ASCII 0000
Unicode
0001 0100
0001
7/2=3 7/2=3.5
print “GKTCS” print (“GKTCS”)
Beginner
It is Friendly
simple
Why
Mature
Package
Versatile &
Libraries
Flexible
?
Support
Expandable AI
Advantages
Free & Open Interpreted Vast Libraries
Source Language Support
Improved Dynamically Object
Productivity Typed Oriented
Disadvantages
Speed Design
Limitations Restrictions
Weak in Underdeveloped
Mobile DB layers
Computing
Web Frameworks
Flask Web2Py
CherryPy
CherryPy Django
Tornado Pyramid
Bottle Dash
CubicWeb
File Extensions in Python
01 .py
02 .pyc 03 .pyd
The normal
extension for a The compiled A Windows DLL
Python source bytecode file
file
04 .pyo 05 .pyw
06 .pyz
A file created A Python script A Python script
with for Windows archive
optimizations
Applications Of Python
Network Web & Internet
Programing 6 1 Development
Database Games and 3D
Access 5 2 Graphics
Business
Applications
4 3 Software
Development
Popular website build with Python
Reddit
YouTube Instagram
Google
Dropbox
Quora Pinterest
Installing Python on Windows
Step: 1
❑ To download and install Python, go to Python's official
website http://www.python.org/downloads/
Step: 2
❑ When download is complete run .exe file to install
Python.
Step: 3
❑ You can see python installation.
Step: 4
❑ when installation was complete you can see message
“setup was successful” on screen.
IDLE Development Environment
❑ Integrated DeveLopment Environment
❑ Text editor with smart indenting for creating
python files.
❑ Menu commands for changing system settings
and running files.
Python Interpreter
❑ Interactive Interface to python
Python 3.8.1 (tags/v3.8.1:1b293b6, Dec 18 2019,
22:39:24) [MSC v.1916 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for
more information.
>>>
How Python run’s
Interpreter
Byte Virtual
Compiler
Code Machine
Source code Running
Code
Library
Module
Running Python
❑ When you open the interpreter and type command
Datatypes
Text Type: str
Numeric Types: int, float, complex
Sequence Types: list, tuple, range
Mapping Type: dict
Set Types: set, frozenset
Boolean Type: bool
Binary Types: bytes, bytearray, memoryview
Datatypes and Example
❑ When you assign a value to a variable data type is set :
To store empty
values as NULL
in database
int float str
a=10 a=2.5 a=“GKTCS”
complex list tuple
a = [ “python", a = ( “python",
a=2x “Java", “Html“ ] “Java", “Html“ )
dict set bool
a={
"name" : “Amit", a = { “python", a=True
“Java", “Html“ }
"age" : 25 }
complex bytes bytearray
a=2x a=b”GKTCS” a=bytearray(5)
Basic Datatypes
❑ Integers(for numbers)
a=4+3 #answer is 7, integer addition
❑ Floats
a=5/2 #answer is 2.5
❑ Strings
Can use “ ” or ‘ ’ to specify.
“GKTCS” or ‘GKTCS’ are same.
String Methods
title() upper() lower()
Converts the first Converts a string Converts a string
character of each into upper case into lower case
word to upper
case
isdigit() isupper() swapcase()
Returns True if all Returns True if all Swaps cases, lower
characters in the characters in the case becomes
string are digits string are in upper case and vice
upper case. versa
Variables
❑ Variables are use to store data values.
❑ A variable is created when you assign a value to it.
x=2
y = “Amit"
print(x)
print(y)
Output
Rules for Python variables:
❑ A variable name must start with a letter or the underscore
character
❑ A variable name cannot start with a number
❑ A variable name can only contain alpha-numeric characters
and underscores (A-z, 0-9, and _ )
❑ Variable names are case-sensitive (age, Age and AGE are
three different variables)
Comments
Comments can be used to improve readability of the code.
1) Single-line comments
Simply create a line starting with the hash (#) character
#This would be a single line comment in Python
2) Multi-line comments
Created by adding a delimiter (""") on each end of the comment.
""" This would be a multiline comment in Python that
describes your code, your day, or anything you want it to """
Output