SlideShare a Scribd company logo
PYTHON PROGRAMMING
Course Objective
 To learn about Python programming language syntax, semantics, and the runtime environment
Course Outcomes
After the successful completion of the course, the student will be able to:
CO1: To design, implement and test readable, efficient programs that take advantage of
Python built-in capabilities and follow Python best practices.
CO2: To understand implementation differences and performance tradeoffs associated with
various Python data structures.
CO3: To manipulate and analyze large datasets and handle missing or inconsistent values.
CO4: To identify the right data analytics structure to solve a problem.
Unit 1: Introduction to Python
Introduction to Python-coding styles in python-data types and variables- operators and expressions- numbers and relevant
functions-if statement- while statement-for statement-break and continue. arrays - sequences-lists-stack-queues-functional
programming- tuples-sequence unpacking- methods- dictionaries–sets- Fundamentals of OOPS in Python-Inheritance,
Encapsulation, Polymorphism, Data abstraction.
Unit 2: Functions in Python
User-defined functions-anonymous functions-recursive functions- introduction to modules-creating and importing and
modules-classes and objects-class methods- class properties-static method-constructor- method overriding-inheritance-
operator overloading-introduction to pip- installing packages-using python packages.
Unit 3: Basics of Numpy
NumPy Basics: arrays and vectorized computation-introduction to pandas data structures-series-data frame-index objects-
indexing, selection, and filtering- arithmetic and data alignment-applying functions and mapping-sorting and ranking-
summarizing and computing descriptive statistics-correlation and covariance-handling missing data-
hierarchical indexing.
Unit 4: Working with Graphs
Data Wrangling-combining and merging data sets- -data transformation-detecting and filtering outliers-string manipulation-
vectorized string functions in pandas- plotting and visualization- matplotlib api primer- colors, markers, and line styles- ticks,
labels, and legends- annotations and drawing on a subplot- saving plots to file- plotting functions in pandas.
Unit 5: Real time Data Analysis
Time Series- date and time data types and tools- converting between string and date time- time series basics-
indexing, selection, sub setting- date ranges, frequencies, and shifting-generating date ranges-
frequencies and date offsets-time zone handling- quarterly period frequencies- time series
plotting-data munging – splicing together data sources- decile and quartile analysis-sample applications-future
contract rolling- rolling correlation and linear regression- A Case study on
predict the future rating of a restaurant based on an ML model.
a) Reference Books
1. Michael H Goldwasser, David Letscher, “Object Oriented Programming in Python”, Prentice Hall, 1st
Edition, 2007.
2. Yashavant Kanetkar, Aditya Kanetkar, “Let us Python, BPB publication, 1st Edition, 2019.
3. Ashok Kamthane, Amit Kamthane, “Programming and Problem solving with Python”, McGraw Hill
Education (India) Private Limited, 2018.
4. Taneja Sheetal, Kumar Naveen, “Python Programming – A Modular Approach”, Pearson, 2017.
5. R Nageswara Rao, “Core Python Programming”, Dreamtech Press, 2017 Edition.
6. Peter Wentworth, Jeffrey Elkner, Allen B. Downey and Chris Meyers, “How to Think Like a Computer
Scientist: Learning with Python 3”, 3rd Edition, 2015.
7. Paul Barry, “Head First Python a Brain Friendly Guide”, O’Reilly, 2 nd Edition, 2016.
8. Dainel Y.Chen “Pandas for Everyone Python Data Analysis” Pearson Education, 2019.
Question paper Blue print
Unit
Hours Allotted in
the Syllabus
COs
Addressed
No. of Questions & Marks Distribution
Section A Total Marks Section B Total Marks Section C Total
Marks
I 8 CO1 1 2 1 5 - 0
II 12 CO2 2 4 1 5 1 10
III 14 CO3 2 4 2 10 1 10
IV 12 CO4 1 2 1 5 1 10
V 14 CO4 2 4 2 10 2 20
Bloom’s Taxonomy Level(s) Used
Remembering, Understanding
Levels
Applying, Analyzing Evaluating
and
Creating Levels
Applying, Analyzing,
Evaluating and
Creating Levels
Python Practical
Content
1. Write a python program to open a file and check what are the access permissions acquired by that file using os module.
2. Write a python program to find the linear regression.
3. Write a program to double a given number and add two numbers using lambda().
4. Write a Python Program to Using a numpy module create an array and check the following: 1. Type of array 2. Shape of array 3. Type of elements in array.
5. Create a dictionary and apply the following methods 1) Print the dictionary items 2) access items 3) use get() 4)change values 5) use len()
6. Write a python code to read a csv file using pandas module and print the first and last five lines of a file.
7. Write a python code to set background color and pic and draw a circle using turtle module
8. Write a python program to create a package, sub -package, modules and create staff and student function to module.
9 Write a python program to plot a bar graph for the car data set.
10 Write a python program to create a login web page using pycharm.
What is Python…?
• Python is a popular high-level programming language used in various applications
• Python is an easy language to learn because of its simple syntax
• Python can be used for simple tasks such as plotting or for more complex tasks
like machine learning
• Python supports modules and packages, which encourages program modularity
and code reuse.
• Python is a general purpose programming language that is often applied in
scripting roles.
• So, Python is programming language as well as scripting language.
• Python is also called as Interpreted language
The biggest strength of Python is huge collection of standard library which can be
used for the following:
 Machine Learning
 GUI Applications (like Kivy, Tkinter, PyQt etc. )
 Web frameworks like Django (used by YouTube, Instagram, Dropbox)
 Image processing (like OpenCV, Pillow)
 Web scraping (like Scrapy, BeautifulSoup, Selenium)
 Test frameworks
 Multimedia
 Scientific computing
 Text processing and many more..
