Python Notes
Python Notes
with
Python
From :-31/08/23
Till : -
Semester :
-
Sen-1
Professor : -
Karan Sir
LIBN expert
once y
Python with
Basics about
py t h o n
: -
-is our
first
we evere ehis
save- -
Python would
The
follo byte
ode
fell fanzoy-own it
&
·
or sher .
at should half
:
↑
it
critual machine &
/definitions : -
-> information
collects e
fe
file
multiple
from
:
- &
I facter -Interfector
median
for
: communication
is
the
are
data
non-compiled
string
-- is
of .
It often
used to explain how the
code is
femilioning
<- etc .
The
single-line comment syntax is -
Creating a variable :
A variable is
basically
holds
object
an
value :
that a defined
It is a part of the
I characters -
(a-2)
naming
sensitive
sys te m
case .
Some clean
Coding Tips s Tricks
For ex c
,
b, c = 1 , 2 , 3
e
-m
print (a ,
b, L)- Output ->
123
it
or
function
for
for ex : -
x= wrong way x = 1
V
1
2
R y
y
I
/
=
=
2 = x +
y perint(u+y) I
Output correct
-
43
print (take (n)) -outfout -> Dictionary"
osconi
Python
with
types :
① text
type -> Str
n-Variable data
tigpen
containing
:
comple numbers .
Ex : -x =
1 j
-I
2) List Sequence bayed data containing
t y ke
Ordered
i]
·
Eg :
-n =
[ 10 ,
Hi ,
·
chargable
·
Duplicatable
: Basically list but
-
read -
only .
Orderen
(10 78)
·
Hi
eg
: -
, , ·
Duplicatable
·
changable
-
4) Range : -
Usel to
whole
get
numbers
sequence of
.
Not
compatible
with decimals .
So I key-based tionary
:
-
data take
Eg :
-GName' :
"Karan' ,
"Rank' :
Professor's
·
ordered
·
key-based data
·
key must be
unique ,
However data doesnt require uniquenes .
Eatykes : -
-
⑰ Set Unorganised
: -
set of data
I
Unordered
example
·
: -
Unchangable
GName's
·
Karan' ,
"Rank ,
Professor's
·
Unindexed
duplicate
No
e
·
example : -
(Name's Karan' ,
"Ranks ,
Professor']
11/09/23
tykes
Des : -
Byte I
:
Byte-Bing form
-
of data .
A
=
&array-Arranged data
binning
form of .
eg
:- B =
bytway [1-]
I my pic
Operators ⑦ operators
-
Sothetic
:
② Assignment operators
③ Comparison operators
④ Logical operators
⑤ Bit-wise operator
⑥ dentity
I
I operator
I addition (H)
I subtraction 2-3
3) Multifly( *
)
Division(/)
⑤ Floor division(/1)
6 Modulus (%)
I Exponential ( **)
I Assignment operators :
used lo
-
assign
variabl value ·
ER :
-
A =
"H :
I =
I
x = 1 137 =
I
x =
x -
71
I t = x 1 12) x ny S
=
x +
=
.
I S
3) - x 1 13) x
=
xAS
=
x -
I I
⑭Y * I
n
=
xx1
I G x
=
x/z
I
6 1 I
n
=
x117
1)
=
* * 3
a x ** k
0
1 x
= x =
1
S
I
- I
x = x)1
= x
=
x I
I
-Simbre
3) Comparision compare values
we
operators : -
1 --
I
4
=
= S (Oufurt-False) (Bodean)
I I I 2 : 3 (Outbut-True)
=
3 - I
I
-3
5>3
? E
14 1
=
27 = z
S
~ Logical operators : -
I) AND
,
x < =
20 AND Y <= 21
2) OR A 10 OR B 1
=
=
>
3) NOT
String
12109123
tination
-
A =
"Hello Output -> HelloWorld
B = "World'
print (A +
String Format .
Age 30
Age
=
30
text :
'My age is E3
text -
"My age is
(Age))
Freos
I
, string + Integer The right
is
logically invorent
for kythos
&
3/09/23
case
-
types
comel east
my-Name-Is
) Pascal ease
My-Name-Is
③ Smoke case
my-name- is
-> Unpacking
collection
a
A =
71' ,
2,
]
X Y Z , ,
= A
X = I
y = 'z
z =
-
15/09123
Chan Coding
-
& Write
The san of
a
program
first
n
:-
sin a
.
My You
R
are given 4 members A ,
B
,
C
,
B
, find
D .
*
expression (A B)
+ (( -B) /t
as
given
a member o
, find its cube
.
area
⑰ Given a quadratic expression , +2x+1 . Now
Print the
result of A> B
>B
a tangle .
Print yes
or wo
Qi Given 3
integer A, B, < and
find
Sentegers
18/09/23
ing/sliving
Indessing
-
: -
slicing
-
: -
H
A = "Hello
↑y +↑
print (AC0]) ->
01234-Inden values
Joint (A[ s]) -> :
on sin
Negative Slicing :
-
A= Hello
↑y +↑
01234
S
- -
4-7-2 -
1
fint(A(-s -1]) :
Negative slizing can
:
only foint
Hell
(AES ])
point
use to till 0
foint
:
op
Hello
fully
we can also use multiple slice operations in one line .
,
Ey point ([1 thats ellable
: s
: :
1
List
I As
list
items ⑤ look list a) Joint list
③ Add
list
items ③ Sort list
of
19/09/23
20/09/23
fies
Tuples
-
-
D Oytha tuples
2)
tuple
Acco
3) update taple
I impassed tuple
look
tuple
jo Tuftech e
22109/23
Lists
-
I' ,
'B'
, "21] ,
12 =23
to
coby ,
dont do I instead do this -
12 21 Lz
[Link]()
=
X V
list
Join : There are 2 built-in functions ,
Inland
Adding
13 =
L2+ 22 23 =
11 enterd (L2)
List methods :
ples
Defined/created by-
Tc ('A' $ ,)
'
=
;
T1 =
tuble (PA ,
'B' , (1)
Accen items : -
sand as list
11 =
abherd (D)
T =
tuble (L1 coby) .
X , Y , z
=
T2
print X) A
!
->
->
fint YS B
Joint table
: -
Ts = T1 +
I2
Multiplying of tuples :
-
Is= T1
*
2
Dictionary
Topics :
-
3) access itams
Introduction to
dictionary :
-
D1='Mane' :
"Karan' , 'Class : B .
Tech's
Defining
bracket Blu markers
keys
represent
Access items :
- x =
D1 [Mame']
OR
use D1 ·
get (Name")
To get all beys ,
use De Reys() function
Values () function
Ters']
Finish mote of becaus
thuschen A Friday
-
-
som
conditions if statements