Department of CSE-H
COURSE NAME: DATA ANALYTICS AND
VISUALIZATION
COURSE CODE: 22DSB3101A
Topics: PYTHON INTRODUCTION
Session - 22
AIM OF THE
SESSION
To familiarize students with the basic concepts of Python, such as introduction
INSTRUCTIONAL
OBJECTIVES
This Session is designed to know Python introduction
LEARNING OUTCOMES
At the end of this session, you should be able to know the basic of python and how to use it
WHAT IS PYTHON ?
Interactive
0
1
Interpreted
0
2
Object Oriented
0 Scripting Language
3
0
4 High Level Programming
Language
DIFFERENCE BETWEEN PROGRAMING LANGUAGE
& SCRIPTING LANGUAGE
HELLO
Java GKTCS
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”)
Beginne
It is r
simple Friendly
Why
Mature
Package
Versatile &
Flexible
Libraries
?
Suppor
Expandable t AI
ADVANTAGE
S
Free & Open Interpreted Vast Libraries
Source Language Support
Improved Dynamically Object
Productivity Typed Oriented
DISADVANTAGE
S
Speed Design
Limitation Restriction
s s
Weak in Underdevelope
Mobile d DB layers
Computing
WEB FRAMEWORKS
Flask Web2Py
CherryPy
CherryPy Django
Tornado Pyramid
Bottl DASH
e
CubicWeb
File Extensions in
Python
01 .py
02 .pyc 03 .pyd
The normal
extension for a The A Windows
Python source compiled DLL(Dyn
file bytecode amic Link
Library)
file
04 .pyo 05 .pyw
06 .pyz
A file created A Python script A Python script
with for Windows archive
optimization
s
Applications Of
Python
Network Web &
Programing 6 1 Internet
Development
Databas
e 5 2 Games and
3D
Access Graphics
Business
Application
4 3 Software
Developmen
s t
POPULAR WEBSITE BUILD WITH
PYTHON
Reddi
YouTube t Instagram
Google
Dropbox
Quora Pinterest
Step: 1
INSTALLING PYTHON ON WINDOWS
To download and install Python, go to Python's official
website [Link]
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
Machine
Code
Source code Running
Code
Library
Modul
e
RUNNING
When you openPYTHON
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 :
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",
"age" : 25 }
“Html“ }
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 into upper case into lower case
each word to
upper case
isdigit() isupper() swapcase()
Returns True if Returns True if all Swaps cases, lower
all characters in characters in the case becomes
the string are string are in upper case and vice
digits upper case. versa
VARIABLE
S
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
SELF-ASSESSMENT QUESTIONS
1. What is Python primarily known for?
a) Web design
b) Machine learning and data analysis
c) Image editing
d) Hardware programming
2. Which of the following is a valid Python variable name?
a) 1_variable
b) variable-1
c) variable_1
d) variable 1
TERMINAL QUESTIONS
1. Explain the key features of Python that make it a popular programming
language.
2. What is the Python interpreter, and how does it differ from compiled
languages like C or Java?
3. How do you create a variable in Python, and what are the rules for naming
variables?
4. What are Python's built-in data types? Provide examples of each.
5. What is a Python module, and how do you import one?
REFERENCES FOR FURTHER LEARNING OF THE SESSION
Reference Books:
1. Data science Hand book – Field cady- wiley
2. Statistical inference for data science-Brian Caffo
3. Introducing Data science by Davy cielen, Arno [Link], Mohamed Ali
Web Link:
[Link] Data Science Handbook 2. Coursera, Simplilearn course material
THANK YOU
Team – DAV