SlideShare a Scribd company logo
PYTHON
LANGUAGE
Dr. B. Subashini,
Assistant Professor of Computer Applications,
V.V.Vanniaperumal College for Women,
Virudhunagar
BRIEF HISTORY OF PYTHON
• Invented in the Netherlands, early 90s by
Guido van Rossum
• Named after Monty Python
• Open sourced from the beginning
• Considered a scripting language, but is much
more
• Scalable, object oriented and functional from
the beginning
• Used by Google from the beginning
• Increasingly popular
PYTHON
• 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.
WHY PYTHON?
• Python works on different platforms (Windows, Mac,
Linux, Raspberry Pi, etc).
• Python has a simple syntax similar to the English
language.
• Python has syntax that allows developers to write
programs with fewer lines than some other programming
languages.
• Python runs on an interpreter system, meaning that
code can be executed as soon as it is written. This
means that prototyping can be very quick.
• Python can be treated in a procedural way,
an object-oriented way or a functional way.
VERSION
• The most recent major version of Python is
Python 3
• 3.12.0 is the latest version of Python released on
October 2, 2023
• However, Python 2 being updated with security,
is still quite popular
PYTHON SYNTAX
• Python was designed for readability, and has some
similarities to the English language with influence
from mathematics.
• Python uses new lines to complete a command, as
opposed to other programming languages which
often use semicolons or parentheses.
• Python relies on indentation, using whitespace, to
define scope; such as the scope of loops, functions
and classes. Other programming languages often
use curly-brackets for this purpose.
COMMENTS
• Comments can be used to explain Python code.
• Comments can be used to make the code more
readable.
• Comments can be used to prevent execution when
testing code.
• Example:
• #This is a comment
print("Hello, World!")
VARIABLES
• Variables are containers for storing data values.
• Python has no command for declaring a variable.
• A variable is created the moment just first assign a value
to it.
• x = 5
y = "John"
print(x)
print(y)
VARIABLE NAMES
• 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.
BUILT IN DATA TYPES
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
None Type: NoneType
NUMPY
• Stands for Numerical Python
• Is the fundamental package required for high performance
computing and data analysis
• NumPy is so important for numerical computations in
Python is because it is designed for efficiency on large
arrays of data.
• It provides ndarray for creating multiple dimensional arrays.
• Internally stores data in a contiguous block of
memory, independent of other built-in
Python objects, use much less memory
than built-in Python sequences.
NUMPY NDARRAY VS LIST
• Standard math functions for fast operations on entire arrays of data
without having to write loops
• NumPy Arrays are important because they enable to express batch
operations on data without writing any for loops. We call this
vectorization.
• One of the key features of NumPy is its N-dimensional array object, or
ndarray, which is a fast, flexible container for large datasets in Python.
• Whenever you see “array,” “NumPy array,” or “ndarray” in the text, with
few exceptions they all refer to the same thing: the ndarray object.
• NumPy-based algorithms are generally 10 to
100 times faster (or more) than their pure Python
counterparts and use significantly less memory.
import numpy as np
my_arr = np.arange(1000000)
NDARRAY
• ndarray is used for storage of homogeneous data
• i.e., all elements the same type
• Every array must have a shape and a dtype
• Supports convenient slicing, indexing and efficient
vectorized computation
import numpy as np
data1 = [6, 7, 5, 8, 0, 1]
arr1 = np.array(data1)
print(arr1)
CREATING NDARRAYS
Using list of lists
import numpy as np
data2 = [[1, 2, 3, 4], [5, 6, 7, 8]] #list of lists
arr2 = np.array(data2)
print(arr2.ndim) #2
print(arr2.shape) # (2,4)
array = np.array([[0,1,2],[2,3,4]])
[[0 1 2]
[2 3 4]]
array = np.zeros((2,3))
[[0. 0. 0.]
[0. 0. 0.]]
array = np.ones((2,3))
[[1. 1. 1.]
[1. 1. 1.]]
array = np.arange(0, 10, 2)
[0, 2, 4, 6, 8]
array = np.eye(3)
[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]
array = np.random.randint(0,
10, (3,3))
[[6 4 3]
[1 5 6]
[9 8 5]]
CREATING NDARRAYS
ARITHMETIC WITH NUMPY
ARRAYS
• Any arithmetic operations between equal-size arrays
applies the operation element-wise:
arr = np.array([[1, 2, 3], [4, 5, 6]])
print(arr)
[[1 2 3]
[4 5 6]]
print(arr * arr)
[[ 1 4 9]
[16 25 36]]
print(arr - arr)
[[0 0 0]
[0 0 0]]
ARITHMETIC WITH NUMPY
ARRAYS
• Arithmetic operations with scalars propagate the scalar
argument to each element in the array:
arr = np.array([[1., 2., 3.], [4., 5., 6.]])
print(arr)
[[1. 2. 3.]
[4. 5. 6.]]
print(arr **2)
[[ 1. 4. 9.]
[16. 25. 36.]]
ARITHMETIC WITH NUMPY
ARRAYS
• Comparisons between arrays of the same size yield
boolean arrays:
arr = np.array([[1., 2., 3.], [4., 5., 6.]])
print(arr)
[[1. 2. 3.]
[4. 5. 6.]]
arr2 = np.array([[0., 4., 1.], [7., 2., 12.]])
print(arr2)
[[ 0. 4. 1.]
[ 7. 2. 12.]]
print(arr2 > arr)
[[False True False]
[ True False True]]
INDEXING AND SLICING
• One-dimensional arrays are simple; on the surface they act
similarly to Python lists:
arr = np.arange(10)
print(arr) # [0 1 2 3 4 5 6 7 8 9]
print(arr[5]) #5
print(arr[5:8]) #[5 6 7]
arr[5:8] = 12
print(arr) #[ 0 1 2 3 4 12 12 12 8 9]
INDEXING AND SLICING
• An important first distinction from Python’s built-in lists is
that array slices are views on the original array.
• This means that the data is not copied, and any modifications to
the view will be reflected in the source array.
arr = np.arange(10)
print(arr) # [0 1 2 3 4 5 6 7 8 9]
arr_slice = arr[5:8]
print(arr_slice) # [5 6 7]
arr_slice[1] = 12345
print(arr)
# [ 0 1 2 3 4 5 12345 7 8 9]
arr_slice[:] = 64
print(arr)
# [ 0 1 2 3 4 64 64 64 8 9]
INDEXING
• In a two-dimensional array, the elements at each index are
no longer scalars but rather one-dimensional arrays:
• Thus, individual elements can be accessed recursively.
But that is a bit too much work, so we can
pass a comma-separated list of indices
to select individual elements.
• So these are equivalent:
arr2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(arr2d[2]) # [7 8 9]
print(arr2d[0][2]) # 3
print(arr2d[0, 2]) #3

