SlideShare a Scribd company logo
PYTHON PROGRAMMING
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 V
an 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 VanRossum
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
Introduction  to  Python  Programming Basics
• 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 languages.
• 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 to fast, 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
Introduction  to  Python  Programming Basics
•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 Se
aborn galleries
National
Security
Agency
NASA
Where is python used in the Industry
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
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))
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
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
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
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
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.
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
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.
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Range()
Introduction  to  Python  Programming Basics
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)
Introduction  to  Python  Programming Basics
Python divides the operators in the following
groups:
• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators
•
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Comments in Python
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
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.
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics
Introduction  to  Python  Programming Basics

More Related Content

What's hot (20)

Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
Vanessa Rene
 
Python programming
Python  programmingPython  programming
Python programming
Ashwin Kumar Ramasamy
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
Edureka!
 
MACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULEMACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULE
DrBindhuM
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Agung Wahyudi
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
rfojdar
 
Single source Shortest path algorithm with example
Single source Shortest path algorithm with exampleSingle source Shortest path algorithm with example
Single source Shortest path algorithm with example
VINITACHAUHAN21
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With Python
Praveen M Jigajinni
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 
Numpy tutorial
Numpy tutorialNumpy tutorial
Numpy tutorial
HarikaReddy115
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
 
Covering algorithm
Covering algorithmCovering algorithm
Covering algorithm
Tilani Gunawardena PhD(UNIBAS), BSc(Pera), FHEA(UK), CEng, MIESL
 
PyTorch under the hood
PyTorch under the hoodPyTorch under the hood
PyTorch under the hood
Christian Perone
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
MansiSuthar3
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Fariz Darari
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
Tahani Al-Manie
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Maulik Borsaniya
 
Introduction python
Introduction pythonIntroduction python
Introduction python
Jumbo Techno e_Learning
 
Intro to Python Programming Language
Intro to Python Programming LanguageIntro to Python Programming Language
Intro to Python Programming Language
Dipankar Achinta
 
Introduction To Python
Introduction To PythonIntroduction To Python
Introduction To Python
Vanessa Rene
 
Introduction To Python | Edureka
Introduction To Python | EdurekaIntroduction To Python | Edureka
Introduction To Python | Edureka
Edureka!
 
MACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULEMACHINE LEARNING-LEARNING RULE
MACHINE LEARNING-LEARNING RULE
DrBindhuM
 
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Learn Python Programming | Python Programming - Step by Step | Python for Beg...
Edureka!
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Agung Wahyudi
 
Full Python in 20 slides
Full Python in 20 slidesFull Python in 20 slides
Full Python in 20 slides
rfojdar
 
Single source Shortest path algorithm with example
Single source Shortest path algorithm with exampleSingle source Shortest path algorithm with example
Single source Shortest path algorithm with example
VINITACHAUHAN21
 
11 Unit1 Chapter 1 Getting Started With Python
11   Unit1 Chapter 1 Getting Started With Python11   Unit1 Chapter 1 Getting Started With Python
11 Unit1 Chapter 1 Getting Started With Python
Praveen M Jigajinni
 
Introduction to Python
Introduction to PythonIntroduction to Python
Introduction to Python
Nowell Strite
 
Python in 30 minutes!
Python in 30 minutes!Python in 30 minutes!
Python in 30 minutes!
Fariz Darari
 
Introduction to Python programming Language
Introduction to Python programming LanguageIntroduction to Python programming Language
Introduction to Python programming Language
MansiSuthar3
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
Fariz Darari
 
Python 3 Programming Language
Python 3 Programming LanguagePython 3 Programming Language
Python 3 Programming Language
Tahani Al-Manie
 
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYAChapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Chapter 1 - INTRODUCTION TO PYTHON -MAULIK BORSANIYA
Maulik Borsaniya
 

Similar to Introduction to Python Programming Basics (20)

Python.pptx
Python.pptxPython.pptx
Python.pptx
abclara
 
PYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptxPYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptx
EzatIlman1
 
Research paper on python by Rj
Research paper on python by RjResearch paper on python by Rj
Research paper on python by Rj
Shree M.L.Kakadiya MCA mahila college, Amreli
 
Introduction to Python.pptx
Introduction to Python.pptxIntroduction to Python.pptx
Introduction to Python.pptx
SamyakJain461
 
