2. Agenda
What is Python?….
History of Python
Features
Uses of Python in industry
Python Building Blocks
Python environment setup
Simple Python program
PyCharm IDE installtion
Python Data Types
3. What is Python
Python is a high-level, general-purpose and a very
popular programming language.
Python is an interpreted, interactive and object
oriented language.
4. History of Python
The idea of Python started in late 1980S
Real implementation of Python was started in
December 1989
Finally published in February 1990(Netherland) by
Guido van Rossum , and released.
Picked ‘Python’ name- comedy show(Monty Python’s
flying circus).
5. Features
Following are features of Python –
Interactive
Object -oriented
Interpreted
Platform independent
Automatic memory management
free and open source
readability
dynamically typed
6. Uses of Python in industry
Python uses in Central Intelligence Agency (CIA)
Google's first search engine
Facebook (in their production engineering)
NASA uses Workflow Automation Tool which is written in
python
Nokia uses python for its platform s60
The entire stack of dropbox was written in python
Dropbox.
Quora is social commenting site which is written in
python.
Instagram (uses python for front end).
YouTube
7. Python Building Blocks
Python Identifiers:
All the variables, class, object, functions, lists,
dictionaries etc. in Python are known as Identifiers.
Rules for giving identifier:
1. Case sensitive.(num and Num both are different
functions)
2. Name should not be keyword.
3. Name can begin with letter or underscore(_) only
4. contains both numbers and letters along with
underscores (A-z, 0-9, and _ ).
8. Python Building Blocks
Variable: A variable is nothing but a reserved memory
location to store values.
Rules for variable names same as identifiers.
Ex. valid invalid
name 1name
Full_name Full name
_4(meaningless) 123name
_string break
Var_123 @city
9. Variables
Do not require explicit declaration.
other programming language Python language
int a=20; a=20
Allows to assign value to multiple variables
a1=a2=a3=a4=30
Allows to assign sequence of values to sequence of
variables
s1,s2,s3=10,20,30
10. Keywords:
1. The keywords are special words reserved for some
purpose.
2. The names of keywords can be not be used as
variable name.
12. Indentation
refers to the spaces at the beginning of a code line.
Python uses indentation to indicate a block of code.
For example –
age = 1
if age <= 2:
print(' true')
Output: True
indent
13. Comments
Comments can be used to explain Python code.
In Python, we use the hash (#) symbol to start writing
a comment.
ex. A=12 #value 12 assign to variable a
Python Interpreter ignores comment.
For multiple line comments uses three single quotes (‘’’
……..‘’’) three double quotes (””” ……“””).
14. Python Environmental Setup
1. First, download the latest version of Python from the
official website. I have downloaded python 3.10.2
version. For that purpose open the web site
https://www.python.org
26. Modes of Working in Python
1) Interactive mode- gives immediate feedback for
each statement. Fed statements are stored in active
memory.
2) Script mode- python commands are stored in a file
and the file is saved using the extension .py
30. Program for practice
1. Running Simple Python program to Display multiple
lines Message(script mode)
2. Running Simple Python to Display 'welcome'
Message(interactive mode)
35. Python Data Types
Data types are used to define type of variable.
Data types
numeric Strings Tuples Lists Dictionary
36. Python Data Types
1) Numeric/Numbers:
Number stores numeric values.
The integer, long, float, and complex values belong to a Python
Numbers data-type.
type() function to know the data-type of the variable.
isinstance() function is used to check an object belongs to a
particular class.
num=10
a=54.3 #float number
B=0o2345 #octal number
Bin=0b10101 #bin number
hex=0x4325 #hex. number
X+yj=3+6j #complex
39. 2) String :
String is a collection of characters.
uses single quote(‘…’), double quote (“….”)or triple quote
(”””…..”””)to define a string.
We can use three operators along with the string is slicing
operator[] or[:],concatenate operator(+), repetition operator *.
ex. >>> strl="My"
>>> str2="Python“
>>> print (str2[0]) #slicing operator
output: P
>>> print (str2)
>>>Python
>>> print (strl+str2) # concatenate operator
output: MyPython
>>> print (str2*3) # repetition operator
output: PythonPythonPython
‘”””Python””””
40. 3) List :
similar to array in C or C++ but it can simultaneously
hold different types of data in list.
It is basically an ordered sequence of some data
written using square brackets([]) and commas(,).
Ex. -
>>> #List of only strings
>>> b=["Sun", "Mon”, “Tue", "Wed“]
>>> print (b)
output: ['Sun', 'Mon', 'Tue', 'Wed']
Like string Same
operators use in list-
slicing operator[] or [:],
concatenate
operator(+), repetition
operator(*)
41. 4) Tuple :
collection of elements and it is similar to the List.
But the items of the tuple are separated by comma(,)
and the elements are enclosed in ( ) parenthesis.
Tuples are immutable.(can not change value)
Ex.->>> #Tuple of both integers and strings
>>> b=(“one”,1, 2, "two", "three", 3)
>>> print (b)
output: ('one', 1, 2, ‘two', 'three',3)
>>> print (b[3]) # slicing operator
output: two
Like string Same
operators use in list-
slicing operator[] or [:],
concatenate
operator(+), repetition
operator(*)
42. 5) Dictionary
collection of elements in the form of key:value pair.
for example-{1:’Red’, 2:’black’}
dictionaries are like a hash-table that has pair of
index(key) and element(value).
present in the curly brackets.
Ex. – dict={1:’red’,2:’blue’,3:’green’}
>>>print(dict)
output:{1:’red’,2:’blue’,3:’green’}
>>>print(dict.keys())
output: dict_keys([1,2,3])
>>>print(dict.values())
output: dict_values([red,blue,green])
43. Input through keyboard
Here, python have built-in function input() to read
input value.
Ex. print(“enter your name”)
name=input()
The default of read value is string only.
Type casting is nothing but it convert one data type
(string) into other another data type.
Ex. print(“enter your age”)
name=int(input())