0% found this document useful (0 votes)
2 views186 pages

Python Handwritten Notes PDF Guide (2)

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views186 pages

Python Handwritten Notes PDF Guide (2)

Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

PYTHON

HANDWRITTEN NOTES

Chip Sized

chipsized

Chip Sized
170+ PAGES
PREFACE

PYTHON
Hello friends! I present to you my
personal handwritten notes of
Python which consists of over 170+
pages involving all important topics.
It took about 25 hours to complete
the notes.

I request you to support my work

by rating this book 5 out of 5.

You can get this book for free on


Gumroad. But getting it for a small

amount would be of a great help if


you are willing to support me and

my channel.

I would constantly work to provide


you with better and useful content.
You can follow and subscribe to my
LinkedIn, Instagram and Youtube
channel.

PAYPAL DONATION
[Link]/chipsized
CONTENTS

N
INTRODUCTION TO PYTHON
PYTHON DEFINITION

HISTORY OF PYTHON

O
FEATURES OF PYTHON

APPLICATIONS OF PYTHON

INSTALLING PYTHON
INSTALLATION STEPS

H
INTERACTIVE AND SCRIPT MODE

THE PRINT FUNCTION


INTRODUCTION
MULTIPLE PRINT FUNCTIONS

PYT
PRINT MULTIPLE VALUES
USING END ARGUMENT
USING SEP ARGUMENT

COMMENTS
VARIABLES
INTRODUCTION
RULES FOR NAMING VARIABLES
VARIABLE ASSIGNMENT
UPDATING VARIABLES
MULTIPLE VALUES AND VARIABLES
SINGLE VALUE TO VARIABLES

DATA TYPES
INTRODUCTION
INT, FLOAT AND COMPLEX
STRINGS, LISTS AND TUPLES
DICTIONARIES
SETS
BOOLEANS

N
NONE TYРЕ

MUTABILITY OF DATA TYPES

IMPLICIT TYPE CONVERSION

EXPLICIT TYPE CONVERSION

GETTING USER INPUT

O
OPERATORS
INTRODUCTION
ARITHMETIC OPERATORS
COMPARISON OPERATORS

H
LOGICAL OPERATORS
BITWISE OPERATORS

ASSIGNMENT OPERATORS
IDENTITY OPERATORS
MEMBERSHIP OPERATORS

T
OPERATOR PRECEDENCE
OPERATOR ASSOCIATIVITY

BLOCKS AND INDENTATION


INTRODUCTION
IMPORTANT POINTS

CONDITIONAL STATEMENTS
INTRODUCTION
THE IF STATEMENT
PY
THE IF-ELSE STATEMENT
THE IF-ELIF-ELSE LADDER
ORDER OF CONDITIONS
THE NESTED-IF STATEMENT
SHORT HAND IF

SHORT HAND IF-ELSE

THE PASS STATEMENT


MATCH CASE

PYTHON
INTRODUCTION
USING MULTIPLE PATTERN VALUES
USING A GUARD

LOOPS
INTRODUCTION
FLOWCHART - LOOPS
WHILE LOOP
INFINITE LOOP

FOR LOOP
THE RANGE FUNCTION

NESTED LOOPS
BREAK AND CONTINUE STATEMENTS
THE ELSE STATEMENT
THE PASS STATEMENT

STRINGS
INTRODUCTION
INDEXING IN STRINGS
STRING SLICING
STRING IMMUTABILITY
MULTILINE STRINGS

STRING CONCAT AND REPEAT


STRING LENGTH AND MEMBERSHIP
STRING METHODS
STRING FORMATTING

ESCAPE CHARACTERS

LISTS
INTRODUCTION
LIST SLICING
CHANGING LIST VALUES
INSERTING LIST ITEMS
ADDING LIST ITEMS
REMOVING LIST ITEMS

PYTHON
COPYING LISTS
SORTING LISTS
REVERSING LISTS
LIST CONCAT AND REPEAT

LOOPING THROUGH A LIST


LIST COMPREHENSION

TUPLES
INTRODUCTION
TUPLE ASSIGNMENT

UNPACKING TUPLES
UPDATING TUPLES
DELETING TUPLES
TUPLE CONCAT AND REPEAT
TUPLE METHODS

SETS
INTRODUCTION
ACCESS AND CHANGE SET ITEMS
ADD SET ITEMS
REMOVE SET ITEMS
SET OPERATIONS

DICTIONARIES
INTRODUCTION
ACCESS ITEMS
CHANGE VALUES
ADD DICTIONARY ITEMS
REMOVE ITEMS

LOOP THROUGH DICTIONARIES


COPY A DICTIONARY
FUNCTIONS

PYTHON
INTRODUCTION
IMPORTANT POINTS