More Related Content

PPTX
Introduction to numpy.pptx
PPTX
Lecture 2 _Foundions foundions NumPyI.pptx
PDF
summer training report on python
PPTX
Array-single dimensional array concept .pptx
PPTX
Python Demo.pptx
PPTX
Python Demo.pptx
PPTX
Chapter 5-Numpy-Pandas.pptx python programming
PPTX
L-30-35huujjjhgjnnjhggbjkiuuhhjkiiijj.pptx
Introduction to numpy.pptx
Lecture 2 _Foundions foundions NumPyI.pptx
summer training report on python
Array-single dimensional array concept .pptx
Python Demo.pptx
Python Demo.pptx
Chapter 5-Numpy-Pandas.pptx python programming
L-30-35huujjjhgjnnjhggbjkiuuhhjkiiijj.pptx

Similar to Basic Introduction to Python Programming (20)

PDF
Migrating from matlab to python
PDF
Numpy.pdf
PPTX
scripting in Python
PPTX
numpy code and examples with attributes.pptx
PPTX
Python for ML.pptx
PPTX
Week 11.pptx
PPTX
Python For Data Science.pptx
PPT
CAP776Numpy (2).ppt
PPT
CAP776Numpy.ppt
PDF
Python: An introduction A summer workshop
PPTX
numpydocococ34554367827839271966666.pptx
PPT
2025pylab engineering 2025pylab engineering
PPTX
DATA ANALYSIS AND VISUALISATION using python
PDF
Python programming : Arrays
PPTX
ARRAY OPERATIONS.pptx
PPT
Python basics to advanced in on ppt is available
PPTX
Introduction to numpy Session 1
PDF
ppt_pspp.pdf
PDF
Python for scientific computing
PPTX
Migrating from matlab to python
Numpy.pdf
scripting in Python
numpy code and examples with attributes.pptx
Python for ML.pptx
Week 11.pptx
Python For Data Science.pptx
CAP776Numpy (2).ppt
CAP776Numpy.ppt
Python: An introduction A summer workshop
numpydocococ34554367827839271966666.pptx
2025pylab engineering 2025pylab engineering
DATA ANALYSIS AND VISUALISATION using python
Python programming : Arrays
ARRAY OPERATIONS.pptx
Python basics to advanced in on ppt is available
Introduction to numpy Session 1
ppt_pspp.pdf
Python for scientific computing
Ad

