Diksha Sangale 46 AI Practical 1-8

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

Name: Diksba M:Sangale

STDTYBsc I I
ROLLNO: Y6
DIN A

TNDEx

SYDSo D a t e PRACILCAL NAME S1GN

40230121w e apmaram to implement|


d e p t h - r s tsearcho Algomtho.

b 23]o+|21 ite apmogra.no toîmpleroent


beadth-firsE searcb Algorithm
2 3o0+21 riLe apogmano For impleme-
dtation of N-Queen's eoblen

Oto8|2 ribe aproaram tDimplement


coateTJug prpblem:
. 1308 2 lcoLe a pmDcramto shufFle
deck of cards.

b 13|08|21 OTiLe a pDam For constaraints


Satificatioa prob)ems.

2.008 21 umite apogpramo to solue


Oue of Hanoi Poblem

2.0108|2lomiLe apmooram to iraplement


A Algos1thm
2|o821 mte a pmocerano For Tave llina
Salesnan problem (TSP)
8 1+|921rove Assocíative Lau and
Dfstribuive Lau
SClnso\e 01'KShQ Mq naj Al
·Ra \ \ MO '. l.\ 6 CD
2~\o+\~:1___ _ _ rpR AG 1~C AL --1 A
- . -· - - ··-
.--..- -- - - - - -
·--~- :.....-.

-1- -·- -- -·· - - -·-· --- ---


- --- hic! Y:.- 0 .es.:noDs.x,:xcr\::e D.£5 - ~Ex \goo ;tn_ --co_. __
l -- - - - --- -- - ---- - - -- - --
- - - --- - - - - - - - - - -
--- - - -r-- - - - - - - - - - ·

'is 1e.c .u .1s, ve


1 ,.

-- - ~eo '"'<- ti ~ - _\~_ Dep tzb- P\.:x_s_\:. se.a -Yc b


_ c:--c ~o. .? ½ ·
- - - - - -Ol.90':6.; th\'Q . _. P-o'?!".... i.'"'i.a ~es ,.n~ C\ he. e
-- d _a_-\::-Q_ ..sb:ruc.\::ul)'"e.. ..... _. . ____ . _ _ _

·-~- - --- - -- - - _ t;)...I. \:. ..i.s . co\ \ e o ---\:-be d€..p\:'n- ~,'""fst


s.ea"YC.\{
hec..o"-AS.€. _i\; _s\:; a-Yc -S t~'( "() \::-'ne "6"00 t. ()od
e ~
-------1-

£.o \.lo-1.QS ...e_Q_c.~ ... -~a.+ h \,1) \t.S gce ..0- test. ct-e.~-\:.\,
- - J -_ _

t-- --- -+- -~,-;a.A._e__ 'oe..\?o_ , _e. ~P v~_a .5 . -· ~ +-ne._ n.e.x. :\: __ ~ot 'r,
1- --- --+ --- -'~! Tne,.. r~c e.s s_ Dt tbe . D.PS R-\ef"nth'f"O .::, L
i---- ----- ----r ---~
'? c, o\
&-\.a: :n '-0...-r_ 'cO t-\-,e... . s~s ___ f?.ilg.o~\tp.:CO ·
)_e . _ . .. - - -- - -
_ nod .e_. _--=-1- .l e .P ·e:-. ·- no_a e . -\ rig h 'b-
___ ___ ___ ___ 'n.octe. _
- - - - - - - - - ____ ____ __ .l.RQ OT t'Q4 €)

-- -- -- -- -- u@ z- -- -- - Le•,,_e_l_Q__

-------i---------
(}µ"'- -I> 'eve\ ~----=---- ·

~ '
---;-""r""'-- ----'\-"'._.., ..._---=...;; :::-a;r'--j :--+ \e ·,~ ~ - --- - -

-· CE) -=- " ·-~ ,11;: \ r.:

1 - - - - - - - + - - - - - - - - _ _ ..... .lf!Q_
g_l node-+------