FUNCTION CALL
FUNCTION - EXPLANATION DIAGRAM
PARAMETERS AND ARGUMENTS
KEYWORD ARGUMENTS
ARBITRARY ARGUMENTS
ARBITRARY KEYWORD ARGUMENTS
DEFAULT PARAMETERS

CHANGES WHEN PASSING VALUES


RETURN VALUES
USING PASS IN FUNCTIONS
TYPES OF FUNCTIONS

VARIABLE SCOPE
GLOBAL, LOCAL AND NON-LOCAL VARIABLES
OVERSHADOWING OF VARIABLES
MODIFICATION IN DIFFERENT SCOPES

EXCEPTION HANDLING
INTRODUCTION
TRY AND EXCEPT BLOCK

MULTIPLE EXCEPT BLOCKS


ELSE AND FINALLY BLOCKS
RAISING EXCEPTIONS

MODULES
INTRODUCTION
CREATING A MODULE
IMPORT A MODULE
USING THE FROM STATEMENT
RENAMING THE MODULE
BUILT-IN MODULES
COMMONLY USED MODULES
SOME EXAMPLES

N
PACKAGES
INTRODUCTION
CREATING A PACKAGE
IMPORTING A PACKAGE

O
CLASSES AND OBJECTS
INTRODUCTION

CREATING A CLASS
CREATING OBJECTS

H
PASSING VALUES TO CONSTRUCTOR
MODIFYING OBJECT ATTRIBUTES
GETTERS AND SETTERS
PRIVATE ATTRIBUTES
DELETING ATTRIBUTES AND OBJECTS

PYT
THE PASS STATEMENT

CLASS ATTRIBUTES
CLASS METHODS

STATIC METHODS

INHERITANCE
INTRODUCTION
METHOD OVERRIDING
THE SUPER FUNCTION
TYPES OF INHERITANCE
PYTHON HANDWRITEN NOTES

YOUTUBE - Chip Sized


LINKED IN - Chip Sized
INSTAGRAM - chipsized

INTRODUCTION TO PYTHON:

DEFINITION:

Python is an interpretad, high-level,


and general -purpose programming language.

High lovol - Programs are easily undesstoDd


by bumans

Anterproted - Uses an intorpretar to

execute programs.

General Purpose - Used in a variety of


applications leke wob,
desktop, ML, AI etc

HISTORY:

Founder - Guldo van Rossum

Year found - 1989

Purpose Botter Readabelety.

Vorsions Python 2 and 3 Ccusently


Python 3.10)
FEATURES OF PYTHON:

1) Easy to writo, read, and learn.


2) Froe and open-sousce.

3) Interpreted
4) Supports modulasity.
5) Extensible

6) Dynamie type systam.


7) Automattc memory management.
8) Supposts thisd-party packages.
9) obpect -oriented.

APPLICATIONS OE PYTHON

1) Wob Development
2) Game Devellopodent
3) Machene Learning and AI.
4) Data Science and Visuali zation.
5) Desktop GUI

6) Web Scraping Apps.


7) Businoss Applications (E-Commerce)
8) Audro and Vedeo Applicatpons
9) CAD Appications
10) Embedded Applications.

Top companies such as GDogle, Facebook,


Instagram, Quasa, Dropbox, Udemy and IBM
usos Python.

H TS number one In populasity ameng


Vanguages.
INSTALLING PYTHON:

Note: (To check wbother Pythonalready is


installed, open command prompt CCMD), and
type the command "python --version". gf Pt

shows version, you


a have it alseady
Pnstalled. Ie not you must download the
Python Prstalles.)

STEPS:

1) Opon your browser. and search python.


27 Caecke the lenk of [Link] (search).
3) Download the lateost version.
4) Opon the installer
5) Chock the two boxes below Cirstall for
all usess, add Python to PATH.)
6) Click on Install Now. Walt untpl Pt's

complete anel then close.


7) Agaen open CMD. Type the command
"python --vession", and It would display the
version.

Note: ( There may be diffesent versions of


Python and are constantly updated. At the
time of writing. the version was Python 3.10.7.

Download the latest vorsion any wdy as

there may be very letthe defference among


defferent verston.
INTERACTIVE AND SCRIPT MODE:

In Python, there are two ways to


sub our code.

1) Intera cive Mode

2) Scrtpt Mode.

INTERACTIVE MODE SCRIPT MDDE

1 Python statements 1) Python program is


are wsitien in CMD and written in a file.
we got the sesult Dp The Python interpreter
each line instantly executes the complete
file and displays
output in CMD.

2) Bottor Suited for 2) More suitable Por


writing very short long psograms.
progsams.

3) Code can be edited, 3) Edlting of code


but 9t Ps hasd to do. is easily done.

g)Code cannut be saved 4) Code can be Saved


and used Pn futture. and used in future.

5) Suitable far practire 5) Suitable for


and wndorstanding code. writing programs and
projects.
THE PRINT FUNCTION:

The print) function is used to aisplay


