SlideShare a Scribd company logo
Programming
using python
BA Sem II
2023-24
Sukhpal
Guest Faculty, DTU
Syllabus
Unit 1:
Introduction to
Python
programming
Unit 2: Inbuilt data
structures (strings,
lists, tuples and
dictionary)
Unit 3: Working
with Python
libraries and writing
functions
Syllabus
 Unit 1: Introduction to Python programming
 Interactive mode and script mode, structure of a program, script execution, debugging-
errors, comments and error messages.
 Identifiers, keywords, constants, variables, data types and assignments.
 Arithmetic operators and expressions, relational operators, conditions and logical operators,
operator precedence.
 Input and output statements, control structures: if-else, loops, break and continue statements.
 Introduction to in-built functions: invoking functions.
 Handling missing data values: isnull, notnull.
Syllabus
 Unit 2: Python data structures (strings, lists, tuples and dictionary)
 Strings: initialize strings, subscript operator, access elements, string operations, built-in
string functions and methods, slicing a string, escape sequences.
 Lists: concepts of mutable lists, list operations: create, initialize, access, traverse,
append/insert new elements, search, sort, replace, removing elements; inbuilt list
functions and methods, list comprehensions.
 Tuples: concepts of immutable tuples, tuple operations: create, initialize, access
elements; tuple assignment, slicing, and indexing.
 Dictionary: concept of key-value pair, literals, operations: create, initialize, access,
traverse, append, add and remove keys, dictionary functions and methods.
Syllabus
 Unit 3: Working with Python libraries and writing functions
 Introduction to python libraries: NumPy, Pandas, Matplotlib, importing libraries.
 Data visualization using Matplotlib library, plotting graphs: line plot, bar chart,
scatter plot.
 NumPy and Pandas datatypes, basic operations: create, access, slice, add and
remove, reshape, indexing.
 Introduction to user-defined functions: parameters, scope of variables, passing
parameters, void functions, functions returning values, invoking functions, lambda
function, passing list, tuple, dictionary as a function parameters.
Reference material (Books)
1. Mckinney, W. (2017). Python for Data Analysis. Second edition,
O’reilly (SPD)
2. VanderPlas, J. (2016). Python Data Science Handbook: Essential Tools
for Working with Data. Second edition, O’reilly (SPD).
3. Guttag, J. V. (2013). Introduction to computation and programming
using Python. MIT Press.
4. Liang, Y. D. (2013). Introduction to Programming using Python.
Pearson.
5. T. Budd, Exploring Python, TMH, 1st Ed, 2011
6. Urban, M. & Murach, J. (2018). Python Programming. Shroff
Reference material (Tutorials)
 Python Tutorial by Python Developers
https://docs.python.org/3/tutorial/index.html
 Python Tutorial by Tutorial Point
https://www.tutorialspoint.com/python/index.htm
 Introduction to Python by W3Schools
https://www.w3schools.com/python/python_intro.asp
 Python Practice Challenge by Hacker-rank
https://www.hackerrank.com/domains/python
Introduction to Programming
 Language
 Programming Language
 Python Programming
 Bits, Bytes, MB, GB, TB, PB, EB, ZB, YB
 Number System-Binary, OD, D, HD
Programming Language (PL)
 To communicate with a person, we need a specific language (to share ideas, opinions with each other), similarly,
to communicate with computers, programmers also need a language is called Programming language.
 It is a set of instructions written in any specific language ( C, C++, Java, Python) to perform a specific task.
Types of programming languages
 Low-Level PLs– machine code in 0s and 1s
 Machine Language – machine code in binary or hexadecimal
 Assembly Language - symbolic and human-understandable form, uses assembler to convert from assembly