What can Python do?
• Python can be used on a server to create web applications.
• Python can be used alongside software to create workflows.
• Python can connect to database systems. It can also read and modify files.
• Python can be used to handle big data and perform complex mathematics.
• Python can be used for rapid prototyping, or for production-ready software
development.
History
Invented in the Netherlands, early 90s by Guido van Rossum
Python was conceived in the late 1980s and its
implementation was started in December 1989
Guido Van Rossum is fan of ‘Monty Python’s
Flying Circus’, this is a famous TV show in Netherlands
Named after Monty Python
Open sourced from the beginning
Guido van Rossum
“Python is an experiment in how much
freedom program-mers need. Too much
freedom and nobody can read another's
code; too little and expressive-ness is
endangered.”
Why was python created?
"My original motivation for creating Python was the
perceived need for a higher level language in the
Amoeba [Operating Systems] project.
I realized that the development of system
Moreover, doing these things in the Bourne
administration utilities in C was taking too long.
shell
wouldn't work for a variety of reasons. ...
So, there was a need for a
language that would bridge the gap
between C and the shell”
- Guido Van
Rossum
Differences between program and
scripting language
• Program
•a program is executed (i.e. the
source is first compiled, and the result
of that compilation is expected)
•A "program" in general, is a
sequence of instructions written so
that a computer can perform
certain task.
• Scripting
•a script is interpreted
•A "script" is code written in a
scripting language. A scripting
language is nothing but a type of
programming language in which we
can write code to control another
software application.
Differences between program and
scripting language
Applications of Scripting Languages :
1. To automate certain tasks in a program
2. Extracting information from a data set
3. Less code intensive as compared to traditional programming
languages
Applications of Programming Languages :
1. They typically run inside a parent program like scripts
2. More compatible while integrating code with mathematical
models
3. Languages like JAVA can be compiled and then used on any
platform
python programming unit 1 wala ppt .pptx
• Advantages of Python
1. Easy to Read, Learn and Write
• Python is a high-level programming language that has English-like syntax. This
makes it easier to read and understand the code.
• Python is really easy to pick up and learn, that is why a lot of people recommend
Python to beginners. You need less lines of code to perform the same task as
compared to other major languages like C/C++ and Java.
2. Improved Productivity
• Python is a very productive language. Due to the simplicity of Python, developers
can focus on solving the problem. They don’t need to spend too much time in
understanding the syntax or behavior of the programming language. You write less
code and get more things done.
• 3. Interpreted Language
• Python is an interpreted language which means that Python directly executes the
code line by line. In case of any error, it stops further execution and reports back
the error which has occurred.
• Python shows only one error even if the program has multiple errors. This
makes debugging easier.
• 4. Dynamically Typed
• Python doesn’t know the type of variable until we run the code. It automatically
assigns the data type during execution. The programmer doesn’t need to worry
about declaring variables and their data types.
5. Free and Open-Source
• Python comes under the OSI approved open-source license. This makes
t free to use and distribute. You can download the source code, modify it and even
distribute your version of Python. This is useful for organizations that want to
modify some specific behavior and use their version for development.
• 6. Vast Libraries Support
• The standard library of Python is huge, you can find almost all the functions
needed for your task. So, you don’t have to depend on external libraries.
• But even if you do, a Python package manager (pip) makes things easier to import
other great packages from the Python package index (PyPi). It consists of over
200,000 packages.
• Disadvantages of Python
• 1. Slow Speed
• The line by line execution of code often leads to slow execution. The dynamic
nature of Python is also responsible for the slow speed of Python because it has to
do the extra work while executing code. So, Python is not used for purposes where
speed is an important aspect of the project.
• 2. Not Memory Efficient
• To provide simplicity to the developer, Python has to do a little tradeoff. The Python
programming language uses a large amount of memory. This can be a disadvantage
while building applications when we prefer memory optimization.
• 3. Weak in Mobile Computing
• Python is generally used in server-side programming. We don’t get to see Python on
the client-side or mobile applications because of the following reasons. Python
is not memory efficient and it has slow processing power as compared to other
• 4. Database Access
• Programming in Python is easy and stress-free. But when we are interacting with
the database, it lacks behind.
• The Python’s database access layer is primitive and underdeveloped in comparison
to the popular technologies like JDBC and ODBC.
• Huge enterprises need smooth interaction of complex legacy data and Python is
thus rarely used in enterprises.
• 5. Runtime Errors
• As we know Python is a dynamically typed language so the data type of a variable
can change anytime. A variable containing integer number may hold a string in the
future, which can lead to Runtime Errors.
• Therefore Python programmers need to perform thorough testing of the
applications.
Why do people use Python…?
The following primary factors cited by Python users
seem to be these:
Python is object-oriented
Structure supports such concepts as polymorphism, operation
overloading, and multiple inheritance.
Indentation
Indentation is one of the greatest future in Python.
It's free (open source)
Downloading and installing Python is free and easy
Source code is easily accessible
It's powerful
- Dynamic typing
- Built-in types and tools
- Library utilities
- Third party utilities (e.g. Numeric, NumPy, SciPy)
-Automatic memory management
It's portable
- Python runs virtually every major
platform used today
-As long as you have a compatible Python interpreter installed,
Python programs will run in exactly the same manner,
irrespective of platform.
It's mixable
-Python can be linked to components written in other
languages easily
- Linking tofast, compiled code is useful to
computationally intensive
• problems
- - Python/C integration is quite common
•It's easy to use
- No intermediate compile and link steps as in C/ C++
- Python programs are compiled automatically to an
intermediate form called bytecode, which the interpreter then reads
- This gives Python the development speed of an interpreter without
• the performance loss inherent in purely interpreted languages
•It's easy to learn
python programming unit 1 wala ppt .pptx
•The Server and
Client applications
are coded using
Python
•Machine Learning is used to
cluster users based on their
interest on shows and retain
them for longer
•Better search result
are provided based
on ranking of the
websites and much
more
•Transfer of files between peer-
to-peer which started out as a
normal python file
Bit-
Torrent
Google
Dropbox
NETFLIX
Where is python used in the Industry
• Scientific
calculations are
computed using
python
• Machine Learning and
Artificial Intelligence
• Cyber-Security
analysis and other
encryption and
decryption work
is done using
python
•Data visualizations from the
Matplotlib and Seaborn
galleries
National
Security
Agency
NASA
Where is python used in the Industry
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
Coding Styles in python
• There are four different coding styles offered by python. They are
 Functional
 Imperative
 Object-oriented
 Procedural