the output in the console.

SYNTAX

print (<value>)

EX: 0/P:

print ('Hello Worldl') Hello Word

MULTIPLE PRINT EUNCTIONS:


We can use multiple print funetions.
It prints each vallie in a hewlene

Ex: 0/P:

print C20) 20

print (3-56) 3-56

print ('Hellw') Hello

print (" Python") Python

Text Ccalled stsings) In Python must be

given withen single os double quotes.

PRINT MULTIPLE VALUES:


② Multiple values can be printod using
a single print Punction and separating
values with a comma.

SYNTAX:
print (<vas1z, <vo27,..., <val n
Ex:

print C10, 'Hello', " Python", 3.87)

01p:
ID Hello Python 3.87

The values are printed in a Single lene


with a white space in botwo00

USING END ARGUMENT:

MuHple values can be printed using


dipfesent print Punctions and stiu mako them

display in a bew single lene.

The end argument is used for that

within the print function to print a string


after all values are printed

By default, it holds a 'in' (newline)


charactes and that is why, a new print
function starts printing in the newlene.

EX:
print C" HellD", end = '#'
print ("Morning"

07p
Hello # Morning
USING SEP ARAUMENT:
The sop argumerst can be used
within the print function to print a string
between all values when multiple values
ase wsed

By default, The
Sop argumest holds a
white space ca ") and that's why, values
printed in the same ine leave a whitespace.

EX:

print (u Hello", ID, 20.45, Sep =" * uI

0/P:
He llo *10* 20•45
COMMENTS:
Comments are used for explaining code

in plain English

The Python interpreter ignores commerts


and they are not executed.

A Comment starts with a # syтьol


and is terminated by the end of Lene.

Inlene comments ase written beside


a Python statement.

Ex:

# This is a single - line comment


print (" My Code") # This prints My Code

0rp:

My Code

Here, the first comment is a single lene


comment and the second Comment is an
Pnlene comment.
VARIABLES:
Variables are bames assigned to
memory locations. The values assigned to

variables can be used within the program.

SYNTAX:
<vasiable-name> = <value>

Noto: No need to declase a vasiabte or

Specify the Python is dynamically


data Jype.
typod Cdata type automatically detected dusing
runtime)

EX /P

a = 10 ID

print Ca)

Here, á is the variabde name for the


C
value ID, When you refer to a anywhere
in the program, that means you are

referring to 1D. te

C
RULES FOR NAMING VARIA BLES
C
to

1) Vasiable hames must start with a letter


or an undesscore.

x=20 #valfd

-chip = "stzed" # valld


$a = 13.94 #invalid

3b = 44 #Pnvalie
2) Variable names must start with letters

or undesscores, but digits can be used exept


the stast. Speial symbols can't be used

a var = "chocolate" # valid

num1 = 3 # vauel

3) Names are case -sensitive

a =ID 0/P:

print (A) Error

4) Python keywords are not allowed. These


ase 35 keywords Cas of vessiDn 3-1D).

The ist Df keywords can be seen using


this code.

Import keyword
print (keyword. kolist)

ASSIGNING ONE VARIABLE TO ANOTHER:


variable containing a value
A can
be assigned to another variabde

EX:
a = 20

b=a # Assigning a (which has value 20)


#

print (b)
print (as
0/P:
20

20

Noto: When different vasiables havo the


same value, 9t means that the values has

two hamas. This can be visually displayped.

When a = 15, b = 15

a 1
b
15

UPDATING VARIABLES:
Vasiables can be updated to
different values within a program.

EX:
num1 = IDD

num 2 =200

prent (numI, num2)


Dum 2 = numI #assign numi nums

numI = 40b # update numi

print Coum1, num2)

0/P

100 200

400 100
VISUAL REPRESENTATIDN:

numa I0D num 2 200

Imun
IDD -num2 20D Cleft alone)

num 27 LDD numI 4DD

The updated values can be of different


data types.

Ex:

Val1 = 10 # an integer
print (val1)
val1 = " GDDd" #a string
prent cval1) LSY

0/P
10

Good

You can assign an expression to a variable


and Pt would automatt cally convest Pt to
a value.

EX
a = 2+4 # automatically added
prirt (ex)

0%p:6
EX
a = LD

print Ca)
a=a+ 20 # add 20 to á and then

print (a) # assign the new valme to a

#again.

0/P:

30

ASSIGN MULTIPLE VALUES TO MULTIPLE VARIABLES:

You can assigh muttiple values to


multiple vartables in one une. Make suse

that the number of vauriables are equal


to the sumber of values.

Ex: O/P

a, b,c = 20, 12, 34 2D

print (a) 12

print (b) 34
print (c)

If vasiables or values become more

os less 9t results Pn ersos.

EX:
Morning", "Night", "Evening"
4

a, b = " # Error
a, b, c= 1,2 # Errtr

You might also like