Basic Python Notes

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

clacstec

Basic PYTHON Notes


AUL UMAR
NoTES 4ALLErY
Nhat is a Python
Python is a simee, hign level, qenexal.
purpose and obËect - Oriented PYOgraMMing
language
hy leayn Puthon
EGSy to use Qnd earn
Expresslve anguage.
C

Intexpretedlanguage
|Object-Oyiented 1anquage.
Open sOuYCe |anguage
Extensible
Embeddable
Dynamic MemoYy Allocatlon
"Cqur Programming suppoxt.
where is Puthon used?
Dara science
Dara Mining
Desktop Applicatons
Mobile Applications.
web Applications
Machine learninag
3D CADApplications
SpeechRecognitlons
Dcie

NOTE : hexe /s no use Of Cusly braCes ox


Semicoloni n python prog7aMmin g
|anguage.
Rathon tYst Program AUL MR LUNKEPN).
NOTES GALERY TeLE;EAM).
KograM for Print Heilo norld
Print"Hello aNorld"
Puthon PopulaY rameworKS and ibYaries
|eb Development : D Janao f1ask_ lyYamid
Chersy Py.
GUIS based Applications : TK, PyGTK, PyQT,
PyTS.
Machine |easning : Tensorfow yToYch
Py
Scikit- learn etc.

Mathematics : Numpy
Nympy pandgS etc.
Puithon axiables.
Python Variable is a nane that is used to
refer toD MeMory 10carion. Pytnon vaxiable
is alsO Knon as identiCiex and used to
hold alue:
classMate
Date
Page

n n python, Ne don't need to specify the type


f yaiable b ecause puthon is an inFer
|language and smart
Smart enough to qet variable
type.
Examples:
|| Tnteger Data Tupe.
b ="vedant" || Character Data Type.
U 80.50 || Aloat Dara Type
print (a)
priot (b)
Pyint (u) AtuL kuMAL(LINKEPN)
NOTES GALeKYTELEYRA)
Output :
5
Vedent
80.50

Python 10ops.
The while loops
witn the mhile lo0p e can
execute a Set of Starements as long as Q
condition is tyue

Example
while i<6:
prlnt (i)
3.
classMate
Date
Page

The for loops


AFox l0op is used foY iterating over a
Sequence . It is fyequently used to traverse
the data structures like ist_ , tuple or
dictiongry
The syntax of Fox lo0p:
or iteyating - var in sequence
Sttement (S)

Example i
S+Y= Vedant
foY i in stx:
Print(i)

Outpyr: AUL eMR LINKEDIN).


NorES GALLeRY(TELE4RAM).

Exgmele:
aqe int(input("Enter your Age"))
age
print("you qre eligible to vote")
else:
print("yos are No eligible to vote" 4.
classMAte
Date
Page

The elif stQtement

Ihe eli stateMent aye used to check Multiple


Conditions and executes the specific block
OF statements dependin upon the tue
Condition aMOng them.
ATuL KMALUNKGDIN).
NOTES YMLERY (TeLRAM)
Suntax TE ConditlonS:
# block of Statements
eif condition :
*blocK of Starements
elif conditBon 3:
# blocK of Statemens
elif condition 4i
# blocK of Sratements
else

Rython function
Pathon function axe the Most iMpoxtant
aspect of an application. A Function can be
setined as the oxagnized blocK of
xeusable code, mhich can be caled
Jnhen evey required

Cyeating function.
Python provides the def Keyword to define
the function. The syntax of the de Cine
Funcion is GiVen below
5.
cAssMate
Date
Poge

Suntax
def My.funcion(Paraqmeters) :
unctlon - blocK
etuYn Expression.
AuL aMM LINKEDIN)
ExaMple : NOrES GAMUeYGEEYRAM).
def suM(): # Defining funcion
b= 20

xeturn c
#Calin sum function in pxint
statement
print("The sum is :", suMO)

Pthon Arxays
An array is ga collection of a similay tupe
Of data and stored it into the contiaues
MemoÝy 10cqtion THe îndex of an array
is starting nith Q I ee can access each
element via itsjndex.

Tne Array can be cyeated in python by


iM20ring the aYYay Module to the
python program.
6
LINKEPIN).
element:"aLI])
9)
=arx.axYay('i,C2,4,6.
q to)
eleMent:"a quotes,
the
of
Date
KUMAR
arr
ATUL 2 4 thesingle
collection
quotes vedant
as :
:element
FiYst
print("Second Sring
Python
element
by String
indexing
* avYayprint("yst triple
íMpoxt suxounded Hi
iMport Second (=
ox Sty
String
is
aXYay quores
tyom ExqMple Qurpur Syntaxi
charactexs
Python
double
IMALUNKEPIN).
AruL
clhssmta.
Sting
Date a
string
Of
pexfoM 55
sub-Stzings =
L two
E
Hello".
=
Str number
the
2atticulay
string
to Sum
is
[0.
Lo]) [2])
Print(sty
L1]) ty [5])
Pslnt(&t
[3])
[4])
Print(Sty (&th
Print
Print(Sty
Print(S Concatengte
Poxmatting
the used enteyO
Stina
Operators
J’OAccess
is
Tt
Examplei 0 Oubeut:

t E /.

You might also like