Docsity

Python Complete notes, Study notes of Computer science

Partial preview of the text

Download Python Complete notes and more Study notes Computer science in PDF only on Docsity!

Page No. ; Tirltoduchion 40. Python 41 What is. python 2 12. Fechtves. if ate 13 Applications oF python 4 and {15 First python pragram __|Modules, Comment and Pip 124 Modules in puthon — 12:2 Comments in python 183. What ig a pip? 2 a Variables Data Types keywords t Operators 8:1 Variables in python | 841 Identifier in puthon —|32 Data Tipes in pulhon on rds. in 24 Opal “ on | ‘Usk, Dictionay. sek. Tipe }. Tipe Conversion a 14 Dictionary, 143 get | a Alle, G4 0-20 a\- 25 457 ly iCmcoivercioneme Flow rrtrol 5-1_1f- statement 52 Th-elge olakement = 53 elif clatement 5-4 Nested if statement Loops €-{_While loop Pers 6-2 For Loop 6° For loa sing_ran eO Fincion 64 Nested i la ~ am ae i oq i i Shing” a a and i fig 1:4 Deleting the. a SEA job sg =, ee _ Si-No | 2. -r chaptens Advanced data stuclures Ra Lists 2-2 sels 183 Dictionaries R-4 Shacks and queues (Using Lists) Funchional Progtammin B-l Map, Filler and “reduce 8-2 Lambda and Anonymous Functions Working with files and directories '4-1 File Yo Operations (Binary Files) 14-2 Directory Manipulation : 4-3 Working with" Osv and JSON Files Requlay Expressions HIB Inhodaction to regular Expression 15-2 Pattern modtching with re’ module, 15-3 Gmmon regular Expression Patterns Web development with agthon I6-| Peadihcn to web development 16-2 Building simple Web Applications with Flask and Sjargo Data Analysis and Visualization I7-1 NumPy and Pandas for Data manipuladion IT-2 Matp otlib and seaborn - Page Ne 62- &8 69-3 VE intl 82-84 &5-3l 92-Iol h elannmate F q (e-—Ie) ~ se No chapter Page. No. ) | 18) |Machine learning andl Al ne | 8-1 Intoduchion’ 4o machine learning = ; | 182 Using libraries like scikit- learn | !&-(lo a. dnd Tensor Flow Pe allan! e LL 183 Simple, Machine. learning example | Large standard Library: Puthon provides d_ vose ctandard libraay with ready— to-use SA aud functions for various Jacks. Saving dev dlvers time and effort in implementing cammon_ Functionalities. } Object - Oriented Programmnin (oop) :- = Python supparks the tes - oriented praqramming paradignn , alleaitiag or the ete dnd manipulaian of abjecks Classes and inheritance - | = Cross=Plal-Fare ee Pulbon is available. on multinle \atforms including Windams macs and Linux , making tr bighly portable ona) versatile . an Third - Party Libraries ‘= Puthan has a vast ecasustem of third- party libraries “ond framewirkee thar expand its | capabi ies invel Perent domains, such as web developmen dale dnalusis , andere dine Aerial J Y) Toterpreted Nature i Pythan is_an_ interpreted language meaning it does not require compilakon This edule ine: feel es clevelopment cide aa code! can he exerutad direcHy without tthe peed aera -sepeate compilation step: Thhearotian Capmbilities + Python can easily inleqate with other lanquages like C, CH dnd Java,allowing developers | to leverage existing codebases and _libravies: | plications OF Python U | 1.3 A Hl Python is widely used in various domains and_offers numerous applications que 4a _iks Flexibility edse af ( use Here are some key dreas where python finds Q a . pmenk ack such _as Django and Flask dips Framewo- tks Plovides ofPicien! tools and libtaries to build elynamic uekoles hee web apelicalians Data Ahalusis an Visualizotion t= Puthan's tich ecosystem of libraries including NumPy Pandas. dnd abplatlib pode it popular choice far data analysis and viewhlixation -T endbles professional. to Prcesk manipulate and visualize, data eflechiv vely: J Machine learning and AriPicial Intelligence Ke Puthan bas beco- me the do-+ languade, -for mat ine. leamina and Al Projedks.. —J iiidriesike Benson keras and scikit learn provide power ! ful toole tor implementing complex algorithms and ining, madels- Automation and Scripting: Python's easy = bo read syntax and rapid evebpme Efe wae ake We antidea|wehateds foe cl eae commonly used for muy tasks such as file manipultion data parsing dnd_aylem admi Tak tation: [4 Pathon Installation = download and install Python | Fallon these steps classmate Date Pa —$— ff Printing Hello Ward using puthan Prin ("Hello World | ") let's break down the cade! The pint() Rinction is seed to display the specified massage or_value on the cansale- gt * Th this case. we pass the ishring "Hello World |" an argument to the rintt) funclian: The shing Is Sileed id dite. quictes -The_4# | cum bal indica ee a comment in Pulhan - Comments. are ignore by the interpreter and are. teed tp pravide exolainalions “ar een hee 4h classmate Dete et SS dks. Comment Pip —— Cm a 1 = LL c= ad “K12) Modules {fo pathon! J eee organive your code. logically, ga instead of having all vow ode in a single fi e -yoct. ca “oplit ik inks muttiple modules based on their purlose - When uu want +4 use. the Functionality froth 4k module yon can import i+ into yout current program ac_anather Module. This_allows you to access and use funchions classes and variables debined bitin that madule you tite. tuna wuniting Aputtind cade. repeatedly and instead’ rouse the. onde debinsd in the module- 7Tiree_main tupes of modules : eupes. |__ Madules | i. a es I v Vv 1 Buill-in madules External Modules | User- defined Modules. ~__ 1) Built -in modules : a These _are_madules + classmate pie poorer a = = I (preter. pdb th a_comment rl ignores ik and maves on to the pert linas_of code.-Commentscan-be_placed — at the end of line_or_an_a_tine by. +hemeecl ves T's imporlank ty that co : readers and _are not executed bu the. Python interoreten: j “Therefore, they have. ho_impack on the program's Pinelisnality ~or_perfowmante - — lie E Ties of Commenks ' - J] ages Types of Commehrs t 1 Single-line Comment Mull: -line Comment — 1 Ginale -line. comments Single - line. comments are used tp add explainatary moles or _commienteran-a single. line! of colle They “Wart with a haeh sumbsl (+) and continue untill the end of the line. Any hing written after the hash .symbol_is considered a comment and is ignored by the. python Roose, Here's an ekanlph : # This is a single-line comment x =5 +t Assigning a value +o the yariahb = Q- Mulli-line Comments : _— :s Mulli-line comments also known as black cam- : 2 ments, allow you to add comments that sarm multiple §. lines - Python daes_not have a fill-in suntax spect '- x | Hienlle far multi-line comments, but ou can aéheive Mis buy using tiple quates (either single or_couble) to create a Sind thal js not assigned +o any variable -Since it ts not used elsewhere. in the cole it acts asa comment - Here's an example: GUTS te mulli—line. comment - TE cayn_span acmss multiple lines and is endosed within tiple — : tte —— Ka if Assigning a value to the variable x - i T&S What is o pip 2 Th simple terms pip is a package managel ingall Puthon f for _puthon- TE sands for" rip Inctalls Packages” or" Pip When workina ciith python ,you mau need to use extern | libraries: arnoduled that ptavide additional Funclionalities | betiond what the ctandard | libvaru_abbers.Tbese libraries | are_ctten developed by he puthon | nmnaunite and _are [availble Pw dnuone to use. | Pip makes Vit esky to ingtall a ackage, Manage and _unins+al) these external libra leg: ba pots ~ classmate Dete Page a. U : 3+{ Variables in Puthon Th Prthon. variables are used to store values that can be used Saler in a progtam You can think of variables as containers that! bald data. Whe! makes python unique ie +hat uow dan't need to explicitly dleclay tupe of a variable. You_simplu assign a_value to a Yu aa | vatidble using the "= tem loy - Foy example , you mn ee Pe aiianlet called “name” ancl assign it a value Like his : hame =" Yadnyesh” Here."name” ie the variable. name, and 'Yadnyesh" is | the valve. assigned to th Puthon will cudamaHoalig delerm. ipe the +upe “oP variable. based on the valye Gasigned J = | Variables in Python can hale diferent -upes of data such ll Sis |_as numbers jetings liske oy even more, complex obieds. [ You_can change Bie sachs a a_Variable al any a iy clasemate Page a qge=25 aqe=26 se Upel tng the value of age variable. Python also_allowe vou +o exform aperctions on variable: For example. , you Lan ai _ subst ct -toulti ply ar_divide Vdridhles bontaining brie! Aenean geen eambine- variables of dipleient types using operators _For_inshanee x ) 8 Woy y X= xt +H The value of ‘x’ will be 8. greeting ="Hello” = Name = "John" Message = greeting + ""+name # The value of message suillube, "Holly John" Variables pavide a way to slore and manipulate dala in phan’ makingsvk easier tn workountthloinhaes ‘mation fhYoughput ‘your’ program By giving meanings [ if | pames to Varinbles you_ciin make yout cade more_readable and “understandable” classmate (jm Hete_ dre some_examples af valid idenbifiets_in_pythan — * tu_variable ae * count + total sum |: Pl | * Muclass i ‘An here dre. some. examples of invalid identifiers : * 123 abe (sharts with a digit) a variable( cantains c- bipen) (a_teseived ward) : ay var ( contaips a space) Understanding and Tallawing these, rulas for idenlitiers ih Python is_imbortank to ensure. clanty, reddability “and _praper Sindlisling of uour code: rt = = 3:2 Dota Types in Python Data types in Puthan refer to the, di Ferent | kinds of values thet jan be. “assigned to _variabl Pen a Theu_delermine +the nelure of the data and the ‘ | opetations thet can be performed _on -them - = | | Puthon provides several ee cata types, including : numeric dictionaiy, Boolean, act , and numeric has Integer Comple and Sequence Type ae Shing List and Tuple.- SOW juence types classmate Date Page Numeric Integer Dictionary Comples Number] amen) IMioron Boolean ca ~ python Data eoecd | Types et ia Shing Sequence Jupe. Ligt ] =| Tuple 4: Numeric ‘ I Puthon ssupparts different oumerioal deter tapes i induding esc rage ap ipeipe (decimal numbers). and comp ex numbers (numbers with | peal and imaginary arts) | a: -Inleoers inf): Ineqérs represert whole numbers without any Ailsa | pact For example, age =25. liye Floating-point Numbeys (Float) : Floati 1g = aint numbers represent numbers rit deciaia) haiti Fractone- Fo example (=3-[4. C- Cymplex Numbers (“Comblex) ! Complex numbers have | q_teal_and imaginayy fo) ex: Z= ata | where ul is eek min A.