0% found this document useful (0 votes)
2K views

Al Ict Notes - 03

This document provides information about Python programming language for the 2019 batch. It discusses Python features, syntax errors, semantic errors, keywords, arithmetic operators, comparison operators, logical operators, and assignment operators. Example codes are given to demonstrate each concept.

Uploaded by

shanketheesh
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)
2K views

Al Ict Notes - 03

This document provides information about Python programming language for the 2019 batch. It discusses Python features, syntax errors, semantic errors, keywords, arithmetic operators, comparison operators, logical operators, and assignment operators. Example codes are given to demonstrate each concept.

Uploaded by

shanketheesh
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
You are on page 1/ 9

2019 Batch

jfty; njhlu;ghly; njhopy;Dl;gtpay;

A/L Information and Communication Technology


Programming
2019 Batch
PYHTHON PROGRAMMING LANGUAGE
igj;jd; nra;epuy; nkhopahdJ tupnkhopngau;g;G mbg;gilapy; mike;Js;s ,yf;Fg;nghUs;
rhu;e;jjhf mike;jpUf;Fk; cau;kl;lr; nra;epuy; nkhopahFk;.

igj;jd; nra;epuy; nkhopapid http://www.python.org/ vDk; ,izaj;jsj;jpd; %yk; gjptpwf;fk;


nra;J ngw;Wf;nfhs;s KbAk;

Python’s feature
1. fw;gjw;F ,yFthdJ (Easy to Learn)
2. thrpg;gjw;F ,yFthdJ (Easy to read)
3. guhkupg;gjw;F ,yFthdJ (Easy to maintain)
4. A broad standard library
5. Interactive
6. Portable
7. Extendable
8. Databases
9. GUI Programming
10. Case sensitive

Python program I fzpdpapy; jpwf;Fk; (Open) Kiw

Start Menu tpw;F nrd;W Python ,y; IDLE (Integrated Development Environment) I Click
nra;J Open nra;a KbAk; . ,J “Python Shell” vd;w ngaupy; fhzg;gLk;.
Njhd;Wk; IDLE ,y; >>> vDk; FwPaPL fhzg;gLk;. mjpy; Njitahd FwpKiwfis (Coding)
xt;nthU thpirapYk; (Line) vOjp thp thpirahfr; nraw;gLj;jpf; (Run) nfhs;sKbAk;.
Nfhg;gpidr; (File) Nrkpf;Fk; NghJ (Save) Nfhg;G ePl;rpahdJ (File Extension) .py OR .pyw vd
nfhLj;Jr; Nrkpf;f Ntz;Lk;

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

igj;jd; nra;epuy; nkhopfspy; Vw;glf; $ba tOf;fs;


1. njhlupay; tOf;fs; (Syntax Errors)
2. nrhw;nghUspay; tOf;fs; (Semantic Error)

njhlupay; tOf;fs; (Syntax Errors)

njhlupay; tOf;fshdJ igj;jd; nra;epuypy; fhzg;gLk; %yr;nrhw;fspy; (Keyword) Vw;gLfpd;w


vOj;Jg; gpiofs; kw;Wk; cupa FwpaPLfs; gad;gLj;jg;glhikapdhy; cUthfpd;wJ.
nra;epuyhdJ nkhopngau;g;Gr; nra;ag;gLfpd;w nghOJ gpiofSf;Fupa tupfs; Rl;bf; fhl;lg;gLk;.
MfNt njhlupay; tOf;FSld; $ba nra;epuy; mjd; KbT tiu ,aq;f khl;lhJ. mr;
nra;epuYf;Fupa ntspaPl;bidAk; ngw KbahJ. tOf;fs; jpUj;jg;gl;L kPz;Lk; mr; nra;epuiy
nraw;gLj;Jtjd; %yk; ntspaPl;bidg; ngw KbAk;.
njhlupay; tOf;fs; Vw;glf;$ba re;ju;g;gq;fs;

1. %yr; nrhy;ypy; (Keyword) Vw;gLk; vOj;Jg; gpiofs;


2. Njitahd ,lq;fspy; colon (:) FwpaPL ,lg;glhik
3. cupa ,lq;fspy; milg;Gf;Fwpfs; njhlq;fg;gl;L Kbf;fg;glhik.
4. nrhw;fspw;F (String) “ ” vDk; FwpaPL ,lg;glhik
5. rupahd Kiwapy; cl;js;sy; (indentation) ,lg;glhik

nrhw;nghUspay; tOf;fs; (Semantic Error)

Fwpj;j igj;jd; nra;epuypy; FwpaPL vJ tpjkhd tOf;fSk; ,d;wp nra;epuyhsupdhy; ,lg;gLfpd;w


