Address
:
[go:
up one dir
,
main page
]
Include Form
Remove Scripts
Session Cookies
Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
30 views
18 pages
DocScanner 18 May 2023 12-40 PM
Uploaded by
prajwal pawar
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save DocScanner 18 May 2023 12-40 pm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
30 views
18 pages
DocScanner 18 May 2023 12-40 PM
Uploaded by
prajwal pawar
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save DocScanner 18 May 2023 12-40 pm For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 18
Search
Fullscreen
® fi ne . fy Practical No. 4 st[og 12023 » » ® © ® © © > OD) » ) | Python Insiatovion & configuration ailth usindowss Step1: Download -the Python Tnstallot Go 40 the Python website Chttps: |] www + python ong [download @ download -the [atest version of Python for windows. Step2: Run the Tasialler Once -the installer has finished douinloading, «un the installer by double-clfering on the downloaded File Slep3; Select Installation Options During the installation grocess, youl be paompted 40 select ' which installaufon opHort you want: Make sure fo select radd fython 4o PATH” so that you con ase Python fom the command tine | Step 4: Gompiete the Lasiallaton Click “Enstall Now" te complete the instalatron-This cll? install Pythen & any ae @mponents ante yous machine Step 5! Verify installaton Open the command gompt eg lype ‘python’ FF Python f= installed correctly, you should see the Python yension no displayed ja the owlpah- Congrotulations, you have succesctedly installed Python on your Ultndowe machine! >fograms for understand ing the daja types Data Types — Ye Numemc data types 7 Practfeal Mo. 2 : saledlaaes He Tntegers dala type: X= 10 paint ("Value oF x=", x, "Type oF x=", type (x) O1P=> value oF x =10, “Type oF x =(class ‘int') tt Float data +ype - y= 20-50 print (value oF ye y, "Type oF Y=", typecyy) ojp=> Volue OF Y=30-50, Type of Y= (cless ‘float!) + Complex daia type Comp = sot a0} prine(Value oF compe “snp, “Type of comp =", ayge ceo? . a U o]pey Value of compza0k20j Type oF comp conse eapeieg!) HE Sequence Data Types - aE Sting - str = mielcome 40 Python" pring ("Nalue of sire", str, "Type of sere", tape co) | ojp=> Yalue oF ste = "lerome to python Type oF s#eCclass ‘ stsing'> "=| . 1 contol Flow statements, blocks & (oops C3—— > Ltet WeGua = L'Python", "Sava" "poe | paint (Nalue of list listvaxType of List =" syge(listuas)) |p => tue iste L"Python”, ¥ op pe! Yalue of VetzL"Pyshon", "Tava", *Pup"] “Type of tisk =Celase'1'si) ae Tuple spuptevar = ("si8", "ghubh2”, "Mahi" ,Aakthu") print (‘Volue of xtupleuare =", 4aplenar “Types oF fupleuar: /xypeCtupleva) |o\p=> Yaiue oF tupleuare =(tsla”"shabha”, “poni®, “apshu") TSPS of tuplevay = (class ‘Juple!) ste Dichronaty gleuar = {Sham + +20, wgait, 5, 1271004 gaint (value oF atetvare" 5 aictuors, Tyee oF dictuas =", tyPe cAictvar) olp=> Nalue of dictuat 2 { "sham: 2, fe ae Type of dictuar =(class rdictonary’) A onlay savi" 3 2, oer, “TEPC oF gor eM ype cee) ele = ea Navi" 3 rare oF cet e(elass sek) rigid” Navi" 3 Tar Nolue oF PPro agua Fi 4p Boolea” 2Fue ' oo print Cuolve oraztartape oF o>? ayrece?) o\p=? + goolean') » or ae (class nade oi arrue 7spe w: LONUeUy Few CLUreMeNnts 1 . else 9 fe*Statement age=20 if age>=18; pint C'You ave an adult") elses pant ("You ave a minor") ©}p=> Nou are an adult- > '® For Joop: | numbews =0412,31415) | sum=zo > | for mum fa numbers * 1 sam t+snum w print ("The sum is 1", sam) \ | Op => The gum is tte \ © while loop : | count 20 : i yahite count <5 | int ("ThE esuae vs i, count) \ count +=! > a ® ® © ' | O|p => we ¢ | IP The count Is. 2 o | The count is sl \ The count 1s >> eo) ste count is +> PE The count \s:4 o oe oBreak Statement! u ‘/aumbers = 11,213, 4.57 for num in numbers: if num==3; break y printcnum) elp= . 1 2 ° @ © Cetinue statement : N=Cl,2, 8.415) © for num inn: ' ie ie num 223: continue © peinttnam) » olP » ' a oi 4 s ” 1 OFF statements zs | fer i in rangecn): ie 2 lig ise ) iptoa: Tain ml printciy > | opss 1 2 a \ PpPractical No. 3 ° “Programs fr understanding Functions, ° ga. Use of built in functions. s @sam - , number = [1.2, 3,4, 9) - +o tal = sam (number) j psint ("The sum of the number 1s." total) Output : © he sum of the numbers t's; 15 e @ count - Ccounting characters) *- > ” sentence -"Hello yorld | 3 2 count = len(sentence) » print ("The sentence has", count, "charvaciers .”) ‘ta 9 Output , 2 The sentence has t2 characters : @ @® absoluze Yolue 2 qum=-> > °. absvalue = abs (num) e paint ("The absolute value oF “youm "iss" abs valued 2 Ourpat = i ° The absolute value of -s 1525 2 © @® sesing conversion — j ° qamber 242 i stingenumbers = sty (numbet) 2 ® print (“The numbers as a Stsing Is." , sting_numbers) 4 output = : ‘ —the numbers as a string |S +42 A @®Meoximam value: 3 1 12, 10,18) values 31% maximurn = paxiwalues) point (The maximum vabue fs", maximum) ‘outpar TRE maximum valve 6.15User derined functions alcwlale area oF Circle: der civcleareo (radius) area = 3itq keredias #2 , . veturn avea 4 wadius =s é civeleq = civcle_avea (radius) pant ("The area of the cixcte fs. ", cirelearea) ° owpar > ° 4 5 The aveo of the civele {6 + 18-5 ° @ check Er a Number is Even | /° der eventnumber) = r if numberlo® return Tsue | elses | meiurn False ° nam=6 e@ | ir evencnum)! painecnum "is even nd ® ese nrcnum, “Is odd") 5 pant ( > ourput = © @ is even: © Sequence ® cateutale #rronecdl der ‘Fibonacci 6M): sequence =Lo1'J join range (2, 09% 2 sequence Lint Jk sea d cnext_num) Foe next-num ence Li-2T sequence .
Fe Fibonacci’ sequence", Hb sequence) Joutpur the Fibonacci sequence -L0,1 1 1213, 5, 8,13, atau @ Convert Celsius to Fahrenheit der fahrenheit Ccelgiug) > Fs celsius k a}5 430 wera £ temp. celsius = 25 -temp_f = fahrenheit Chemp-celsius) Point (remp-celsius, “degrees celsius is equal to”, Xemp_F "degrees Fohvenheit ,") Outpat = 25 degrees celsius is equal +0 770 degvees Fahrenheit © Reverse a string. cler weverseC str); sting 2 sta vreturn sysing text = "Hello, Shubhoz |" reverse text = amyorrse (text) print(’Revesded sting," severse_text) -y Outpar'- Reversed String | zzhbuhS ,olleH yw vdeo e 8 8 288 vvvuy ageoeeeeswss? Practical Noy ame fo use existing moduler, packages & Ccrecetng modules , packages: apa gram fo we enisting mModwes. mmport math impovt random te Using math module fa calculate the squay Yor OF a number umber = squengatot = math. sqvt Camber) PANEC'The square yoot oF", qumber! 1s1 "| square vot) te Using vanclom module to generate. a vandem no. be? Leo crandom_namber =-vandom.vondiat (1.10) Print ("Random namber:") aandom_namber) Serpe The square spot oF , 25 is. so Random number | Carandomly genenctecl no. bet? 1 eta), y.at Program fo woe existing package . import sequests de sending a GET sequet to URL response = request: get Cohteps: [api example com") print (" Respens © cocle 1" aesponse. statas_code) pint ("Response content", sesponse: tev) Gukpat = Response code :200 Pesponse content : (content csetarned by the APE)oe 8 09 @ G9 e687 FF HF He 8 ‘output > der sy bstract (a) b)- reiuTn a-b der Cmutiply (046): TRIUTN kb deF diuideca,b): ' seturn afb Import math operations wesult = marhopesaions add (513) \ PANE Additon ~esclt : ") sesalt) ! \ eres | = Math_opesaHons. substrack( lo , 3) print C" Sabsteaction +") qesalt) | sesult = math. opemattons. muttply (416) pane Multipifcation . ") result) eeyult = math operat! ons. dtuisoa (4, 3) pant’ Division 2M; wesc t) Addition Resalt 1 & SupstsacHon ; 7 Mestiplication: 24 Division; 3- as 2k ee or e ss 83 8 809 @ s s p Ger- derine package Packagetry der greet(namey: pant" Hellow,”, name) Packager -py der good bay Cnarne): print (" Goolkye,” Me) from my-packaige import pactugel, portage? packaged «greet ("“Shubhangi") package? good bye("Shuph22") ourpat Hello, Shubhongi Goodbye, Shubh2zEee ee Practical No. 5 i ig 4 a [et - Programs for implementatt’ ‘ons oF all object- ted / concepts like 7 2 class, method. % class deFination @ ~~ class Rectangle : der ~-init. (sete, length, width): sel f-|ength = length o self-Width = width | der get area(selF): | retutn self-length + self .width {| | der get pesimetem(sele) ; \ serum 2 & (see length 4 self-width) > We Creating objs @ calling Methods > 1 = Rectangle C4 16) 51 areas +1-gekared P = Tl. get persimeterst) ' >| | pant ("Rectangle 4.1) . print ("“Areo?! area) > pont ("Persimetes:", p) > 2 =Rectangle (2, 4) > area = 62-gebkareat) P= Tagek pesimeterc) > >! pant (Rectangle 2") ‘ | int (’Rren:” aren) pant ("Perimetres: ", P) >> > Jurpet - Rectangle 4 Area; oy Perimeter : 2.0 Rectangle 2 Area: 8 Peirmeters + 12 sa: Menu Driven Program to implements [nhesitame type dt Base class | class Animal + der —-init_-CselF, Name) + self name = name 1 der earcselt) + pant (" {sele-nam a is eattng-") der sleepcself): print’ {self-namet rs sleeping") ae Derived class using single inhemtance $ og (Animal) + der _-in't_ (self, Mame) ; -inft--(name) clas syperc:s der horkC self) ae print(” {sere name} Is parking") ese egerT- 0. -e ¥F@eriued class using multiple inhemtance class. Cat(Animaly der ~-Init_cserr,namey+ SUPErC).__init__¢namey det meow cer): print CZ sername? ig Meowting') ) FDersived class using mattileve inhentance class Lion (car) der __tntt_cserf- name); ) Super init__cname ) » def woay (self): ‘ PINE C$ seip-namez i's seosing "3 ) te Derived class wing hybrid inhesilance D class Tiger (Lion, Deg): : des —-init__¢serr, name): Saperc).__init__tname) > der grow! (self): : paint {" {sername} ts growling") > > te Desived class using theta hiesorchical i nhemtance > | lass elephant (Animal) y der --init. (self, name) - sqpor).—-init__ (name) , Aerumper(seley* . a, der print ("selfname? is tou mpeting e . °° ° @ ® ° e e“we &© & & ‘ SSE jee ~ dniven program def maine: while Tre: PAINE VAX Ye¥ Animal Proguerm AK) puntC's . Dog (single Lohesitance) ") point(s. Cat (Multiple Inheritance") pantc's. Lon ( mustilevel Lnhesitance)”) pant (4. Tiges( Hybstd Inhesitanee)") point ("S. Elephant ( Hiesarchicad Chhestance)") point("s. Exit |") ch cinput ("Enter your chov'ee: ") feces "299 deg-name -inpar ("Enter dog's name") d = Dog Ldog-name) d -ectkc) a. sleept) d batho elip cha = 2") eat_name = input C" Enter cat's name: ") ¢ = Cat (eal_name) ¢ -eate) ¢-sleepes ce MEOW ¢) alip choana"s name = input "Enter Lien's name:") 1 = Lion (Lhame) Leathe) Isle ep ©) {+ meoud<) 1+ Taree)aie ches qe tname = inpw ("Enter Hges's name :) t = Tiger (t_name) break cy tesleepO a bebavke) > tmeowo0 . o +. weary 2 t gnuwl > > elig chess" ¢ : ; > ename - input( "Enter Elephant's ndme: ) j e+ Elephant (e-name) dD erent © d 5 e sleep) 5 e: trumpek o r elip cha "e"s oO point Cexisting the progzam ") break e else? ; io pantt"Fovalld choice, please bry again." drEnter point +0 the progxm © is vante-. 2° __tnaine_" + man 0) D . > ® @ @2 > > 2 xe & Ani & Animal Program eK t Deg (single Enhestance) a Cat CMulsiple Sahetance) oy CMalHleve) Snheri tance) Tigks Citybwid cEnhesitance) = Elephant CHtesarschical Inhesi bance) o- exit Enter your chore : 2 Enters cotls name : lado tado is eating lado Ss sleeping rado is maosoind Ente your choice a Enter dog's name TTSmy —tamy is eating —Temy, ts sleeping —Teomy is baringJs Program fox implementation of polyme*phism. class Animal? det sound cseiry « pass class Dog Cnnimal) ; der sound cselF) t paint (" Woor}") class Cat¢ Animal) : e | i clef sound (self): e | paint ("Menw)") @ | class cowCanimnal) : ‘eo! dee sound(selr) : 1 paint C ool") e. i : der makesoundcanimal): oO! 1 animal.sound 0) eo; |e create instance» P| 4g: Pogo WF es > e+ Eat | cos Como 3 Ite Make sounds awning pollenoypintsm 7 gmake sound (4 a | matesound(e) | mate sound Cco) | | at | > Oates loo! > Meoul! Mool eoewewewe
You might also like
Python Practicals
PDF
No ratings yet
Python Practicals
158 pages
Python Assignment 3 Ans
PDF
No ratings yet
Python Assignment 3 Ans
19 pages
Beginner's Python Cheat Sheet
PDF
No ratings yet
Beginner's Python Cheat Sheet
12 pages
Python Imp
PDF
No ratings yet
Python Imp
77 pages
Python Practicals
PDF
No ratings yet
Python Practicals
158 pages
Python Handwritten Notes - 1 To 2
PDF
No ratings yet
Python Handwritten Notes - 1 To 2
36 pages
Python Record
PDF
No ratings yet
Python Record
20 pages
Python
PDF
No ratings yet
Python
232 pages
Python Journal
PDF
No ratings yet
Python Journal
25 pages
Python Cheat Sheet PDF
PDF
No ratings yet
Python Cheat Sheet PDF
26 pages
Complete Python Notes by Kaushal.p
PDF
No ratings yet
Complete Python Notes by Kaushal.p
77 pages
Python Sem2
PDF
No ratings yet
Python Sem2
16 pages
Python Practical 6-11
PDF
No ratings yet
Python Practical 6-11
15 pages
AI Practical File
PDF
No ratings yet
AI Practical File
17 pages
Python Practical Codes
PDF
No ratings yet
Python Practical Codes
15 pages
Python Cheat Sheet
PDF
No ratings yet
Python Cheat Sheet
7 pages
Computer Programming Project
PDF
No ratings yet
Computer Programming Project
17 pages
Class 12 Cs Practica
PDF
No ratings yet
Class 12 Cs Practica
53 pages
1696123699200
PDF
No ratings yet
1696123699200
73 pages
Python
PDF
No ratings yet
Python
17 pages
C Programming
PDF
No ratings yet
C Programming
26 pages
Python Cheat Sheet: by Via
PDF
No ratings yet
Python Cheat Sheet: by Via
4 pages
DocScanner 9 Jul 2024 10-39 Am
PDF
No ratings yet
DocScanner 9 Jul 2024 10-39 Am
17 pages
Python For You and Me
PDF
No ratings yet
Python For You and Me
173 pages
Python Handwritten Notes 1701013067
PDF
No ratings yet
Python Handwritten Notes 1701013067
73 pages
Python 22616 Solved Manual (Join AICTE Telegram)
PDF
No ratings yet
Python 22616 Solved Manual (Join AICTE Telegram)
76 pages
Elements of Python3 Programming For Mechanical Engineers
PDF
No ratings yet
Elements of Python3 Programming For Mechanical Engineers
47 pages
Python ? Handwritten Notes
PDF
No ratings yet
Python ? Handwritten Notes
73 pages
Python Imp Question
PDF
No ratings yet
Python Imp Question
17 pages
Python Unit1
PDF
No ratings yet
Python Unit1
39 pages
Python For Mathematics Students PDF
PDF
No ratings yet
Python For Mathematics Students PDF
115 pages
Python
PDF
No ratings yet
Python
31 pages
Chapter 4
PDF
No ratings yet
Chapter 4
18 pages
1696675027246
PDF
No ratings yet
1696675027246
77 pages
Python
PDF
No ratings yet
Python
13 pages
Python (Assignment 1) Shubh
PDF
No ratings yet
Python (Assignment 1) Shubh
12 pages
Python Practical
PDF
No ratings yet
Python Practical
20 pages
Cs Notes
PDF
No ratings yet
Cs Notes
28 pages
Python Notes
PDF
No ratings yet
Python Notes
25 pages
CSCI Final Cheat Sheet
PDF
No ratings yet
CSCI Final Cheat Sheet
14 pages
Python For Data Science (Slideshare)
PDF
No ratings yet
Python For Data Science (Slideshare)
54 pages
Python Alok
PDF
No ratings yet
Python Alok
23 pages
Python Unit 1
PDF
No ratings yet
Python Unit 1
17 pages
Python Question Bank
PDF
No ratings yet
Python Question Bank
13 pages
AKU PPS Pyq 2019
PDF
No ratings yet
AKU PPS Pyq 2019
11 pages
Full Speed Python PDF
PDF
No ratings yet
Full Speed Python PDF
39 pages
All Unit
PDF
No ratings yet
All Unit
7 pages
Python Assignment 2
PDF
No ratings yet
Python Assignment 2
12 pages
Name - Jai Ramteke Class - TYBBA (CA) Roll No - 50 Python Assignment 5 Set A
PDF
100% (1)
Name - Jai Ramteke Class - TYBBA (CA) Roll No - 50 Python Assignment 5 Set A
8 pages
Resumen Python
PDF
No ratings yet
Resumen Python
13 pages
Computer Science Practical Amit Bikram Mishra Class Xii Science A
PDF
No ratings yet
Computer Science Practical Amit Bikram Mishra Class Xii Science A
18 pages
Py QB
PDF
No ratings yet
Py QB
19 pages
CS018 - Python Lab Manual
PDF
No ratings yet
CS018 - Python Lab Manual
28 pages
Lab 2
PDF
No ratings yet
Lab 2
21 pages
Python 2022
PDF
No ratings yet
Python 2022
12 pages
Python
PDF
No ratings yet
Python
5 pages
Cheat Sheet
PDF
No ratings yet
Cheat Sheet
2 pages