Functional coding
• In the functional type of coding, every statement is treated as a Mathematical equation
and mutuable. Most of the programmers prefer this type of coding for recursion and
lambda calculus.
Python Code:
my_list = [1, 5, 4, 6, 8, 11, 3, 12]
new_list = list(map(lambda x: x * 2 , my_list))
print(new_list)
Output:
[2, 10, 8, 12, 16, 22, 6, 24]
Imperative coding
• When there is a change in the program, computation occurs. Imperative style of
coding is adopted, if we have to manipulate the data structures.
Python Code:
sum = 0
for x in my_list:
sum += x
print(sum)
Output:
50
Object-oriented coding
• This type of coding relies on the data fields, which are treated as objects. These can be
manipulated only through prescribed methods. Python doesn’t support this paradigm
completely, due to some features like encapsulation cannot be implemented.
Python Code:
class word:
def test(self):
print("Python")
string = word()
string.test()
Output:
Python
Procedural coding
• It is used for iteration, sequencing, selection, and modularization.
Python Code:
def add(list):
sum = 0
for x in list:
sum += x
return sum
print(add(my_list))
Comments in Python
Keywords in Python
Difference between Interactive and Script
mode in Python
Interactive mode: Instructions are given in front of Python prompt
(eg., >>> ) in Python Shell. Python carries out the given instruction and
shows the result there itself.
Script mode: Python instructions are stored in a file generally with .py
extension and are executed together in one go as a unit. The saved
instructions are known as Python script or Python program.
Working with Python
• Default installation from www.python.org is called Cpython installation and
comes with Python interpreter, Python IDLE(Python GUI) and Pip(package
installer).
• Other Python distributions – Anaconda Python distribution that comes
preloaded with many packages and libraries(eg. Numpy,SciPy,Panda
libraries,etc.)
• Popular IDEs – Spyder IDE,PyCharm IDE etc.
• Spyder IDE is already available as a part of Anaconda Python Distribution.
Major Packages,libraries,frameworks
• Numpy (NUMeric Python) : matrices and linear algebra
• Scipy (SCIentific Python) : many numerical routines
• Pandas : data analysis and modeling library
• Pytest (Python TESTing) : a code testing framework
How to install Python on Windows
• There are two main ways of installing Python on Windows:
1. installation from the official Python website
2. Anaconda, a convenient distribution of Python.
 Choose the first option if you are a programmer using Python for various