jtWfs; ,tw;Ws; mlq;Fk;. mjhtJ nra;epuypw;Fupa ntspaPL ngwg;gLk; Mdhy; mt; ntspaPL
jtwhdjhff; fhzg;gLk;
nrhw;nghUspay; tOf;fSld; $ba nra;epuyhdJ ,Wjp tiu ,aq;fp ntapaPl;bidj; jtwhfj; jUk;

rhtpr; nrhw;fs; (Keywords & Reserved words)

Fwpg;gpl;l xU nra;epuypy; rpy tpNrl nraw;ghLfspid nra;tjw;F kl;Lk; xJf;fg;gl;Ls;s nrhw;fs;


Keywords MFk;. khwpfspw;F toq;fg;gl;bUf;Fk; ngau;fisAk; Keywords IAk; Nru;j;J Reserved
words Fwpg;gpl KbAk;. Keywords ,id khwpfspd; ngau;fspw;F gad;gLj;j KbahJ

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

Keywords

khwp xd;wpw;F ngaupLk; NghJ ftdpf;f Ntz;bait


 khwp xd;wpd; ngau; MdJ ,yf;fq;fs; vOj;Jf;fs; underscore (_) vd;gtw;iwf; nfhz;L
mikayhk;
 khwpfspd; ngau;fs; vOj;Jf;fspy; my;yJ underscore (_) ,y; Muk;gpf;fyhk;. Mdhy;
,yf;fq;fspy; Muk;gpf;ff; $lhJ.
 khwpfspd; ngau;fspDs; ,ilntsp ,l KbahJ. mNjNtis vz;fzpj ju;f;fr;