Python programming ppt.pptx
Python programming ppt.pptxPython programming ppt.pptx
Python programming ppt.pptx
nagendrasai12
 
PYTHON UNIT 1
PYTHON UNIT 1PYTHON UNIT 1
PYTHON UNIT 1
nagendrasai12
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Nikhil Kapoor
 
Python Class 1
Python Class 1Python Class 1
Python Class 1
arijit banerjee
 
COMPUTER 8 Grade 8 - Intro to Python.pdf
COMPUTER 8 Grade 8 - Intro to Python.pdfCOMPUTER 8 Grade 8 - Intro to Python.pdf
COMPUTER 8 Grade 8 - Intro to Python.pdf
dennislelis29
 
Python notes for beginners - in simple sentences
Python notes for beginners - in simple sentencesPython notes for beginners - in simple sentences
Python notes for beginners - in simple sentences
RajyalakshmiUmmadise
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming Language
IRJET Journal
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
Manohar k
 
Python for students step by step guidance
Python for students step by step guidancePython for students step by step guidance
Python for students step by step guidance
MantoshKumar79
 
Python programming for beginners
Python programming for beginnersPython programming for beginners
Python programming for beginners
Benishchoco
 
1-ppt-python.ppt
1-ppt-python.ppt1-ppt-python.ppt
1-ppt-python.ppt
ssusera99a83
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
percivalfernandez2
 
Python Programming Part 1.pdf
Python Programming Part 1.pdfPython Programming Part 1.pdf
Python Programming Part 1.pdf
percivalfernandez2
 
POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE
teachersduniya.com
 
university notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptxuniversity notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptx
7ja1nyx
 
introduction to Python (for beginners)
introduction to Python (for beginners)introduction to Python (for beginners)
introduction to Python (for beginners)
guobichrng
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
abclara
 
PYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptxPYTHON TUTORIALS.pptx
PYTHON TUTORIALS.pptx
EzatIlman1
 
Introduction to Python.pptx
Introduction to Python.pptxIntroduction to Python.pptx
Introduction to Python.pptx
SamyakJain461
 
Python programming ppt.pptx
Python programming ppt.pptxPython programming ppt.pptx
Python programming ppt.pptx
nagendrasai12
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Nikhil Kapoor
 
COMPUTER 8 Grade 8 - Intro to Python.pdf
COMPUTER 8 Grade 8 - Intro to Python.pdfCOMPUTER 8 Grade 8 - Intro to Python.pdf
COMPUTER 8 Grade 8 - Intro to Python.pdf
dennislelis29
 
Python notes for beginners - in simple sentences
Python notes for beginners - in simple sentencesPython notes for beginners - in simple sentences
Python notes for beginners - in simple sentences
RajyalakshmiUmmadise
 
IRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming LanguageIRJET- Python: Simple though an Important Programming Language
IRJET- Python: Simple though an Important Programming Language
IRJET Journal
 
Python Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docxPython Programming and ApplicationsUnit-1.docx
Python Programming and ApplicationsUnit-1.docx
Manohar k
 
Python for students step by step guidance
Python for students step by step guidancePython for students step by step guidance
Python for students step by step guidance
MantoshKumar79
 
Python programming for beginners
Python programming for beginnersPython programming for beginners
Python programming for beginners
Benishchoco
 
POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE POWER OF PYTHON PROGRAMMING LANGUAGE
POWER OF PYTHON PROGRAMMING LANGUAGE
teachersduniya.com
 
university notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptxuniversity notes Lecture - 1 (Python) E-Notes.pptx
university notes Lecture - 1 (Python) E-Notes.pptx
7ja1nyx
 
introduction to Python (for beginners)
introduction to Python (for beginners)introduction to Python (for beginners)
introduction to Python (for beginners)
guobichrng
 
Ad

Recently uploaded (20)

Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
Gibson "Secrets to Changing Behaviour in Scholarly Communication: A 2025 NISO...
National Information Standards Organization (NISO)
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
EUPHORIA GENERAL QUIZ FINALS | QUIZ CLUB OF PSGCAS | 21 MARCH 2025
Quiz Club of PSG College of Arts & Science
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptxRai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Rai dyansty Chach or Brahamn dynasty, History of Dahir History of Sindh NEP.pptx
Dr. Ravi Shankar Arya Mahila P. G. College, Banaras Hindu University, Varanasi, India.
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptxDiptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Diptera: The Two-Winged Wonders, The Fly Squad: Order Diptera.pptx
Arshad Shaikh
 