More from SubashiniRathinavel (11)

PPTX
PYTHON - OBJECT ORIENTED PROGRAMMING .pptx
PPTX
VB.NET Datatypes.pptx
PPTX
Presentation1.pptx
PPTX
Wireless lan security(10.8)
PPTX
Wireless LAN
PPTX
Android workshop
PPTX
Cryptography
PYTHON - OBJECT ORIENTED PROGRAMMING .pptx
VB.NET Datatypes.pptx
Presentation1.pptx
Wireless lan security(10.8)
Wireless LAN
Android workshop
Cryptography
Ad

Recently uploaded (20)

PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Lesson notes of climatology university.
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Cell Types and Its function , kingdom of life
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
01-Introduction-to-Information-Management.pdf
PDF
Classroom Observation Tools for Teachers
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Microbial disease of the cardiovascular and lymphatic systems
PPTX
master seminar digital applications in india
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PPTX
Presentation on HIE in infants and its manifestations
Final Presentation General Medicine 03-08-2024.pptx
Module 4: Burden of Disease Tutorial Slides S2 2025
Lesson notes of climatology university.
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Cell Types and Its function , kingdom of life
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Supply Chain Operations Speaking Notes -ICLT Program
O7-L3 Supply Chain Operations - ICLT Program
01-Introduction-to-Information-Management.pdf
Classroom Observation Tools for Teachers
Abdominal Access Techniques with Prof. Dr. R K Mishra
Microbial disease of the cardiovascular and lymphatic systems
master seminar digital applications in india
O5-L3 Freight Transport Ops (International) V1.pdf
Complications of Minimal Access Surgery at WLH
102 student loan defaulters named and shamed – Is someone you know on the list?
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Presentation on HIE in infants and its manifestations