nra;iff;FwpaPLfisAk; ,l KbahJ.
 Vida tpNrl FwpaPLfs; (!, @, #, $, %, ^, &, *, ,) gad;gLj;j KbahJ.
 igj;jd; nra;epuypd; fiyr; nrhw;fs; khwpypfspd; ngau;fshfg; gzd;gLj;Jjy; jtpu;ff
; g;gly;
Ntz;Lk; (if, for, while, break, print)
 khwpfspd; ngau;fspy; ,lk; ngWk; vOj;Jf;fspd; vz;zpf;iff;F cr;r vy;iy fpilahJ.

Example:

Name rupahdJ (Correct)

Student_Name rupahdJ (Correct)

Mark1 rupahdJ (Correct)

8Angle jtwhdJ (Incorrect)

Student Name jtwhdJ (Incorrect)

Name# jtwhdJ (Incorrect)

@school jtwhdJ (Incorrect)

If jtwhdJ (Incorrect)

123 jtwhdJ (Incorrect)

-school jtwhdJ (Incorrect)

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

trdj;ij fhl;rpg;gLj;Jk; (Print) Kiw


nrhw;fs;, trdq;fs; FwpaPLfis Print nra;Ak; NghJ “ ” ,Ds; my;yJ „ ‟ ,Ds; nfhLf;fg;gly;
Ntz;Lk;.

Example: 01

>>> print "Hello, Python!"

Output :

Example: 02

print "python"

Output :

Example: 03

print ‘python’

Output :

Example: 04

print "Nimal\’s age"

Output :

Example: 05

print "Roy said,\ "hello\" to me"

Output :

Example: 06

print "Name\t", "Age"

Output :

Example: 07

print "Name:\nSchool:\nGrade:"

Output :

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

Note:

 Gjpatupapy; Type nra;tjw;F (Enter/New Lien) :- \n


 Tab %yk; ,ilntsp mikg;gjw;F (Tab Key) :- \t
 Tab %yk; mikf;fg;gl;l ,ilntspia ePf;Ftjw;F :- \r
 \ vDk; FwpaPl;bid ,Ltjw;F :- \\
 ‘ vDk; FwpaPl;bid ,Ltjw;F :- \’
 “ vDk; FwpaPl;bid ,Ltjw;F :- \”

,it midj;Jk; “ ” ,Ds; ,lg;gLjy; mtrpakhFk;

Explicit line Joining


xd;Wld; xd;W njhlu;Ggl;l xNu tupapy; mika Ntz;ba FwpKiwia mLj;j tupapYk; vOj
Ntz;ba Njit Vw;gLk; re;ju;g;gj;jpy; \ vDk; FwpaPL gad;gLj;jg;gLk;

>>> x, y, z =\

2, 3, 5

Implicit line joining


List, Tuple, Dictionary Mfpatw;iw [], (), {} Mfpa milg;Gf;FwpfspDs; tiuaiw nra;Ak; NghJ gy
tupirfspy; mikayhk;

X= { ‘x’:5, ‘y’:

10, ‘z’:20}

tuple = ( 'abcd', 786 , 2.23, 'john', 70.2 )

list = [ 'abcd', 786 , 2.23, 'john', 70.2 ]

tuple[2] = 1000

list[2] = 1000

vz;fis fhl;rpg;gLj;Jk; (Print) Kiw


vz;fis print nra;Ak; NghJ “ ” ,Ds; my;yJ ‘ ’ ,Ds; ,lf;$lhJ. “ ” ,Ds; my;yJ ‘ ’ ,Ds;
,lg;gLk; NghJ ,yf;fq;fs; nrhw;fshff; fUjg;gLk; mjdhy; fzpj;jy; nraw;ghLfs; vjidAk;
Nkw;nfhs;sKbahJ.

>>> print (25)

Output:

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

>>> print ("My age is ",24)

Output:

Note:

xNu tupirapy; fhzg;gLk; igj;jd; $w;Wf;fis NtWgLj;Jtjw;F ; vDk; FwpaPl;bidg;


gad;gLj;jyhk;

Fwpg;Giu (Comments) toq;Fk; Kiw

1. Fwpg;Giufs; (Comments) nra;epuypid (Program) tpgupg;gjw;F gad;gLj;jg;gLk;. mjhtJ


nra;epuiyg; ghu;itapLNthu; mjid tpsq;fpf; nfhs;tjw;F Fwpg;Giufs; cjTfpd;wd.
2. igj;jd; nra;epuypy; # FwpaPl;bw;Fg; (Sign) gpd;du; me;j tupapy; toq;fg;gLk; vy;yh
tplaq;fSk; Fwpg;Giufs; MFk;.
3. # FwpaPl;bw;F (Sign) gpd;du; me;j tupapy; ,lk; ngWk; ve;jtplaKk; run Mf khl;lhJ.
4. ,it ntt;NtW nkhopfSf;F NtW NtW FwpaPLfis nfhz;bUf;Fk;
cjhuzk;: \\java comments

# This is a comment.
# This is a comment, too.
# This is a comment, too.
# I said that already.

vz;fzpjr; nra;iffs; (Arithmetic Operators)

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

,q;F nraw;ghLfis Nkw;nfhs;Sk; NghJ Kd;Dupik mbg;gilapYk; rk Kd;Dupik


ciladthff; fhzg;gbd; ,lkpUe;J tykhfTk; nraw;gLk;. ,k; kjpg;gPl;bd; mbg;gil xOq;fpid
Njitahd ,lq;fspy; () ,Ltjd; %yk; khw;wp mikf;f KbAk;. milg;Gf;Fwpf;Fs; fhzg;gLk;
tplaq;fs; kpfTk; cs; ,lg;gl;l milg;Gf;Fwpapy; njhlq;fp ntspNa ,lg;gl;l milg;Gf;FwpapDs;
,lg;gl;l tplak; tiu kjpg;gplg;gLk;.

>>> 1 + 2 * 3

Output:

>>> (1 + 2) * 3

Output:

xg;gPl;Lr; nra;iffs; (Comparison Operators / Relational Operators)


toq;fg;gLk; vz;fspw;F vz;fspw;F ,ilNa xg;gPL eilngw;W cz;ik, ngha; (True, False)
Mfpatw;wpy; xd;W kl;LNk tUtpisthff; (output) fpilf;Fk;.

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

>>> 9==8

Output : False

>>> 6!=3

Output : True

>>> 5>=5

Output :

jUf;fr; nra;iffs; (Logical Operators)


,uz;L my;yJ ,uz;bw;F Nkw;gl;l xg;gPlL
; r; nra;iffis ,izj;Jg;ghu;g;gjw;F ,it
gad;gLj;jg;gLk; tUtpisT cz;ik (True) my;yJ ngha; (False) Mfpa ,uz;by; xd;whfNt
mikAk;.

Operator Name Example Output


Or or 5>4 or 8>10 True
And And 5>4 or 8>10 False
not Not Not(5<4) False

Assignment Operators
Command Example Output
+= X=3
X+=4
-= Y=75
y-=50
*= Z=10
Z*2
/= X=25
x/=5
%= X=57
X%=4

Example:

>>> x=5

>>> x+=4

>>> print(x)

Output:

P.Bipunaath www.e-kalvi.com
ICT 0757746217
2019 Batch

gpl; rhu;e;j nra;iffs; (Bitwise Operators)

Example:

a= 60; and b = 13;

a = 0011 1100

b = 0000 1101

a&b = 0000 1100

a|b = 0011 1101

a^b = 0011 0001

~a = 1100 0011

P.Bipunaath www.e-kalvi.com
ICT 0757746217

You might also like