What are the benefits that dance brings?
What are the benefits that dance brings?What are the benefits that dance brings?
What are the benefits that dance brings?
memi27
 
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
Module 4 Presentation - Enhancing Competencies and Engagement Strategies in Y...
GeorgeDiamandis11
 
How to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 SlidesHow to Create an Event in Odoo 18 - Odoo 18 Slides
How to Create an Event in Odoo 18 - Odoo 18 Slides
Celine George
 
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition IILDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDMMIA Free Reiki Yoga S9 Grad Level Intuition II
LDM & Mia eStudios
 
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17Different pricelists for different shops in odoo Point of Sale in Odoo 17
Different pricelists for different shops in odoo Point of Sale in Odoo 17
Celine George
 
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdfFEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
FEBA Sofia Univercity final diplian v3 GSDG 5.2025.pdf
ChristinaFortunova
 
Adam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational PsychologyAdam Grant: Transforming Work Culture Through Organizational Psychology
Adam Grant: Transforming Work Culture Through Organizational Psychology
Prachi Shah
 
Ray Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big CycleRay Dalio How Countries go Broke the Big Cycle
Ray Dalio How Countries go Broke the Big Cycle
Dadang Solihin
 
IDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptxIDF 30min presentation - December 2, 2024.pptx
IDF 30min presentation - December 2, 2024.pptx
ArneeAgligar
 
Exploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle SchoolExploring Ocean Floor Features for Middle School
Exploring Ocean Floor Features for Middle School
Marie
 
What is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptxWhat is FIle and explanation of text files.pptx
What is FIle and explanation of text files.pptx
Ramakrishna Reddy Bijjam
 
Hemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptxHemiptera & Neuroptera: Insect Diversity.pptx
Hemiptera & Neuroptera: Insect Diversity.pptx
Arshad Shaikh
 
Respiratory System , Urinary System
Respiratory  System , Urinary SystemRespiratory  System , Urinary System
Respiratory System , Urinary System
RushiMandali
 
Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.Artificial intelligence Presented by JM.
Artificial intelligence Presented by JM.
jmansha170
 
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition OecdEnergy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
Energy Balances Of Oecd Countries 2011 Iea Statistics 1st Edition Oecd
razelitouali
 
Nice Dream.pdf /
Nice Dream.pdf                              /Nice Dream.pdf                              /
Nice Dream.pdf /
ErinUsher3
 
Ad

Introduction to Python Programming Basics

  • 2. 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
  • 3. 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..
  • 4. 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.
  • 5. 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 V an 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
  • 6. 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.”
  • 7. 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 VanRossum
  • 8. 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.
  • 9. 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
  • 11. • 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.
  • 12. • 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.
  • 13. 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.
  • 14. • 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 languages.
  • 15. • 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.
  • 16. 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
  • 17. 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.
  • 18. It's mixable -Python can be linked to components written in other languages easily - Linking to fast, 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
  • 20. •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
  • 21. • 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 Se aborn galleries National Security Agency NASA Where is python used in the Industry
  • 24. 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]
  • 25. 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
  • 26. 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
  • 27. 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))
  • 29. 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.
  • 30. 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.
  • 31. 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
  • 32. 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.
  • 33. 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.
  • 34. 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.
  • 35. 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.
  • 36. 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.
  • 48. Variable and data type in Python
  • 49. 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)
  • 50. 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.
  • 51. 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"
  • 52. 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"
  • 53. 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)
  • 54. Variable and data type in Python
  • 65. 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.
  • 69. 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.
  • 76. 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 :.
  • 77. # Empty dictionary empty_dict = {} # Dictionary with initial key-value pairs my_dict = { "name": "John", "age": 30, "city": "New York" }
  • 78. # 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'}
  • 79. 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 {}.
  • 80. 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)
  • 82. Python divides the operators in the following groups: • Arithmetic operators • Assignment operators • Comparison operators • Logical operators • Identity operators • Membership operators • Bitwise operators •
  • 94. 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.