purposes: creating websites, network programming, developing software
applications.
If instead, your work is focused on data science and machine learning, then
Anaconda is the best choice for you.
Check if Python is already
installed
• Before starting the installation process, we want to check if Python is already
installed on your computer (e.g., by a previous user), and if so, which version of
Python.
open the command line application Command Prompt - and type there
• python -V
If you found that Python is already installed on your computer and want to
check the path of the installation, run
• where.exe python
• in the command line application.
Install Python on Windows from the official Python website
• Step 1. Open the Python Releases for Windows page, select
Python version, and download Python executable installer.
Step 2:
Run the Python Installer for how to install python on windows downloads folder
Make sure to mark Add Python 3.10 to PATH otherwise you will have to do it
explicitly. It will start installing python on windows.
Step 3: Go to windows
and type IDLE
•This is Python Interpreter also
called Python Shell.
•I printed Hello Jasmine, python
is working smoothly.
•The three greater than >>> sign
is called Python command
prompt, where we write our
program and with a single enter
key, it will give result so
instantly.
Installing Anaconda on Windows
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
Variable and data type in Python
Variables
Variables are containers for storing data values.
Creating Variables
Python has no command for declaring a variable.
A variable is created the moment you first assign a
value to it.
x = 5
y = "John"
print(x)
print(y)
Variable Names
• A variable can have a short name (like x and
y) or a more descriptive name (age, carname,
total_volume).
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)
• A variable name cannot be any of the Python
keywords.
Multi Words Variable Names
• Variable names with more than one word
can be difficult to read.
• There are several techniques you can use
to make them more readable:
Camel Case
• Each word, except the first, starts with a
capital letter:
myVariableName = "John"
Pascal Case
• Each word starts with a capital letter:
MyVariableName = "John“
Snake Case
• Each word is separated by an underscore
character:
my_variable_name = "John"
Many Values to Multiple Variables
• Python allows you to assign values to
multiple variables in one line:
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
One Value to Multiple Variables
• And you can assign the same value to
multiple variables in one line:
• x = y = z = "Orange"
print(x)
print(y)
print(z)
Variable and data type in Python
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
List
Lists are used to store multiple items in a single variable.
A Python list contains items separated by commas and enclosed within square
brackets ([]).
Python lists are similar to arrays in C.
One difference between them is that all the items belonging to a Python list can
be of different data type where as C array can store elements related to a
particular data type.
The values stored in a Python list can be accessed using the slice operator ([ ]
and [:]) with indexes starting at 0 in the beginning of the list and working their
way to end -1.
The plus (+) sign is the list concatenation operator, and the asterisk (*) is the
repetition operator.
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
Tuple Data Type
• Python tuple is another sequence data type that is similar to a list.
• A Python tuple consists of a number of values separated by commas.
• Unlike lists, however, tuples are enclosed within parentheses.
• The main differences between lists and tuples are: Lists are enclosed in
brackets ( [ ] ) and their elements and size can be changed, while tuples are
enclosed in parentheses ( ( ) ) and cannot be updated.
• Tuples can be thought of as read-only lists.
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
Range()
python programming unit 1 wala ppt .pptx
Dictionary
• In Python, you can use the built-in dict data type to create and
manipulate dictionaries.
• Dictionaries are a type of collection that store key-value pairs, where
each key maps to a value.
• Dictionaries are also known as associative arrays or hashmaps in
other programming languages.
Creating a dictionary:
• You can create a dictionary using curly braces {} and separating key-
value pairs with colons :.
# Empty dictionary
empty_dict = {}
# Dictionary with initial key-value pairs
my_dict = {
"name": "John",
"age": 30,
"city": "New York"
}
# Adding new key-value pair
my_dict["occupation"] = "Engineer"
# Modifying an existing value
my_dict["age"] = 31
print(my_dict)
# Output: {'name': 'John', 'age': 31, 'city': 'New York', 'occupation': 'Engineer'}
SET
• In Python, a set is an unordered collection of unique elements. It is a
built-in data type that allows you to store and perform set operations
like union, intersection, difference, and more. Sets are denoted using
curly braces {} or by using the set() constructor.
• Here's a basic introduction to working with sets in Python:
• Creating a set:
• You can create a set by enclosing elements inside curly braces {}.
Example
set1 = set()
set2 = {'James', 2, 3,'Python'}
#Printing Set value
print(set2)
# Adding element to the set
set2.add(10)
print(set2)
#Removing element from the set
set2.remove(2)
print(set2)
python programming unit 1 wala ppt .pptx
Python divides the operators in the following
groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
For Loop
It has the ability to iterate over the items of any sequence, such as a list or
a string.
Syntax
for iterating_var in sequence:
statements(s)
If a sequence contains an expression list, it is evaluated first.
Then, the first item in the sequence is assigned to the iterating variable
iterating_var.
Next, the statements block is executed.
Each item in the list is assigned to iterating_var, and the statement(s) block
is executed until the entire sequence is exhausted.
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx

More Related Content

Similar to python programming unit 1 wala ppt .pptx (20)

PPTX
Python programming ppt.pptx
nagendrasai12
 
PPTX
PYTHON UNIT 1
nagendrasai12
 
PPTX
An Introduction To Python - Python, Print()
Blue Elephant Consulting
 
PDF
Python Course In Chandigarh
Excellence Academy
 
PPTX
Python
onlinetraining3
 
PPTX
Python programming
Megha V
 
PDF
python training in chandigarh
priyansuthakur59093
 
PPTX
Introduction-to-Python-Programming1.pptx
vijayalakshmi257551
 
PPTX
What is python
faizrashid1995
 
PPTX
introduction to data science programming.pptx
nazimsattar
 
DOCX
A Decision Tree based Recommendation System for Tourists.docx
spub1985
 
PPTX
Machine learning libraries with python
VishalBisht9217
 
PPTX
Introduction to python lecture (1)
Ali ٍSattar
 
PDF
From Basics to Advanced: A Comprehensive Python Programming Guide
pallavichauhan2525
 
PPTX
Python basics
ssuser4e32df
 
PDF
Introduction to Python
DrMohammed Qassim
 
PPTX
Python.pptx
abclara
 
PPTX
Ultimate Guide to Hire Dedicated Python Developers for Scalable Backend Solut...
Tuvoc Technologies
 
PPTX
Lecture on Fundamentals of Python Programming-1
JannatulFerdouse15
 
PDF
Migration of Applications to Python is the most prudent Decision
Mindfire LLC
 
Python programming ppt.pptx
nagendrasai12
 
PYTHON UNIT 1
nagendrasai12
 
An Introduction To Python - Python, Print()
Blue Elephant Consulting
 
Python Course In Chandigarh
Excellence Academy
 
Python programming
Megha V
 
python training in chandigarh
priyansuthakur59093
 
Introduction-to-Python-Programming1.pptx
vijayalakshmi257551
 
What is python
faizrashid1995
 
introduction to data science programming.pptx
nazimsattar
 
