It is highlevel
programming language
that is easy to read and
write.
It is interpreted language
means here code is
checked line by line.
It is the language with
easy syntax and is
platform independent.
Python is widely because
of its huge libraries and
frameworks like for
example matplotlib,
pandas, etc.
It is beginner-friendly.
Also, along with
interpreted language it is
object oriented too.
What is Python?
4.
SYNTAX RULES
FOR PYTHON
#is used for commenting the line (means there
is no meaning of line starting with the hash, it
is just used to increase the code readability).
Python is case sensitive language means “a”
and “A” are different in python.
Indentation is important means proper spacing
in every line in python is mandatory otherwise
it will show syntax errors.
5.
VARIABLES IN
PYTHON.
4. Keywords(Reserved words with predefined meaning) can’t be
used.
3. No special characters except _
2. Cannot start with a number.
For naming variable there are some rules: 1. Must start with letter
or underscore.
If we assign value at time of declaration of variables, we need not to
mention the data type as it will be decided at runtime.
Variables store data value in python.
6.
WHAT ARE
DATA TYPES?
Datatype defines the type of data.
The different types of dataset are: Numeric,
Boolean, Strings , List , Tuple, Dictionary.
Numeric variable with numeric data type is
declared using int.
String variable is declared as str.
Bool variable is declared as bool.
By default, variable is declared as string if
don’t mention the type.
7.
NUMERIC TYPES: INT,FLOAT,
COMPLEX
Integers (int):
1. Whole numbers, positive or negative, with unlimited precision. Python
can handle arbitrarily large integers. Examples: 42, -7, 1000000000000
Floating-Point (float):
1. Numbers with decimal points or in scientific notation. Stored with finite
precision (about 15-17 significant digits). Examples: 3.14, -0.5, 2e5 (200000)
Complex Numbers (complex):
1. Numbers with real and imaginary components, useful in scientific
computing and signal processing. Examples: 2 + 3j, 5j, complex(1, 4).
8.
LIST AND TUPLES.
Listis an ordered collection of
elements.
Lists are mutable.
List is dynamic in size and
heterogeneous.
It is defined using square brackets [].
They also allow duplicate values.
Tuple is an ordered collection of
elements.
Tuples are immutable means elements
can’t be changed.
Allow duplicate values.
Defined using parenthesis ().
Used for fixed or read-only data.
9.
STRINGS
Ordered sequences of
charactersthat are
immutable—once
created, they cannot
be modified.
Access characters by
index: "Python"[0]
returns 'P'
Negative indexing:
"Python"[-1] returns
'n'
Slicing: "Python"[0:3]
returns 'Pyt'
Concatenation:
"Hello" + " World"
Repetition: "Hi" * 3
returns 'HiHiHi'
10.
DICTIONARY
Stores data inkey–value pairs
Keys are unique, values can be duplicate
Mutable – values can be updated
Defined using curly braces {}
Used for fast lookup and structured data.
EXAMPLE:
person = { "name": "John",
"age": 30,
“City” = “new York”
}
11.
SETS
Sets is unordered
collectionof
elements.
Does not allow
duplicate values.
Sets are mutable.
Defined using
curly braces {}.
colors = {"red",
"green", "blue"}
numbers = {1, 2,
3, 3, 4} #
{1,2,3,4}
12.
BOOLEAN TYPE
Boolean representsTrue or False
values.
Used in decision making and
conditions.
Result of comparison Operations.
Written as True, False (T,F).
Plays a crucial role in if, while, and
logical operations.