I .- - - ~-:~-.--. .. ·-·
- •
p Q_'\;_t)_J_:-_ , I .
- -

--- --- t -
s
.
.:_5-B -~)
,
B. ~2....0 ~~- E -~> .c ___ _) ~ ?__t-1. -:-)_~_-> _l<- - 3
--·-- .. ------- -- ----- .,. __ - ~ -
.
- ·- - - -
. - - --- - ~

----- - - - - - - - - --- - -- - - - - - - - - - · - - - - - - - - - - - - - -
··-- ·+---

--------------
1Sof\9a \e. \:)\ '"s~c, ,V\cv,aj
Ra ,, NO: L\-(;

., l

. .... . ..
I

~'"'('Q'f>f) =- -~ .
. . .. - . r.5 , - ~ C. ' .3 l i r 1-, J
C )
3' :. C '2.' , c 4" J , __
':i..l
·1

--~- . ..
C:.~ ·e > J _
1
'
2.. I
-•• CJ. I -

i•--· • ( Lr l ', - C (8 I J I - - - - -- - -

.. -- -
<g),
-. . ..
c., .J t - --- _..,_. - - -

t 3 .--·- -- -· -- -- -- - - -

-J - - -- -
,d_~~ dFSC."\J\S~-t.e.a 19'1raf''n ,nod-eJ ·.

l _
-~-t ' n()c\e 0 cyt- _) n
po~ o "t lnod e_J
\) 'f s, ced :