Basic Introduction to Python Programming

  • 1. PYTHON LANGUAGE Dr. B. Subashini, Assistant Professor of Computer Applications, V.V.Vanniaperumal College for Women, Virudhunagar
  • 2. BRIEF HISTORY OF PYTHON • Invented in the Netherlands, early 90s by Guido van Rossum • Named after Monty Python • Open sourced from the beginning • Considered a scripting language, but is much more • Scalable, object oriented and functional from the beginning • Used by Google from the beginning • Increasingly popular
  • 3. PYTHON • 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.
  • 4. WHY PYTHON? • Python works on different platforms (Windows, Mac, Linux, Raspberry Pi, etc). • Python has a simple syntax similar to the English language. • Python has syntax that allows developers to write programs with fewer lines than some other programming languages. • Python runs on an interpreter system, meaning that code can be executed as soon as it is written. This means that prototyping can be very quick. • Python can be treated in a procedural way, an object-oriented way or a functional way.
  • 5. VERSION • The most recent major version of Python is Python 3 • 3.12.0 is the latest version of Python released on October 2, 2023 • However, Python 2 being updated with security, is still quite popular
  • 6. PYTHON SYNTAX • Python was designed for readability, and has some similarities to the English language with influence from mathematics. • Python uses new lines to complete a command, as opposed to other programming languages which often use semicolons or parentheses. • Python relies on indentation, using whitespace, to define scope; such as the scope of loops, functions and classes. Other programming languages often use curly-brackets for this purpose.
  • 7. COMMENTS • Comments can be used to explain Python code. • Comments can be used to make the code more readable. • Comments can be used to prevent execution when testing code. • Example: • #This is a comment print("Hello, World!")
  • 8. VARIABLES • Variables are containers for storing data values. • Python has no command for declaring a variable. • A variable is created the moment just first assign a value to it. • x = 5 y = "John" print(x) print(y)
  • 9. VARIABLE NAMES • 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.
  • 10. BUILT IN DATA TYPES 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 None Type: NoneType
  • 11. NUMPY • Stands for Numerical Python • Is the fundamental package required for high performance computing and data analysis • NumPy is so important for numerical computations in Python is because it is designed for efficiency on large arrays of data. • It provides ndarray for creating multiple dimensional arrays. • Internally stores data in a contiguous block of memory, independent of other built-in Python objects, use much less memory than built-in Python sequences.
  • 12. NUMPY NDARRAY VS LIST • Standard math functions for fast operations on entire arrays of data without having to write loops • NumPy Arrays are important because they enable to express batch operations on data without writing any for loops. We call this vectorization. • One of the key features of NumPy is its N-dimensional array object, or ndarray, which is a fast, flexible container for large datasets in Python. • Whenever you see “array,” “NumPy array,” or “ndarray” in the text, with few exceptions they all refer to the same thing: the ndarray object. • NumPy-based algorithms are generally 10 to 100 times faster (or more) than their pure Python counterparts and use significantly less memory. import numpy as np my_arr = np.arange(1000000)
  • 13. NDARRAY • ndarray is used for storage of homogeneous data • i.e., all elements the same type • Every array must have a shape and a dtype • Supports convenient slicing, indexing and efficient vectorized computation import numpy as np data1 = [6, 7, 5, 8, 0, 1] arr1 = np.array(data1) print(arr1)
  • 14. CREATING NDARRAYS Using list of lists import numpy as np data2 = [[1, 2, 3, 4], [5, 6, 7, 8]] #list of lists arr2 = np.array(data2) print(arr2.ndim) #2 print(arr2.shape) # (2,4)
  • 15. array = np.array([[0,1,2],[2,3,4]]) [[0 1 2] [2 3 4]] array = np.zeros((2,3)) [[0. 0. 0.] [0. 0. 0.]] array = np.ones((2,3)) [[1. 1. 1.] [1. 1. 1.]] array = np.arange(0, 10, 2) [0, 2, 4, 6, 8] array = np.eye(3) [[1. 0. 0.] [0. 1. 0.] [0. 0. 1.]] array = np.random.randint(0, 10, (3,3)) [[6 4 3] [1 5 6] [9 8 5]] CREATING NDARRAYS
  • 16. ARITHMETIC WITH NUMPY ARRAYS • Any arithmetic operations between equal-size arrays applies the operation element-wise: arr = np.array([[1, 2, 3], [4, 5, 6]]) print(arr) [[1 2 3] [4 5 6]] print(arr * arr) [[ 1 4 9] [16 25 36]] print(arr - arr) [[0 0 0] [0 0 0]]
  • 17. ARITHMETIC WITH NUMPY ARRAYS • Arithmetic operations with scalars propagate the scalar argument to each element in the array: arr = np.array([[1., 2., 3.], [4., 5., 6.]]) print(arr) [[1. 2. 3.] [4. 5. 6.]] print(arr **2) [[ 1. 4. 9.] [16. 25. 36.]]
  • 18. ARITHMETIC WITH NUMPY ARRAYS • Comparisons between arrays of the same size yield boolean arrays: arr = np.array([[1., 2., 3.], [4., 5., 6.]]) print(arr) [[1. 2. 3.] [4. 5. 6.]] arr2 = np.array([[0., 4., 1.], [7., 2., 12.]]) print(arr2) [[ 0. 4. 1.] [ 7. 2. 12.]] print(arr2 > arr) [[False True False] [ True False True]]
  • 19. INDEXING AND SLICING • One-dimensional arrays are simple; on the surface they act similarly to Python lists: arr = np.arange(10) print(arr) # [0 1 2 3 4 5 6 7 8 9] print(arr[5]) #5 print(arr[5:8]) #[5 6 7] arr[5:8] = 12 print(arr) #[ 0 1 2 3 4 12 12 12 8 9]
  • 20. INDEXING AND SLICING • An important first distinction from Python’s built-in lists is that array slices are views on the original array. • This means that the data is not copied, and any modifications to the view will be reflected in the source array. arr = np.arange(10) print(arr) # [0 1 2 3 4 5 6 7 8 9] arr_slice = arr[5:8] print(arr_slice) # [5 6 7] arr_slice[1] = 12345 print(arr) # [ 0 1 2 3 4 5 12345 7 8 9] arr_slice[:] = 64 print(arr) # [ 0 1 2 3 4 64 64 64 8 9]
  • 21. INDEXING • In a two-dimensional array, the elements at each index are no longer scalars but rather one-dimensional arrays: • Thus, individual elements can be accessed recursively. But that is a bit too much work, so we can pass a comma-separated list of indices to select individual elements. • So these are equivalent: arr2d = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) print(arr2d[2]) # [7 8 9] print(arr2d[0][2]) # 3 print(arr2d[0, 2]) #3