A Decision Tree based Recommendation System for Tourists.docx
spub1985
 
Machine learning libraries with python
VishalBisht9217
 
Introduction to python lecture (1)
Ali ٍSattar
 
From Basics to Advanced: A Comprehensive Python Programming Guide
pallavichauhan2525
 
Python basics
ssuser4e32df
 
Introduction to Python
DrMohammed Qassim
 
Python.pptx
abclara
 
Ultimate Guide to Hire Dedicated Python Developers for Scalable Backend Solut...
Tuvoc Technologies
 
Lecture on Fundamentals of Python Programming-1
JannatulFerdouse15
 
Migration of Applications to Python is the most prudent Decision
Mindfire LLC
 

Recently uploaded (20)

PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PDF
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PDF
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PPT
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
PPTX
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
PPTX
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
PPTX
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
PPTX
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
PPTX
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
PDF
Dimensions of Societal Planning in Commonism
StefanMz
 
PPTX
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
PPSX
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
PDF
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
PPTX
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
PDF
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
Isharyanti-2025-Cross Language Communication in Indonesian Language
Neny Isharyanti
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
The dynastic history of the Chahmana.pdf
PrachiSontakke5
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
Talk on Critical Theory, Part II, Philosophy of Social Sciences
Soraj Hongladarom
 
SPINA BIFIDA: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
How to Convert an Opportunity into a Quotation in Odoo 18 CRM
Celine George
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
BANDHA (BANDAGES) PPT.pptx ayurveda shalya tantra
rakhan78619
 
Stereochemistry-Optical Isomerism in organic compoundsptx
Tarannum Nadaf-Mansuri
 
Quarter1-English3-W4-Identifying Elements of the Story
FLORRACHELSANTOS
 
HYDROCEPHALUS: NURSING MANAGEMENT .pptx
PRADEEP ABOTHU
 
STAFF DEVELOPMENT AND WELFARE: MANAGEMENT
PRADEEP ABOTHU
 
Dimensions of Societal Planning in Commonism
StefanMz
 
THE TAME BIRD AND THE FREE BIRD.pptxxxxx
MarcChristianNicolas
 
Health Planning in india - Unit 03 - CHN 2 - GNM 3RD YEAR.ppsx
Priyanshu Anand
 
LAW OF CONTRACT ( 5 YEAR LLB & UNITARY LLB)- MODULE-3 - LEARN THROUGH PICTURE
APARNA T SHAIL KUMAR
 
ASRB NET 2023 PREVIOUS YEAR QUESTION PAPER GENETICS AND PLANT BREEDING BY SAT...
Krashi Coaching
 
DIGESTION OF CARBOHYDRATES,PROTEINS,LIPIDS
raviralanaresh2
 
Ad