1 v ~ s\~ d . ad d l nod e )
e,a.?n t. node.] •
90-0 n~,8\) 'oou~ , n
-- : __ __ -- d f: s C.. \J ,s, 'c€ a \ 8-YO- p~ , ne ~ ~'n 'ba l.:nr)
' r~nt l((~o\\ ouJ\'(")<:) t-s;~e. De...?m·-~\'1fSt Sea-ye,\-)~
_
CN.o._-rn e •. D, 't<.s \, q ~on qi So'G~{~-\ e. 4
l
tlfS l v Is\ \,e d 1 8"ra,p'n 1 rs' )
Ro\ \ No ~ 4- G" )')

. .
I
,C onc.,us ,on -~ ~ \t1e o..ba'\Je. c...ode ,s suc.c.ess\-'u-
1 \, j e..x (?..c._ u ~ c\ us,"~ ~~\:'non.
I
=-Driver Code
1
""'illr( ' Follo~llng is tne De:p-tl:l-First Sea rch: (~,ame,: Di ks ha llanaj Sangal e & Roll l~o: .do) .. )
dfs (vls i .ted.1 graph.J '; · )

Foll.owlns is tlhe Depth-First: Search: (l~arr.e:Dik.sha1 Hanoj Sang:ale & Roll No: 4-6 )
1

3
3
2
4
8
7
SQn90.\e. t:>,K.s\, q \V \ Qne)J
, Ro\\ No ·. 4 b

23 \ a+ \e2.J
- :=r: - -
--P RA C7" :r..Gf\- L-
M• ::-:-
1 B :::::.-:=-======
-=---- --·-=========
I
I

: - i) 7I:),
s a) 9015:\ t\-yr:n s e a:xc 'o es 'b..,,_e_~b
s~e--L..L-L~a,.d__bJ.,.L.!...~l~~e~-o.,,t_::x...11....-:8~""~0~,l.Dd 3"<a?-n__µ3_0 ~ b __ _
1------.l---t'"'1.,._,_).LI,,
ti ' . ·/
!------- .1--__,__.__,""" '-'-~>J._~W-,.1- ~~~~~- ---'---'---.IL~""'--'fr.l..erD'::7r\Th::CO'
l)

~ , \;_l.<'.b.L.L'f.L.J__.s..;:)..stq_~-
r - - - - - - t - - - ----'--'--1-~~--1..B-1..\.u.g-4.la...L'.lf 'OL seQ.-:--rc~
:tbe b::e e _an_a__
1
0

cl\ \ S\lCC€SSQ: ¥ nroe.


a\;-:\::be c..D:C{
t------ - - + - - -- ~~:l,..,_L___.l,....v;._.: F a::ir e ~ \ og ::to n ad es o £:--- n e.,~,._,,__.

tC:r\ o o \ \""I o c\ e )
-----~
Po\;h _?,:._ s~ >R - >B ➔~ 7 _6\_
- - - - - - - - - --- - - ----- - - - - - - -__J
--- - ·- Code ·. - , -· -·- _:_ ----- - --·-
- ._ _____ : -·- Cons id e::c .:t:.b~ __Eo_\. lo..w in_3-- e x a 'C'O ?-ls ~· ----1
So.nga.\e D,,<s'nq, Mqnoj
fZ_o \ \ No ·, L\ 6

---- -

{ 2.) ·. r J
f 8 I :
-- - - - --jll

__J

- CJ

1 1 - - - - - -~ ~----.!I-..L..L......::,......-"--"'-!..5....l..l.__L-6--'-L~ ---+-'--''-4-~ 'n ..,__...,,..~


'c
.'----''--\- ) __.~' - - - - - - - - - - - - - - 1
.L.......!..
r-.,r,,o..-.,~ ( DOd P,j

- - - - - - - . - - -__,._,.._~ _\..5 ~\e aueDe


l, ·
1-------4----- r'Q -::. C\P e \\ £' f Oz> ( D)
0 \:. -=- c< )) ')

------.---- f.-0:f_ ~ ; n '23'.'CO?n Cm) :


_ _ ~ - ~hou:I_ oo\: '-'r"::i "\J.~S~d ~ ___ _
__ _ __i l l ~ d · a..~~ Cb_cl ~'n\:-nu_'1...J__ __
- - --9..,~u_e, ~ ~?£Dd Ln~b'oO\\:<J _ __
------1

--~- ~ -\n£-_S1eo.d -tn -t}-,-s):., seo~cn :~ ~


, ::l"'--O~ \. r-t.Q\law¾n-5
l..,____._ _ _1_...,,.__N-'---='-'--~ ~ ~ ~ ~D.n~___Scn::esa'e q Ro) \ NO~ ~J~.Y~

__4 e s_L~)S1--\:e..d-,5"rD.,~- i- r 6.1_J_ __ - -- ---- - - - --\


I
----- - -
_ .Cn.nclus.LQ..n ~ - :t\-)e a'oove c,odie ;s ~u.cce..ss£'u)'-:1 ,
e:1' e e, u \-"e. d us, n 8 f>.~ i-h on .
:#Driver Cede
p~int( " FolloL-t! rg is ~he Breadii:h - Fir~ .Search : ( r~arre : Di~csha Manoj 5angale & Roll r~o ; 46} n)
bfs (visited, Br aphJ ~;· 1 #fu nction calling

C1 Following is the Breadth -First Sea~ch:(Name:Oi ksha Manoj Sangale & Roll No; 46)
5 3 7 2 4 8
Sangale Diksha Mangj
RollNO 45 AT

ao10t|2 RACTICAL-2A

Aim: wite a pmogram for icmple.mentation


of N-QueenS pmpblem.s

he.omui Nqueers problem is the pmoblem


Ot aYanqinq the N-Queens oD aD NAN
Chessboasd in such a wau that oo tLOo
QueenS axe arxanged in-the sanne rOuo,
the same columo Or
diagonal.
Example
C4x4)
Q
Q

he solution is The Solution is


C3 2,4 C2,4131
(8x8)

The Solhubion s:C 2, 3,,13, 5, , 4

Code-
global N
N4
Sangale DiRSha Mano
Roll No: 6 AI
30 01a

deEpginLSolutionCboazd)
Foriin range (ND.
For i n range (N)
prsint lboas d i I c i ena " " )
psintC)

dee isSa Fe CboatdTOw ,col)


for n . range (col)
boas d C7OuDJCiJ=E 1
retudn false

Foxiiin zip (range Crous,=)-


YangeCcol L-)
iF boaTd CiICi 1:
retuDFalse

Forijin zip lrange rouw N,4)


range lcol, -DE
iP boas ti j - =
retusn False

Tetun ue

def solueNQUEIL Cooamd Col)


if Col = N
retunn Tue

foz iin range CN):


ipisSaRe Cboad Col)
boas d CiICcol3 1
iF Sole NQUEil Cboasd col t 4) =E
niaTue
YetuD LTue
oama CicolI-0
etuTD False
Sangale oiKshq Manoj
Roll NO: 46 AL
30l07 12

de solue.NQ C)
boas CCo, O, 0OJ
CO, O, O,03
CO OO,03

E SolueNQUtilCboasd, o)== False


prsint ("solulion does not exist").
e tuD)Fdlse

Piotsolution Cboasd
etuDT ue
Solue NQ)
Pint Name Diksha Manoi Sangale
Roll NO 4G")

Conclusion The above code is SuccessS-


Fulluexecuted using Python
Name:Diksha Manoj Sangale &Roll No: 46
8eie
1e e e8

e1e e
True
AL
ngale ofksha MdrnQ
Roh NO 46
O408la PRACTICAL-3

2ater
(oite a proasaro.to fmplemen

J u g eroble

Follouoing axe the u l e s t6 sol ve


neoxu
ateiuaporoblemi
are 2(uqs available o fill
Thee
oatex f r o m one
e ccD trronsfex a t e r
dugbo anothe
iii Theye ae Do moas kinqon the jug
iv)
we can pous a ter out of t h e iu

on the gmound
con be f i l e d ot a
N only onejuq
bime

example
Ou Cre aiven tuoo iugs -gallon Bne
a n d a2-gallon one O pumP uohích b a s
unlimiEe d uoaber which uou can use bo fill
the juqNeitherughas any measurina
poarkinqon.íbHO cau uou.qet exacblu
aallons of coober in the u-galloniuq 2

Solutiom-
Here the inibial.state fs Co,o). The
9oal s tate isC2,nPox any ualue oen

Lítemes in the Litens fn the


4-iteJus 3-1ites u9

3
Sangale Df Ksha Man AL
Roll No 46

Step 1 Initial state loo) both he jugs


ore empt
Step 2 frlluq 2 coith aallons C3) f oaer
Stepa rans Per 3qallo0s of ocAber Pronm
jug 2 o u g
Sp 4 Fill uq 0oi th e 3gallon s of
oaber
Step 5 Tansfe 4aallon.of wa ter
Psom ug
Step 6 &mphy jug
Step Tansfe from ua2tojug 1
Code

de F poUT Cjug 1jug 2)


mac 4 max 2 fiil = 5,
print 7.d\tzdi 1 jug 4jug2)
i fjug 2 is Pill all
NetuTnA
eliE jug 2 s mac2 l
poUs CO jug1)
eie ugi 0andiug2 s o
poU O ug1)
e líf jug 4 is eill
pour Cjug 1 o )
elif ug 1 mooc
pouT maxi u g 2
eli ug1 Cmac 2-ug 2
poU Lo, u94 u a 2
else
Pouz ug i-max2jug2)-Crmax
2-
Jug2 jug2)
pint(NameDiRsha Manoi Sangoale 4 Roll
No46)
print 3U61 \ E JUG2)
Sangale
ROl ND 4GDiKsha ManojJ
AL

poU o o)

Conclugion The aboue code is Success full


execubed Osing puthon
Name:Diksha Manoj Sangale & Roll No: 46
JUG1 JUG2

6
(i)

bo s:OuS£,e d~\< of
,A., l n~ : ll.J.'\', \. e.. C ~'T'Q~"l'Of"n
Co" dS

l~eo '!B :. ; >"The, .., ei;,,µ I-< ed f o.c\<.CtBe. s : ..,, e


\f"OfO'Y \:;,ed. 7"he. • , \:.f.--Y \:;oo\s' p ocko._g~ is ---
Lise.cl. and the 'p:rooluc.\:.' roeWod i_.s ..u.Sed
to 9e1c tne. dee.¼ of. eorrd ~ -; n o. \ 1st- -
f'cyr.na t,
\; '> lh~.s
\ ~_s:\:_ f .s _ ..s_'nu_f t:\e d_o.s tne .:cb
'' s 'nu Pfte 11 f'{")e+hod \oe::r:.sen\:.__1
l• -
D tb...e __ - -

a
y- o '(") o ("(") ·· L; 6'"'1: u--v
8•
- ii , ) Lbe n r ry el e v _o.-n.\:---~.s~-9-_e,._"
drsp\o~ed. 7"he -0-'oa~e,_sb.u.£-£-te.d d ..a.b.cL.J~
, te.-Y~t;ed O \J e--r. ~{s 'l ~cl~ s..~ L<:!21 on
--the cons.o \e.

Code ·,·

t'rnp.o-Yb \ beYb'oo\S> 1 -:x-onctoN1


~~ - d ~ C 'k -::. \ f S '.t, l ~ \;~"'( \:;o O \ S · f'YO do UC. t lx <::.n::'ls L _
(. \
1
C.' .Sf a ae' / )-\~O.'"l. t 1 / t); a 'C"()Q'("\ci l r C. \ ll.-'c::)_'ll
\ \ ) , 1

P'"'; n 'b t ,rlhe. c J?J."Y as O'"'< e. ~e, r,9 s 'nu f~u~~"~l) _


YOl'dON1. s hu~P.\ e l~~ - d.ec K J _
p.,,..f nb \. t1 CoYd s. o'Ye d aa.wn o ~ :1ra ncl 0 :co 2-) 1

o. 1cr-r1_. 11)
~) n \; '- \.ne.~ a.-r-e.. ;
~~ \ ~ ~ YCl n 5£... C.. 5 J •. ~
?'1r' 0 t l r-n B - c.\ e C. \s. C. ' '"J C. 0 'J > '"r C) f. l l ·1 '0-(:) ~...,,...,, d,_e C
c,:i c.,::1; -

pY,nb t<'r--\orr-,,e ~. Dr\<--s'n~ Mon~ So·-c\90.\e. . ~


Ro\\ No ·. '+ ~ 1' )
Thie c-ards a re bedng s huffled
Cards ar,IC! dra wn at random
They are :
6 of Club
5 of Clu.b
5 of Club
5 of Club
6 of Club
r~ame:Dik.sha Ma noj Sangal.e & Roll No: 46
..Sa.r1,9od e.. of KshO\ tvtqno j
Ro\ l No·. 4-6

,s1os \ 2.., PRF\c ,:r..cA L- 4-B

o
~ O
.n t m·. - W"'tf, ce. o. f '"T'Otj'1S""C\ m .Po~
C
cons t.--Y-a \ n cs.
.S 6 \:,, f'C\ C \"' 0'() r--r--o\:, \~X'<) ·

7he.o- :rj : , ) !:'\- ct,u. ee. ns p'.To'c\ era '(s tbe:_ p'YO'o \~m
o+ o.--Y"' to.~~;n ~ .b~e ~-Q.ue .~S)S DO .on t:i~ t-\.
c\,i~Ss'o oqtiS ct ~~ su.c..,h o. w...a. ~ -:rnq \:- r.o -t- c..,..:,o
9J ..l~en s o._y-e. Ot'c--Y.c.(\5ed i0 -\-he ..s~e ~co,
¼e so.me.._ c..o\u ~n o'JS' d~Ofjc nol

Q - Q

Q -- . - --

"l:\)e. sa \~\'\on ~ s ·. _ _ _ - -~e sa\u\~_a_n _ )___§_ ~ __


C'2>l 1,2..., 4] - C 2.. I 4- 1 \ t-6 ___]_ - -

Cod.e :
~\o't) a\ t\
N ==- 4-
o\.e ~ ~"', n t So \ u 'ci o a C. b a o:-~ d J ·
Po1S , , \""\ ,:r.Clr.)~-€.. (__ N:) !
Poer j ~ ..-,"r0.n5e. C ~ ') ·.
11
F'o \r.. (~oo.crcl c,J CJ~ ry en-d -==- '' )

r , '1 't c_ )

deP ts s a~ e. C.'coa'15"ct \ ~w l c_o\ >~


~ O'"'Y j rn "'(- Cl "5.e._
J~ ( C.. 0 \

\-£- bOC\~ d C. ~UJ J c_; J ::: ~ \~


'Ye. '\:.uon f-C\, se.

focr i / _j 1 ~0 'Z.- ~ f (r-c:Q "ns €. L"'CT) UJ 1 -;_-l t - I ) ,1

!Y'C\YI S e Cc..o \ , -t , -\ .) _ :
---- ---
qC\T"\8~ \ e tJ, \'< ~°' MnY"I ~
Ro\\ "'Q· "- ' ~

Sa\ \J e. t-,.\Q t>


~ , n t· l (' t"--\ C\~ ' ~ t)~ \ZS\--i C\ M a:a ~ So_""' ~C\ \P ~~
Ro\\ 'N<'.:) •. L\S ,, )
□, r~ame: Diksha Pan cj San cal e & Rol l l~o ~ 46
8 0 l 0
1 a e e
0 8 0 1
e1 ea
Tru ~
sangale Dirsha Mane
Roll NO46
AI

2008 2 PRACTLCAL 5

Aim usite aomqzam bo demoost


Owes of Hano Problem

heory i y Tt is a cmothematical Puzze


where w e hoave thee rocds andndiskKs
is
iylhe objectives of the putzle
O move the entire stacK to anothe
rod,obeyinothe eollouoinqsimple ulB.
aOny one disk can be noved at a
Lime
b) Ee.och nove consists o takinq
the up per disk from one of the Stao ks
e a diskCan only be moved i f t is the
uppermost dis k on oqs tac ki
c) No diskm a y b e placedo n of
bop
a Smaller disk

Diaaami
3DiSK

8
Sangale, Di KSha Man AL

olosl2
Code
o f banoi disks SoUsCe auxillimy
COuuer
tarqet)
PCdfsks = 1)
bo
print(Move oisk 4 Prom nod i
Tod S3 fosmat ( s o u s c e t a r g e t ) .
yetUTD
touwex_ofhanoiLdisKs-1 soUrcetege

pmint
auxilliary)
Mov e dis k s 3 Pom d 3 o.
Pomat.Cdisks, source tavgeb
rod 2
touwero hanoi Colisks-I, auxi lliory1 SoUTCS
barget)

prinE(Name: Diksha Manoj Sangale Rol:


No:46")
disKs-int Gnput e n t e s h e number o f
disks " ) )
towe-of-hanoi (disrS A, *B'c')

Conclusion
i s S u c c e s s fully execuled.
The above Code
uSing Python.
Name:Diksha Manoj Sangale& Roll No: 46
Enter the number of disks: 3
Move disk 1 from rod A to rod C
Move disk 2 from rod A to rod B
Move disk 1 from rod C to rod B
Move disk 3 from rod A to rod C
Move disk 1 from rod B to rod A
Move disk 2 from rod B to rod C
Move disk 1 from rod A to rod C
AI
Sangale Dirsha Man
Roll Mo!46

aoo8la PRACTICAL 6
im i t e a prooaum to demonstate
AR Search Algorthim.

heory1i A * search is the mostCommnonly


knoun f o o o f best-fist search
i IE Usesheurisic Puncion h
and Cost to recch t h e noden
Prprathe
StorEstote
I Ax algorithm fs similar to use
excepE that Is uses qcn)+ hch) inskead
o fqCD)
iv) Tn A-k sea ch Plgorithm toe
use search heuristic as e l \ as h e
Cost ho each the node

Example.

Path
S-D B-C- G
Sangale DiKsha Mano edaAia stoeaA1
RDIl NO: 46

PRACTI CAL
Aim: Orite o pogrcmPorTrave ling
CALA saleSmaniproblemakASE).

aheoxyi Gtiveni-a.set of ciuies and


distance betuoeen every pair oE cilies
b eeroolemis to Pinactheshoste sE
possible rautehattists eveTY cíEy
exactly once a n a returns to the
StorEig poinEtanq.
- -

BTSPfour i n the qrqph fs 12--3-1


The costof the Fou is
lalloA

SOurCe Code

2fromSysimpor maxsizecialaas
From tertools inmport pezmutations.
V=4

de f travellinq Salesoanfrpblem(gaph ,s)


Nertex =C3
For iin range Cv)
F i=S:
vertex append (i)
min-eath = maxsize
nextpermutatioD =peTmutabion erLex)
Fox i i n next-pe7 Outotion
CurYeDt-paHhweight =O
K=9
Sangole Drksha MOno7 edie

JADITJAA

CUYTentzpothuweightHaraphCk
cno CurmenEpathuseiahb+-araph CKICSJ-

alaaminpath min(ninpahcimenE-
pathuoefobe)

rebumn minpathiS
F narme main "
9aph CCo,1o,15,203, Co,0, 35,253
Ci5 35, 0,203C2O25, 30,D31
S-O
print ATavellinoSalesmannoblem laraph,s)-
uadsdito.
psintName:DiKsha Manoj Sanaale 4 RollNO:
6)

Conclusfon:ihe above code2is success full


iexecuted ssing puthonszio
C Name:Diksha Manoj Sangale &Roll No: 46
sangate bikshq Manopmo P0
Roll Nou6

PRACTICAL- 3
Aim: Prove Associattve.lsaonaiaivhutive
La tw

heory 1) Prove Associalive tau with


TruEh-ba ble
aPAQ) AR= PALQR.

RPAR PAR)AE QARPaCOR)


T

T
P

2) Phrove DisErbutive tau oith


T t h Table
by PACQAR) = (PaQ) v (PAR)

PQR QRPaCQVR\LeAR)LPARFAO) v
(eAR)
T T T T T

T T T
T
T TT
T T
T
f P
ASangale Diksha Man AI
RolNO: 46

daHence proeveolt a e a
LHS = RHS

SOUYCe code

AssocíativeaLau
Prin Diksha Manojsangale RO NO: 462
priot ASsOcative law")
print ANDEA.C8)= (AB).C A.B.C"D
A =iotioput entera value fox A:"2)
8 =int linput e n t e r avalue f o B "))
C i n E ioput (enter a value ForC:")
LHS= A L8* C)
RHS= AXB)*C
RHS2- AXBx C
FCLHS= RHS 1LHS RHS2
pTinELHS= LHS
printRHS= RHS1)
priob EAssocíative Lot is pmved For
AND

Distibutie tacoa
A iatiopat ("enter arvolue for A: "))
8 - n (input Center a value For B " )
c int tinputenter Ovalue For c )
LHSsA*l8tc)
RHS CAXB)t(A*C)
iecLAs =RHS)
print Distribulive o u is erove a"
printDiksha Manoj sanqale Roll No3 46
Concusion The above codeis successfulty
execubed usíng Python
Name:Diksha Manoj Sangale &Roll No: 46
Associattive Law
AND A.(BC) =(AB).C A. B.C
Enter a value for A: 5
Enter a value for B 6
Enter a value for C 4
LHS 12
RHS
120
Associative Law is proved for AND
Enter a value for A: 5
Enter avalue for B6
Enter avalue for C:4
Distributive Law is proved
Name:Diksha Manoj Sangale &Roll No: 46

You might also like