Content 25.Python JSON
26.Python Exception Handling
1. Python introduction and features.
2. Python installation and software
installation
3. print() function and Python Escape
Characters
4. Python Comments
5. Python Variables and Type Casting
6. Python Keyword
7. Python Built-in Data Types
8. Python Operators
9. Python Simple Programs
10.input() function, Split,result printing-
with format() function
11.String in Python, String indexing
,String Concatenation,String
Slicing,String method
12.Python Boolean Values
13.Python Conditional Statement –if ,if-
else , el-if
14.Looping Statement in python –for,
while
15.User Define Function in Python
16.Python Lambda function
17.Python Collections, list
tuple,dictionary,set
18.Python map(),reduce(), filter(), zip(),
max(),min() functions
19. Python Object Oriented
20. Python Inheritance
21. Python Iterators
22. Python Try Except
23. Python Module
24.Python Datetime
,2
Python Language Top Python App Examples
Python is an interpreted high-level general- • Dropbox
purpose programming language.
Guido van Rossum began working on
Python in the late 1980s, as a successor to • Amazon
the ABC programming language, and first
released it in 1991 as Python 0.9.0 • Pinterest
Python 2.0 was released in 2000 and
• Uber
introduced new features.
Python 3.0 was released in 2008.It is most • Netflix
popular version.
• Spotify
Today python is world’s first popular
programming language. Because of it is Python Install
using in Data Science, Big Data and
https://www.python.org/downloads/
machine learning as programming language.
pycharm
Python Famous Module
https://www.jetbrains.com/pycharm/download/#sectio
Numpy (Data Analysis) n=windows
Pandas (Data Cleaning)
Sklearn (Machine Learning) vs code
Matplotlib (for plotting graph and chart) https://code.visualstudio.com/
Django (Web Development)
Flask (Web Development) python --version
Kivy (Mobile App ) # Python print() function
Tkinter – (Python GUI Application)
print(“Hello World”)
Famous Machine Learning Algorithm used
Run - python helloworld.py
in python
Linear Regression Python Escape Characters
Logistic Regression \' Single Quote
Decision Tree \\ Backslash
Support Vector Machine \n New Line
Naive Bayes \r Carriage Return
kNN (k-Nearest Neighbors) \t Tab
k-Means clustering \b Backspace
Random Forest
,3
\f Form Feed A variable name must start with a letter or the
underscore character
\ooo Octal value A variable name cannot start with a number
A variable name can only contain alpha-numeric
\xhh Hex value characters and underscores (A-z, 0-9, and _ )
Variable names are case-sensitive (age, Age and
#Python Comments AGE are three different variables)
#Comments starts with a #, and Python will ignore
#Many Values to Multiple Variables
them: x, y, z = "Orange", "Banana", "Cherry"
print(x)
#This is a comment print(y)
print("Hello, World!") print(z)
#Python Variables Unpack a Collection
Variables are containers for storing data values. fruits = ["apple", "banana", "cherry"]
Python has no command for declaring a x, y, z = fruits
variable. print(x)
A variable is created the moment you first print(y)
assign a value to it.
print(z)
x=5
y = "John"
print(x)
#Python Keyword
print(y)
Python has a set of keywords that are reserved words
Variables do not need to be declared with
that cannot be used as variable names, function names,
any particular type, and can even change
or any other identifiers:
type after they have been set.
#Casting Keyword Description
and A logical operator
If you want to specify the data type of a variable, as To create an alias
this can be done with casting. assert For debugging
break To break out of a loop
x = str(5) # x will be '5' class To define a class
y = int(5) # y will be 5 continueTo continue to the next iteration of a loop
z = float(5) # z will be 5.0 def To define a function
del To delete an object
#Get the Type elif Used in conditional statements, same as else if
else Used in conditional statements
You can get the data type of a variable with the type() except Used with exceptions, what to do when an exception
function. occurs
False Boolean value, result of comparison operations
x = 5 finally Used with exceptions, a block of code that will be
y = "John" executed no matter if there is an exception or not
print(type(x)) for To create a for loop
print(type(y))op-<class 'int'><class 'str'> from To import specific parts of a module
global To declare a global variable
if To make a conditional statement
Variable Names
import To import a module
in To check if a value is present in a list, tuple, etc.
A variable can have a short name (like x and y) or a is To test if two variables are equal
more descriptive name (age, carname, total_volume). lambda To create an anonymous function
Rules for Python variables: None Represents a null value
, 4
nonlocal To declare a non-local variable * Multiplication x * y
not A logical operator / Division x/y
or A logical operator % Modulus x%y
pass A null statement, a statement that will do nothing ** Exponentiation x ** y
raise To raise an exception
// Floor division x // y
return To exit a function and return a value
True Boolean value, result of comparison operations
try To make a try...except statement #Python Assignment Operators
while To create a while loop
with Used to simplify exception handling Operator Example Same As
yield To end a function, returns a generato
= x=5 x=5
+= x += 3 x=x+3
#Python Built-in Data Types
-= x -= 3 x=x-3
Text Type:str *= x *= 3 x=x*3
/= x /= 3 x=x/3
Numeric Types:int, float, complex %= x %= 3 x=x%3
//= x //= 3 x = x // 3
Sequence Types:list, tuple, range **= x **= 3 x = x ** 3
&= x &= 3 x=x&3
Mapping Type:dict |= x |= 3 x=x|3
^= x ^= 3 x=x^3
Set Types:set, frozenset >>= x >>= 3 x = x >> 3
<<= x <<= 3 x = x << 3
Boolean Type: bool
Binary Types: bytes, bytearray, memoryview Python Comparison Operators
Comparison operators are used to compare two
Print the data type of the variable x: values:
x=5 Operator Name Example
print(type(x))
== Equal x == y
!= Not equal x != y
#Python Operators > Greater than x>y
< Less than x<y
Python divides the operators in the following >= Greater than or equal to x >= y
groups:
<= Less than or equal to x <= y
Arithmetic operators
Assignment operators #Python Logical Operators
Comparison operators Logical operators are used to combine conditional
statements:
Logical operators Operator Description
Identity operators and Returns True if both statements are
Membership operators true Example: x < 5 and x < 10
Bitwise operators or Returns True if one of the statements is
true Example x < 5 or x < 4
#Python Arithmetic Operators not Reverse the result, returns False if the
result is true
Operator Name Example Example- not(x < 5 and x < 10)
+ Addition x+y
- Subtraction x-y