language to machine language
 High-Level PLs-requires a compiler or interpreter to translate the program into machine language
 Procedural Oriented PLs – structure program to solve a specific task (e.g. C, Pascal, ALGOL, COBOL,
BASIC)
 Object Oriented PLs - programs are divided into small parts called objects (e.g. C++, Java, Python, C#)
Registers
 Register in computer: Fastest type of memory, located within the CPU, used for storing
temporary data and CPU instructions.
 The size of a register maybe 8, 16, 32, or 64 bits. In 32-bit CPU, each register is 32 bits wide
and it can manipulate 32 bits of data at a time. The modern PCs have 32-bit or 64-bit registers
and are referred to as 32-bit processors and 64-bit processors.
Computer Memory
 Computer Memory is the hardware part of the system which stores data, information, and
instructions.
 Tabular Representation of
Various Memory Sizes
Name Equal To
Bit 1 Bit
Nibble 4 Bits
Byte 8 Bits
Kilobyte 1024 Bytes
Megabyte 1, 024 Kilobytes
Gigabyte 1, 024 Megabytes
Terrabyte 1, 024 Gigabytes
Petabyte 1, 024 Terabytes
Exabyte 1, 024 Petabytes
Zettabyte 1, 024 Exabytes
Yottabyte 1, 024 Zettabytes
Number System
 The number system is a structured way of
representing numbers.
 Different types of number systems
 Decimal (Base 10 – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)
 Binary (Base 2 – 0, 1)
 Octal (Base 8 – 0, 1, 2, 3, 4, 5, 6, 7)
 Hexadecimal (Base 16 –
0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F; where
A=10, B=11, ..., F=15)
Conversion Between Number Systems
1. Decimal to Binary:
i. Divide the decimal number by 2.
ii. Record the remainder (either 0 or 1).
iii. Repeat until the quotient is 0.
iv. The binary equivalent is the sequence of
remainders read from bottom to top.
2. Binary to Hexadecimal:
i. Group the binary digits into sets of four,
starting from the right.
ii. Convert each group to its hexadecimal
equivalent.
3. Decimal to Hexadecimal:
i. Convert the decimal number to binary.
ii. Convert the binary number to
hexadecimal.
What is Python?
Python is a high-level, interpreted
programming language known for its
simplicity and readability. It's versatile and can
be used for various applications such as web
development, data analysis, machine learning,
scientific computing, and more.
History of Python
Origin: Python was created by Guido van Rossum during 1985-1990
and first released in 1991.
Philosophy: Python's design philosophy emphasizes code readability,
and its syntax allows programmers to express concepts in fewer lines
of code than languages like C++ or Java.
Versions: Over the years, several versions of Python have been
released. The two main versions in use today are Python 2 in 2000 and
Python 3 in 2008, with Python 3 being the most recent and
recommended version. We will be using 3.12.1
Why Learn Python?
Versatility: Python can be used for various purposes, from web
development to data analysis and machine learning.
Readability: Python's syntax is designed to be clear and concise,
making it easier for beginners to understand and write code.
Community Support: Python has a large and active community, which
means plenty of resources, libraries, and frameworks are available.
Career Opportunities: Python skills are in high demand in the tech
industry, offering numerous job opportunities and competitive salaries.
Features of Python
Interpreted Language: Python code is executed line by line, making it
easier to debug and test.
Object-Oriented: Python supports object-oriented programming, allowing
for the creation of reusable and organized code.
Dynamic Typing: Variables in Python are dynamically typed, meaning
you don't need to declare a variable's type explicitly.
Rich Standard Library: Python comes with a comprehensive standard
library that provides modules and functions for various tasks, reducing
the need for external libraries.
Python vs Other Languages
Comparison with C/C++: Python offers higher-level
abstractions and a more concise syntax compared to
languages like C/C++, making it easier to write and
maintain code.
Comparison with Java: While Java is also a versatile
language, Python's simplicity and readability give it an
edge for rapid development and prototyping.
Setting Up Python Environment
Installation
IDEs (Integrated Development
Environments)
Editors
Command Prompt
Installation
Installation
Installation
Installation
Installation
Tick √
Installation
Installation
Installation
Running Python
 Press Window button and search “IDLE”
Python Basic Programs
Python Basic Programs
Python Basic Programs
Python Basic Programs
INTERPRETER Editor
Python Basic Programs
Python Basic Programs
Python Basic Programs
Python at command prompt
 Open command prompt
Python at command prompt
Ctrl + z
IDEs
An integrated development
environment (IDE) is a software
application that helps
programmers develop software
code efficiently.
How to install Spyder and Jupyter Notebook
 Install anaconda for installing these together
How to run Spyder
 Search Spyder in window and run it
INTERACTIVE
INTERPRETER
Editor
How to run Jupyter Notebook
 Search Jupyter Notebook in window and run it
How to run Jupyter Notebook
Python Syntax
INDENTATION COMMENTS
A block of code
must have a
consistent number
of spaces
Variables or Naming
Conventions
 A Python identifier is a name used to
identify a variable, function, class, module
or other object. An identifier starts with a
letter A to Z or a to z or an underscore (_)
followed by zero or more letters,
underscores and digits (0 to 9).
 Python does not allow punctuation
characters such as @, $, and % within
identifiers.
 Python is case sensitive.
Reserved Keywords
and as assert
break class continue
def del elif
else except False
finally for from
global if import
in is lambda
None nonlocal not
or pass raise
return True try
while with yield
Python Data Types
Operators
• Arithmetic
• Comparison
• Assignment
• Logical
• Bitwise
Basic Data Types
• Integers
• Floats
• Complex
• Booleans
• Strings
Arithmetic
Operators
 + for addition
 - for subtraction
 * for multiplication
 / for division
 // for floor division
 % for remainder
 ** for exponentiation
Comparison
Operators
 == for equality check
 != for not equal
 > for greater than
 < for less than
 >= for greater than or equal to
 <= for less than or equal to
Assignment
Operators
 = for assigning right value into left variable
 A @= B
Let @ be the operation of A and B then A = A @ B and
@ {+, -, *, /, //, %, **, &, ^, |}
Logical
Operators
 Compare True and False Boolean values
 and if both are True will give True otherwise False
 or if both are False will give False otherwise True
 not (unitary operator – used with a single variable) if
given value if False returns True otherwise returns False
Logical
Operators
 Bitwise AND: &
 Bitwise OR: |
 Bitwise XOR (Exclusive OR): ^
 Bitwise NOT (1s complement): ~
 Left Shift: <<
 Right Shift: >>
Data Types
 int
 float
 complex
 bool
 str
Ad

More Related Content

Similar to Lacture 1- Programming using python.pptx (20)

20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
abinayas958164
 
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
abinayas958164
 
Python basic
Python basicPython basic
Python basic
radhikaadroja
 
Python-Mastering-the-Language-of-Data-Science.pptx
Python-Mastering-the-Language-of-Data-Science.pptxPython-Mastering-the-Language-of-Data-Science.pptx
Python-Mastering-the-Language-of-Data-Science.pptx
dmdHaneef
 
Intro to python
Intro to pythonIntro to python
Intro to python
Mohamed Essam
 
It is about IDLE Python Installation version 3.1.2
It is about IDLE Python Installation version 3.1.2It is about IDLE Python Installation version 3.1.2
It is about IDLE Python Installation version 3.1.2
swarajyakmit15
 
MODULE 1.pptx
MODULE 1.pptxMODULE 1.pptx
MODULE 1.pptx
KPDDRAVIDIAN
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
Samir Mohanty
 
Python Programming
Python ProgrammingPython Programming
Python Programming
SheikAllavudeenN
 
Chapter - 1.pptx
Chapter - 1.pptxChapter - 1.pptx
Chapter - 1.pptx
MikialeTesfamariam
 
Intro-to-Python-Part-1-first-part-edition.pdf
Intro-to-Python-Part-1-first-part-edition.pdfIntro-to-Python-Part-1-first-part-edition.pdf
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
ilovepdf_merged pdfggjhfgyutertyuiuytrsj
ilovepdf_merged pdfggjhfgyutertyuiuytrsjilovepdf_merged pdfggjhfgyutertyuiuytrsj
ilovepdf_merged pdfggjhfgyutertyuiuytrsj
gautamkumar88905
 
Python basics
Python basicsPython basics
Python basics
ssuser4e32df
 
Python_Interview_Questions.pdf
Python_Interview_Questions.pdfPython_Interview_Questions.pdf
Python_Interview_Questions.pdf
Samir P.
 
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptxpython programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
AnaIyer1
 
01 python introduction
01 python introduction 01 python introduction
01 python introduction
Tamer Ahmed Farrag, PhD
 
Python programming
Python programmingPython programming
Python programming
Prof. Dr. K. Adisesha
 
Introduction-to-Python.pptx grade 9 ICT.
Introduction-to-Python.pptx grade 9 ICT.Introduction-to-Python.pptx grade 9 ICT.
Introduction-to-Python.pptx grade 9 ICT.
NeilIvanCasas1
 
Python Programming
Python ProgrammingPython Programming
Python Programming
shahid sultan
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
Raveendra R
 
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
abinayas958164
 
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
abinayas958164
 
Python-Mastering-the-Language-of-Data-Science.pptx
Python-Mastering-the-Language-of-Data-Science.pptxPython-Mastering-the-Language-of-Data-Science.pptx
Python-Mastering-the-Language-of-Data-Science.pptx
dmdHaneef
 
It is about IDLE Python Installation version 3.1.2
It is about IDLE Python Installation version 3.1.2It is about IDLE Python Installation version 3.1.2
It is about IDLE Python Installation version 3.1.2
swarajyakmit15
 
Overview of python 2019
Overview of python 2019Overview of python 2019
Overview of python 2019
Samir Mohanty
 
Intro-to-Python-Part-1-first-part-edition.pdf
Intro-to-Python-Part-1-first-part-edition.pdfIntro-to-Python-Part-1-first-part-edition.pdf
Intro-to-Python-Part-1-first-part-edition.pdf
ssuser543728
 
ilovepdf_merged pdfggjhfgyutertyuiuytrsj
ilovepdf_merged pdfggjhfgyutertyuiuytrsjilovepdf_merged pdfggjhfgyutertyuiuytrsj
ilovepdf_merged pdfggjhfgyutertyuiuytrsj
gautamkumar88905
 
Python_Interview_Questions.pdf
Python_Interview_Questions.pdfPython_Interview_Questions.pdf
Python_Interview_Questions.pdf
Samir P.
 
python programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptxpython programming unit 1 wala ppt .pptx
python programming unit 1 wala ppt .pptx
AnaIyer1
 
Introduction-to-Python.pptx grade 9 ICT.
Introduction-to-Python.pptx grade 9 ICT.Introduction-to-Python.pptx grade 9 ICT.
Introduction-to-Python.pptx grade 9 ICT.
NeilIvanCasas1
 
Introduction to Python Basics Programming
Introduction to Python Basics ProgrammingIntroduction to Python Basics Programming
Introduction to Python Basics Programming
Raveendra R
 

Recently uploaded (20)

Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
Digilocker under workingProcess Flow.pptx
Digilocker  under workingProcess Flow.pptxDigilocker  under workingProcess Flow.pptx
Digilocker under workingProcess Flow.pptx
satnamsadguru491
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Ch3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendencyCh3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendency
ayeleasefa2
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
Data Science Courses in India iim skills
Data Science Courses in India iim skillsData Science Courses in India iim skills
Data Science Courses in India iim skills
dharnathakur29
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Principles of information security Chapter 5.ppt
Principles of information security Chapter 5.pptPrinciples of information security Chapter 5.ppt
Principles of information security Chapter 5.ppt
EstherBaguma
 
VKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptxVKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptx
Vinod Srivastava
 
Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...
Pixellion
 
VKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptxVKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptx
Vinod Srivastava
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
Ppt. Nikhil.pptxnshwuudgcudisisshvehsjks
Ppt. Nikhil.pptxnshwuudgcudisisshvehsjksPpt. Nikhil.pptxnshwuudgcudisisshvehsjks
Ppt. Nikhil.pptxnshwuudgcudisisshvehsjks
panchariyasahil
 
183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag
fardin123rahman07
 
Deloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit contextDeloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit context
Process mining Evangelist
 
chapter3 Central Tendency statistics.ppt
chapter3 Central Tendency statistics.pptchapter3 Central Tendency statistics.ppt
chapter3 Central Tendency statistics.ppt
justinebandajbn
 
chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
Stack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptxStack_and_Queue_Presentation_Final (1).pptx
Stack_and_Queue_Presentation_Final (1).pptx
binduraniha86
 
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnTemplate_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
Template_A3nnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnnn
cegiver630
 
Data Analytics Overview and its applications
Data Analytics Overview and its applicationsData Analytics Overview and its applications
Data Analytics Overview and its applications
JanmejayaMishra7
 
Digilocker under workingProcess Flow.pptx
Digilocker  under workingProcess Flow.pptxDigilocker  under workingProcess Flow.pptx
Digilocker under workingProcess Flow.pptx
satnamsadguru491
 
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptxmd-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
md-presentHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHation.pptx
fatimalazaar2004
 
Ch3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendencyCh3MCT24.pptx measure of central tendency
Ch3MCT24.pptx measure of central tendency
ayeleasefa2
 
Calories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptxCalories_Prediction_using_Linear_Regression.pptx
Calories_Prediction_using_Linear_Regression.pptx
TijiLMAHESHWARI
 
Data Science Courses in India iim skills
Data Science Courses in India iim skillsData Science Courses in India iim skills
Data Science Courses in India iim skills
dharnathakur29
 
Simple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptxSimple_AI_Explanation_English somplr.pptx
Simple_AI_Explanation_English somplr.pptx
ssuser2aa19f
 
Principles of information security Chapter 5.ppt
Principles of information security Chapter 5.pptPrinciples of information security Chapter 5.ppt
Principles of information security Chapter 5.ppt
EstherBaguma
 
VKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptxVKS-Python Basics for Beginners and advance.pptx
VKS-Python Basics for Beginners and advance.pptx
Vinod Srivastava
 
Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...Thingyan is now a global treasure! See how people around the world are search...
Thingyan is now a global treasure! See how people around the world are search...
Pixellion
 
VKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptxVKS-Python-FIe Handling text CSV Binary.pptx
VKS-Python-FIe Handling text CSV Binary.pptx
Vinod Srivastava
 
Conic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptxConic Sectionfaggavahabaayhahahahahs.pptx
Conic Sectionfaggavahabaayhahahahahs.pptx
taiwanesechetan
 
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptxPerencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
Perencanaan Pengendalian-Proyek-Konstruksi-MS-PROJECT.pptx
PareaRusan
 
Ppt. Nikhil.pptxnshwuudgcudisisshvehsjks
Ppt. Nikhil.pptxnshwuudgcudisisshvehsjksPpt. Nikhil.pptxnshwuudgcudisisshvehsjks
Ppt. Nikhil.pptxnshwuudgcudisisshvehsjks
panchariyasahil
 
183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag183409-christina-rossetti.pdfdsfsdasggsag
183409-christina-rossetti.pdfdsfsdasggsag
fardin123rahman07
 
Deloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit contextDeloitte Analytics - Applying Process Mining in an audit context
Deloitte Analytics - Applying Process Mining in an audit context
Process mining Evangelist
 
chapter3 Central Tendency statistics.ppt
chapter3 Central Tendency statistics.pptchapter3 Central Tendency statistics.ppt
chapter3 Central Tendency statistics.ppt
justinebandajbn
 
chapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptxchapter 4 Variability statistical research .pptx
chapter 4 Variability statistical research .pptx
justinebandajbn
 
Ad

Lacture 1- Programming using python.pptx

  • 1. Programming using python BA Sem II 2023-24 Sukhpal Guest Faculty, DTU
  • 2. Syllabus Unit 1: Introduction to Python programming Unit 2: Inbuilt data structures (strings, lists, tuples and dictionary) Unit 3: Working with Python libraries and writing functions
  • 3. Syllabus  Unit 1: Introduction to Python programming  Interactive mode and script mode, structure of a program, script execution, debugging- errors, comments and error messages.  Identifiers, keywords, constants, variables, data types and assignments.  Arithmetic operators and expressions, relational operators, conditions and logical operators, operator precedence.  Input and output statements, control structures: if-else, loops, break and continue statements.  Introduction to in-built functions: invoking functions.  Handling missing data values: isnull, notnull.
  • 4. Syllabus  Unit 2: Python data structures (strings, lists, tuples and dictionary)  Strings: initialize strings, subscript operator, access elements, string operations, built-in string functions and methods, slicing a string, escape sequences.  Lists: concepts of mutable lists, list operations: create, initialize, access, traverse, append/insert new elements, search, sort, replace, removing elements; inbuilt list functions and methods, list comprehensions.  Tuples: concepts of immutable tuples, tuple operations: create, initialize, access elements; tuple assignment, slicing, and indexing.  Dictionary: concept of key-value pair, literals, operations: create, initialize, access, traverse, append, add and remove keys, dictionary functions and methods.
  • 5. Syllabus  Unit 3: Working with Python libraries and writing functions  Introduction to python libraries: NumPy, Pandas, Matplotlib, importing libraries.  Data visualization using Matplotlib library, plotting graphs: line plot, bar chart, scatter plot.  NumPy and Pandas datatypes, basic operations: create, access, slice, add and remove, reshape, indexing.  Introduction to user-defined functions: parameters, scope of variables, passing parameters, void functions, functions returning values, invoking functions, lambda function, passing list, tuple, dictionary as a function parameters.
  • 6. Reference material (Books) 1. Mckinney, W. (2017). Python for Data Analysis. Second edition, O’reilly (SPD) 2. VanderPlas, J. (2016). Python Data Science Handbook: Essential Tools for Working with Data. Second edition, O’reilly (SPD). 3. Guttag, J. V. (2013). Introduction to computation and programming using Python. MIT Press. 4. Liang, Y. D. (2013). Introduction to Programming using Python. Pearson. 5. T. Budd, Exploring Python, TMH, 1st Ed, 2011 6. Urban, M. & Murach, J. (2018). Python Programming. Shroff
  • 7. Reference material (Tutorials)  Python Tutorial by Python Developers https://docs.python.org/3/tutorial/index.html  Python Tutorial by Tutorial Point https://www.tutorialspoint.com/python/index.htm  Introduction to Python by W3Schools https://www.w3schools.com/python/python_intro.asp  Python Practice Challenge by Hacker-rank https://www.hackerrank.com/domains/python
  • 8. Introduction to Programming  Language  Programming Language  Python Programming  Bits, Bytes, MB, GB, TB, PB, EB, ZB, YB  Number System-Binary, OD, D, HD
  • 9. Programming Language (PL)  To communicate with a person, we need a specific language (to share ideas, opinions with each other), similarly, to communicate with computers, programmers also need a language is called Programming language.  It is a set of instructions written in any specific language ( C, C++, Java, Python) to perform a specific task. Types of programming languages  Low-Level PLs– machine code in 0s and 1s  Machine Language – machine code in binary or hexadecimal  Assembly Language - symbolic and human-understandable form, uses assembler to convert from assembly language to machine language  High-Level PLs-requires a compiler or interpreter to translate the program into machine language  Procedural Oriented PLs – structure program to solve a specific task (e.g. C, Pascal, ALGOL, COBOL, BASIC)  Object Oriented PLs - programs are divided into small parts called objects (e.g. C++, Java, Python, C#)
  • 10. Registers  Register in computer: Fastest type of memory, located within the CPU, used for storing temporary data and CPU instructions.  The size of a register maybe 8, 16, 32, or 64 bits. In 32-bit CPU, each register is 32 bits wide and it can manipulate 32 bits of data at a time. The modern PCs have 32-bit or 64-bit registers and are referred to as 32-bit processors and 64-bit processors.
  • 11. Computer Memory  Computer Memory is the hardware part of the system which stores data, information, and instructions.  Tabular Representation of Various Memory Sizes Name Equal To Bit 1 Bit Nibble 4 Bits Byte 8 Bits Kilobyte 1024 Bytes Megabyte 1, 024 Kilobytes Gigabyte 1, 024 Megabytes Terrabyte 1, 024 Gigabytes Petabyte 1, 024 Terabytes Exabyte 1, 024 Petabytes Zettabyte 1, 024 Exabytes Yottabyte 1, 024 Zettabytes
  • 12. Number System  The number system is a structured way of representing numbers.  Different types of number systems  Decimal (Base 10 – 0, 1, 2, 3, 4, 5, 6, 7, 8, 9)  Binary (Base 2 – 0, 1)  Octal (Base 8 – 0, 1, 2, 3, 4, 5, 6, 7)  Hexadecimal (Base 16 – 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F; where A=10, B=11, ..., F=15) Conversion Between Number Systems 1. Decimal to Binary: i. Divide the decimal number by 2. ii. Record the remainder (either 0 or 1). iii. Repeat until the quotient is 0. iv. The binary equivalent is the sequence of remainders read from bottom to top. 2. Binary to Hexadecimal: i. Group the binary digits into sets of four, starting from the right. ii. Convert each group to its hexadecimal equivalent. 3. Decimal to Hexadecimal: i. Convert the decimal number to binary. ii. Convert the binary number to hexadecimal.
  • 13. What is Python? Python is a high-level, interpreted programming language known for its simplicity and readability. It's versatile and can be used for various applications such as web development, data analysis, machine learning, scientific computing, and more.
  • 14. History of Python Origin: Python was created by Guido van Rossum during 1985-1990 and first released in 1991. Philosophy: Python's design philosophy emphasizes code readability, and its syntax allows programmers to express concepts in fewer lines of code than languages like C++ or Java. Versions: Over the years, several versions of Python have been released. The two main versions in use today are Python 2 in 2000 and Python 3 in 2008, with Python 3 being the most recent and recommended version. We will be using 3.12.1
  • 15. Why Learn Python? Versatility: Python can be used for various purposes, from web development to data analysis and machine learning. Readability: Python's syntax is designed to be clear and concise, making it easier for beginners to understand and write code. Community Support: Python has a large and active community, which means plenty of resources, libraries, and frameworks are available. Career Opportunities: Python skills are in high demand in the tech industry, offering numerous job opportunities and competitive salaries.
  • 16. Features of Python Interpreted Language: Python code is executed line by line, making it easier to debug and test. Object-Oriented: Python supports object-oriented programming, allowing for the creation of reusable and organized code. Dynamic Typing: Variables in Python are dynamically typed, meaning you don't need to declare a variable's type explicitly. Rich Standard Library: Python comes with a comprehensive standard library that provides modules and functions for various tasks, reducing the need for external libraries.
  • 17. Python vs Other Languages Comparison with C/C++: Python offers higher-level abstractions and a more concise syntax compared to languages like C/C++, making it easier to write and maintain code. Comparison with Java: While Java is also a versatile language, Python's simplicity and readability give it an edge for rapid development and prototyping.
  • 18. Setting Up Python Environment Installation IDEs (Integrated Development Environments) Editors Command Prompt
  • 27. Running Python  Press Window button and search “IDLE”
  • 35. Python at command prompt  Open command prompt
  • 36. Python at command prompt Ctrl + z
  • 37. IDEs An integrated development environment (IDE) is a software application that helps programmers develop software code efficiently.
  • 38. How to install Spyder and Jupyter Notebook  Install anaconda for installing these together
  • 39. How to run Spyder  Search Spyder in window and run it INTERACTIVE INTERPRETER Editor
  • 40. How to run Jupyter Notebook  Search Jupyter Notebook in window and run it
  • 41. How to run Jupyter Notebook
  • 42. Python Syntax INDENTATION COMMENTS A block of code must have a consistent number of spaces
  • 43. Variables or Naming Conventions  A Python identifier is a name used to identify a variable, function, class, module or other object. An identifier starts with a letter A to Z or a to z or an underscore (_) followed by zero or more letters, underscores and digits (0 to 9).  Python does not allow punctuation characters such as @, $, and % within identifiers.  Python is case sensitive.
  • 44. Reserved Keywords and as assert break class continue def del elif else except False finally for from global if import in is lambda None nonlocal not or pass raise return True try while with yield
  • 45. Python Data Types Operators • Arithmetic • Comparison • Assignment • Logical • Bitwise Basic Data Types • Integers • Floats • Complex • Booleans • Strings
  • 46. Arithmetic Operators  + for addition  - for subtraction  * for multiplication  / for division  // for floor division  % for remainder  ** for exponentiation
  • 47. Comparison Operators  == for equality check  != for not equal  > for greater than  < for less than  >= for greater than or equal to  <= for less than or equal to
  • 48. Assignment Operators  = for assigning right value into left variable  A @= B Let @ be the operation of A and B then A = A @ B and @ {+, -, *, /, //, %, **, &, ^, |}
  • 49. Logical Operators  Compare True and False Boolean values  and if both are True will give True otherwise False  or if both are False will give False otherwise True  not (unitary operator – used with a single variable) if given value if False returns True otherwise returns False
  • 50. Logical Operators  Bitwise AND: &  Bitwise OR: |  Bitwise XOR (Exclusive OR): ^  Bitwise NOT (1s complement): ~  Left Shift: <<  Right Shift: >>
  • 51. Data Types  int  float  complex  bool  str