python programming unit 1 wala ppt .pptx

  • 2. Course Objective  To learn about Python programming language syntax, semantics, and the runtime environment Course Outcomes After the successful completion of the course, the student will be able to: CO1: To design, implement and test readable, efficient programs that take advantage of Python built-in capabilities and follow Python best practices. CO2: To understand implementation differences and performance tradeoffs associated with various Python data structures. CO3: To manipulate and analyze large datasets and handle missing or inconsistent values. CO4: To identify the right data analytics structure to solve a problem.
  • 3. Unit 1: Introduction to Python Introduction to Python-coding styles in python-data types and variables- operators and expressions- numbers and relevant functions-if statement- while statement-for statement-break and continue. arrays - sequences-lists-stack-queues-functional programming- tuples-sequence unpacking- methods- dictionaries–sets- Fundamentals of OOPS in Python-Inheritance, Encapsulation, Polymorphism, Data abstraction. Unit 2: Functions in Python User-defined functions-anonymous functions-recursive functions- introduction to modules-creating and importing and modules-classes and objects-class methods- class properties-static method-constructor- method overriding-inheritance- operator overloading-introduction to pip- installing packages-using python packages. Unit 3: Basics of Numpy NumPy Basics: arrays and vectorized computation-introduction to pandas data structures-series-data frame-index objects- indexing, selection, and filtering- arithmetic and data alignment-applying functions and mapping-sorting and ranking- summarizing and computing descriptive statistics-correlation and covariance-handling missing data- hierarchical indexing. Unit 4: Working with Graphs Data Wrangling-combining and merging data sets- -data transformation-detecting and filtering outliers-string manipulation- vectorized string functions in pandas- plotting and visualization- matplotlib api primer- colors, markers, and line styles- ticks, labels, and legends- annotations and drawing on a subplot- saving plots to file- plotting functions in pandas.
  • 4. Unit 5: Real time Data Analysis Time Series- date and time data types and tools- converting between string and date time- time series basics- indexing, selection, sub setting- date ranges, frequencies, and shifting-generating date ranges- frequencies and date offsets-time zone handling- quarterly period frequencies- time series plotting-data munging – splicing together data sources- decile and quartile analysis-sample applications-future contract rolling- rolling correlation and linear regression- A Case study on predict the future rating of a restaurant based on an ML model. a) Reference Books 1. Michael H Goldwasser, David Letscher, “Object Oriented Programming in Python”, Prentice Hall, 1st Edition, 2007. 2. Yashavant Kanetkar, Aditya Kanetkar, “Let us Python, BPB publication, 1st Edition, 2019. 3. Ashok Kamthane, Amit Kamthane, “Programming and Problem solving with Python”, McGraw Hill Education (India) Private Limited, 2018. 4. Taneja Sheetal, Kumar Naveen, “Python Programming – A Modular Approach”, Pearson, 2017. 5. R Nageswara Rao, “Core Python Programming”, Dreamtech Press, 2017 Edition. 6. Peter Wentworth, Jeffrey Elkner, Allen B. Downey and Chris Meyers, “How to Think Like a Computer Scientist: Learning with Python 3”, 3rd Edition, 2015. 7. Paul Barry, “Head First Python a Brain Friendly Guide”, O’Reilly, 2 nd Edition, 2016. 8. Dainel Y.Chen “Pandas for Everyone Python Data Analysis” Pearson Education, 2019.
  • 5. Question paper Blue print Unit Hours Allotted in the Syllabus COs Addressed No. of Questions & Marks Distribution Section A Total Marks Section B Total Marks Section C Total Marks I 8 CO1 1 2 1 5 - 0 II 12 CO2 2 4 1 5 1 10 III 14 CO3 2 4 2 10 1 10 IV 12 CO4 1 2 1 5 1 10 V 14 CO4 2 4 2 10 2 20 Bloom’s Taxonomy Level(s) Used Remembering, Understanding Levels Applying, Analyzing Evaluating and Creating Levels Applying, Analyzing, Evaluating and Creating Levels
  • 6. Python Practical Content 1. Write a python program to open a file and check what are the access permissions acquired by that file using os module. 2. Write a python program to find the linear regression. 3. Write a program to double a given number and add two numbers using lambda(). 4. Write a Python Program to Using a numpy module create an array and check the following: 1. Type of array 2. Shape of array 3. Type of elements in array. 5. Create a dictionary and apply the following methods 1) Print the dictionary items 2) access items 3) use get() 4)change values 5) use len() 6. Write a python code to read a csv file using pandas module and print the first and last five lines of a file. 7. Write a python code to set background color and pic and draw a circle using turtle module 8. Write a python program to create a package, sub -package, modules and create staff and student function to module. 9 Write a python program to plot a bar graph for the car data set. 10 Write a python program to create a login web page using pycharm.
  • 7. What is Python…? • Python is a popular high-level programming language used in various applications • Python is an easy language to learn because of its simple syntax • Python can be used for simple tasks such as plotting or for more complex tasks like machine learning • Python supports modules and packages, which encourages program modularity and code reuse. • Python is a general purpose programming language that is often applied in scripting roles. • So, Python is programming language as well as scripting language. • Python is also called as Interpreted language
  • 8. The biggest strength of Python is huge collection of standard library which can be used for the following:  Machine Learning  GUI Applications (like Kivy, Tkinter, PyQt etc. )  Web frameworks like Django (used by YouTube, Instagram, Dropbox)  Image processing (like OpenCV, Pillow)  Web scraping (like Scrapy, BeautifulSoup, Selenium)  Test frameworks  Multimedia  Scientific computing  Text processing and many more..
  • 9. What can Python do? • Python can be used on a server to create web applications. • Python can be used alongside software to create workflows. • Python can connect to database systems. It can also read and modify files. • Python can be used to handle big data and perform complex mathematics. • Python can be used for rapid prototyping, or for production-ready software development.
  • 10. History Invented in the Netherlands, early 90s by Guido van Rossum Python was conceived in the late 1980s and its implementation was started in December 1989 Guido Van Rossum is fan of ‘Monty Python’s Flying Circus’, this is a famous TV show in Netherlands Named after Monty Python Open sourced from the beginning
  • 11. Guido van Rossum “Python is an experiment in how much freedom program-mers need. Too much freedom and nobody can read another's code; too little and expressive-ness is endangered.”
  • 12. Why was python created? "My original motivation for creating Python was the perceived need for a higher level language in the Amoeba [Operating Systems] project. I realized that the development of system Moreover, doing these things in the Bourne administration utilities in C was taking too long. shell wouldn't work for a variety of reasons. ... So, there was a need for a language that would bridge the gap between C and the shell” - Guido Van Rossum
  • 13. Differences between program and scripting language • Program •a program is executed (i.e. the source is first compiled, and the result of that compilation is expected) •A "program" in general, is a sequence of instructions written so that a computer can perform certain task. • Scripting •a script is interpreted •A "script" is code written in a scripting language. A scripting language is nothing but a type of programming language in which we can write code to control another software application.
  • 14. Differences between program and scripting language Applications of Scripting Languages : 1. To automate certain tasks in a program 2. Extracting information from a data set 3. Less code intensive as compared to traditional programming languages Applications of Programming Languages : 1. They typically run inside a parent program like scripts 2. More compatible while integrating code with mathematical models 3. Languages like JAVA can be compiled and then used on any platform
  • 16. • Advantages of Python 1. Easy to Read, Learn and Write • Python is a high-level programming language that has English-like syntax. This makes it easier to read and understand the code. • Python is really easy to pick up and learn, that is why a lot of people recommend Python to beginners. You need less lines of code to perform the same task as compared to other major languages like C/C++ and Java. 2. Improved Productivity • Python is a very productive language. Due to the simplicity of Python, developers can focus on solving the problem. They don’t need to spend too much time in understanding the syntax or behavior of the programming language. You write less code and get more things done.
  • 17. • 3. Interpreted Language • Python is an interpreted language which means that Python directly executes the code line by line. In case of any error, it stops further execution and reports back the error which has occurred. • Python shows only one error even if the program has multiple errors. This makes debugging easier. • 4. Dynamically Typed • Python doesn’t know the type of variable until we run the code. It automatically assigns the data type during execution. The programmer doesn’t need to worry about declaring variables and their data types.
  • 18. 5. Free and Open-Source • Python comes under the OSI approved open-source license. This makes t free to use and distribute. You can download the source code, modify it and even distribute your version of Python. This is useful for organizations that want to modify some specific behavior and use their version for development. • 6. Vast Libraries Support • The standard library of Python is huge, you can find almost all the functions needed for your task. So, you don’t have to depend on external libraries. • But even if you do, a Python package manager (pip) makes things easier to import other great packages from the Python package index (PyPi). It consists of over 200,000 packages.
  • 19. • Disadvantages of Python • 1. Slow Speed • The line by line execution of code often leads to slow execution. The dynamic nature of Python is also responsible for the slow speed of Python because it has to do the extra work while executing code. So, Python is not used for purposes where speed is an important aspect of the project. • 2. Not Memory Efficient • To provide simplicity to the developer, Python has to do a little tradeoff. The Python programming language uses a large amount of memory. This can be a disadvantage while building applications when we prefer memory optimization. • 3. Weak in Mobile Computing • Python is generally used in server-side programming. We don’t get to see Python on the client-side or mobile applications because of the following reasons. Python is not memory efficient and it has slow processing power as compared to other
  • 20. • 4. Database Access • Programming in Python is easy and stress-free. But when we are interacting with the database, it lacks behind. • The Python’s database access layer is primitive and underdeveloped in comparison to the popular technologies like JDBC and ODBC. • Huge enterprises need smooth interaction of complex legacy data and Python is thus rarely used in enterprises. • 5. Runtime Errors • As we know Python is a dynamically typed language so the data type of a variable can change anytime. A variable containing integer number may hold a string in the future, which can lead to Runtime Errors. • Therefore Python programmers need to perform thorough testing of the applications.
  • 21. Why do people use Python…? The following primary factors cited by Python users seem to be these: Python is object-oriented Structure supports such concepts as polymorphism, operation overloading, and multiple inheritance. Indentation Indentation is one of the greatest future in Python. It's free (open source) Downloading and installing Python is free and easy Source code is easily accessible
  • 22. It's powerful - Dynamic typing - Built-in types and tools - Library utilities - Third party utilities (e.g. Numeric, NumPy, SciPy) -Automatic memory management It's portable - Python runs virtually every major platform used today -As long as you have a compatible Python interpreter installed, Python programs will run in exactly the same manner, irrespective of platform.
  • 23. It's mixable -Python can be linked to components written in other languages easily - Linking tofast, compiled code is useful to computationally intensive • problems - - Python/C integration is quite common •It's easy to use - No intermediate compile and link steps as in C/ C++ - Python programs are compiled automatically to an intermediate form called bytecode, which the interpreter then reads - This gives Python the development speed of an interpreter without • the performance loss inherent in purely interpreted languages •It's easy to learn
  • 25. •The Server and Client applications are coded using Python •Machine Learning is used to cluster users based on their interest on shows and retain them for longer •Better search result are provided based on ranking of the websites and much more •Transfer of files between peer- to-peer which started out as a normal python file Bit- Torrent Google Dropbox NETFLIX Where is python used in the Industry
  • 26. • Scientific calculations are computed using python • Machine Learning and Artificial Intelligence • Cyber-Security analysis and other encryption and decryption work is done using python •Data visualizations from the Matplotlib and Seaborn galleries National Security Agency NASA Where is python used in the Industry
  • 29. Coding Styles in python • There are four different coding styles offered by python. They are  Functional  Imperative  Object-oriented  Procedural Functional coding • In the functional type of coding, every statement is treated as a Mathematical equation and mutuable. Most of the programmers prefer this type of coding for recursion and lambda calculus. Python Code: my_list = [1, 5, 4, 6, 8, 11, 3, 12] new_list = list(map(lambda x: x * 2 , my_list)) print(new_list) Output: [2, 10, 8, 12, 16, 22, 6, 24]
  • 30. Imperative coding • When there is a change in the program, computation occurs. Imperative style of coding is adopted, if we have to manipulate the data structures. Python Code: sum = 0 for x in my_list: sum += x print(sum) Output: 50
  • 31. Object-oriented coding • This type of coding relies on the data fields, which are treated as objects. These can be manipulated only through prescribed methods. Python doesn’t support this paradigm completely, due to some features like encapsulation cannot be implemented. Python Code: class word: def test(self): print("Python") string = word() string.test() Output: Python
  • 32. Procedural coding • It is used for iteration, sequencing, selection, and modularization. Python Code: def add(list): sum = 0 for x in list: sum += x return sum print(add(my_list))
  • 35. Difference between Interactive and Script mode in Python Interactive mode: Instructions are given in front of Python prompt (eg., >>> ) in Python Shell. Python carries out the given instruction and shows the result there itself. Script mode: Python instructions are stored in a file generally with .py extension and are executed together in one go as a unit. The saved instructions are known as Python script or Python program.
  • 36. Working with Python • Default installation from www.python.org is called Cpython installation and comes with Python interpreter, Python IDLE(Python GUI) and Pip(package installer). • Other Python distributions – Anaconda Python distribution that comes preloaded with many packages and libraries(eg. Numpy,SciPy,Panda libraries,etc.) • Popular IDEs – Spyder IDE,PyCharm IDE etc. • Spyder IDE is already available as a part of Anaconda Python Distribution.
  • 37. Major Packages,libraries,frameworks • Numpy (NUMeric Python) : matrices and linear algebra • Scipy (SCIentific Python) : many numerical routines • Pandas : data analysis and modeling library • Pytest (Python TESTing) : a code testing framework
  • 38. How to install Python on Windows • There are two main ways of installing Python on Windows: 1. installation from the official Python website 2. Anaconda, a convenient distribution of Python.  Choose the first option if you are a programmer using Python for various purposes: creating websites, network programming, developing software applications. If instead, your work is focused on data science and machine learning, then Anaconda is the best choice for you.
  • 39. Check if Python is already installed • Before starting the installation process, we want to check if Python is already installed on your computer (e.g., by a previous user), and if so, which version of Python. open the command line application Command Prompt - and type there • python -V If you found that Python is already installed on your computer and want to check the path of the installation, run • where.exe python • in the command line application.
  • 40. Install Python on Windows from the official Python website • Step 1. Open the Python Releases for Windows page, select Python version, and download Python executable installer.
  • 41. Step 2: Run the Python Installer for how to install python on windows downloads folder Make sure to mark Add Python 3.10 to PATH otherwise you will have to do it explicitly. It will start installing python on windows.
  • 42. Step 3: Go to windows and type IDLE •This is Python Interpreter also called Python Shell. •I printed Hello Jasmine, python is working smoothly. •The three greater than >>> sign is called Python command prompt, where we write our program and with a single enter key, it will give result so instantly.
  • 54. Variable and data type in Python
  • 55. Variables Variables are containers for storing data values. Creating Variables Python has no command for declaring a variable. A variable is created the moment you first assign a value to it. x = 5 y = "John" print(x) print(y)
  • 56. Variable Names • A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume). 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) • A variable name cannot be any of the Python keywords.
  • 57. Multi Words Variable Names • Variable names with more than one word can be difficult to read. • There are several techniques you can use to make them more readable: Camel Case • Each word, except the first, starts with a capital letter: myVariableName = "John"
  • 58. Pascal Case • Each word starts with a capital letter: MyVariableName = "John“ Snake Case • Each word is separated by an underscore character: my_variable_name = "John"
  • 59. Many Values to Multiple Variables • Python allows you to assign values to multiple variables in one line: x, y, z = "Orange", "Banana", "Cherry" print(x) print(y) print(z) One Value to Multiple Variables • And you can assign the same value to multiple variables in one line: • x = y = z = "Orange" print(x) print(y) print(z)
  • 60. Variable and data type in Python
  • 71. List Lists are used to store multiple items in a single variable. A Python list contains items separated by commas and enclosed within square brackets ([]). Python lists are similar to arrays in C. One difference between them is that all the items belonging to a Python list can be of different data type where as C array can store elements related to a particular data type. The values stored in a Python list can be accessed using the slice operator ([ ] and [:]) with indexes starting at 0 in the beginning of the list and working their way to end -1. The plus (+) sign is the list concatenation operator, and the asterisk (*) is the repetition operator.
  • 75. Tuple Data Type • Python tuple is another sequence data type that is similar to a list. • A Python tuple consists of a number of values separated by commas. • Unlike lists, however, tuples are enclosed within parentheses. • The main differences between lists and tuples are: Lists are enclosed in brackets ( [ ] ) and their elements and size can be changed, while tuples are enclosed in parentheses ( ( ) ) and cannot be updated. • Tuples can be thought of as read-only lists.
  • 82. Dictionary • In Python, you can use the built-in dict data type to create and manipulate dictionaries. • Dictionaries are a type of collection that store key-value pairs, where each key maps to a value. • Dictionaries are also known as associative arrays or hashmaps in other programming languages. Creating a dictionary: • You can create a dictionary using curly braces {} and separating key- value pairs with colons :.
  • 83. # Empty dictionary empty_dict = {} # Dictionary with initial key-value pairs my_dict = { "name": "John", "age": 30, "city": "New York" }
  • 84. # Adding new key-value pair my_dict["occupation"] = "Engineer" # Modifying an existing value my_dict["age"] = 31 print(my_dict) # Output: {'name': 'John', 'age': 31, 'city': 'New York', 'occupation': 'Engineer'}
  • 85. SET • In Python, a set is an unordered collection of unique elements. It is a built-in data type that allows you to store and perform set operations like union, intersection, difference, and more. Sets are denoted using curly braces {} or by using the set() constructor. • Here's a basic introduction to working with sets in Python: • Creating a set: • You can create a set by enclosing elements inside curly braces {}.
  • 86. Example set1 = set() set2 = {'James', 2, 3,'Python'} #Printing Set value print(set2) # Adding element to the set set2.add(10) print(set2) #Removing element from the set set2.remove(2) print(set2)
  • 88. Python divides the operators in the following groups: • Arithmetic operators • Assignment operators • Comparison operators • Logical operators • Identity operators • Membership operators • Bitwise operators
  • 102. For Loop It has the ability to iterate over the items of any sequence, such as a list or a string. Syntax for iterating_var in sequence: statements(s) If a sequence contains an expression list, it is evaluated first. Then, the first item in the sequence is assigned to the iterating variable iterating_var. Next, the statements block is executed. Each item in the list is assigned to iterating_var, and the statement(s) block is executed until the entire sequence is exhausted.