id
int64
0
25.6k
text
stringlengths
0
4.59k
13,400
reconstructing the shortest-path tree our pseudo-code description of dijkstra' algorithm in code fragment and our implementation in code fragment computes the value [ ]for each vertex vthat is the length of the shortest path from the source vertex to howeverthose forms of the algorithm do not explicitly compute the act...
13,401
minimum spanning trees suppose we wish to connect all the computers in new office building using the least amount of cable we can model this problem using an undirectedweighted graph whose vertices represent the computersand whose edges represent all the possible pairs (uvof computerswhere the weight (uvof edge (uvis e...
13,402
crucial fact about minimum spanning trees the two mst algorithms we discuss are based on the greedy methodwhich in this case depends crucially on the following fact (see figure belongs to minimum spanning tree min-weight "bridgeedge figure an illustration of the crucial fact about minimum spanning trees proposition let...
13,403
prim-jarnik algorithm in the prim-jarnik algorithmwe grow minimum spanning tree from single cluster starting from some "rootvertex the main idea is similar to that of dijkstra' algorithm we begin with some vertex sdefining the initial "cloudof vertices thenin each iterationwe choose minimum-weight edge (uv)connecting v...
13,404
analyzing the prim-jarnik algorithm the implementation issues for the prim-jarnik algorithm are similar to those for dijkstra' algorithmrelying on an adaptable priority queue (section we initially perform insertions into qlater perform extract-min operationsand may update total of priorities as part of the algorithm th...
13,405
bos ord ord jfk lax mia ( bos ord ord jfk lax bwi mia mia jfk dfw pvd sfo bwi dfw lax pvd bos sfo bwi ( jfk mia dfw pvd sfo bwi dfw lax pvd sfo bos ( ( bos bos ord ord jfk bwi lax pvd jfk sfo dfw dfw lax sfo pvd bwi mia (imia (jfigure an illustration of the prim-jarnik mst algorithm (continued from figure
13,406
python implementation code fragment presents python implementation of the prim-jarnik algorithm the mst is returned as an unordered list of edges def mst primjarnik( ) """compute minimum spanning tree of weighted graph return list of edges that comprise the mst (in arbitrary order "" ={ [vis bound on distance to tree t...
13,407
kruskal' algorithm in this sectionwe introduce kruskal' algorithm for constructing minimum spanning tree while the prim-jarnik algorithm builds the mst by growing single tree until it spans the graphkruskal' algorithm maintains forest of clustersrepeatedly merging pairs of clusters until single cluster spans the graph ...
13,408
bos ord lax mia ( bos ord jfk bwi lax mia bos ord ord jfk bwi mia dfw lax pvd jfk sfo dfw lax pvd bos ( sfo bwi ( mia jfk dfw pvd sfo dfw lax pvd bos ord bwi (asfo mia jfk dfw pvd sfo bwi dfw lax ord jfk sfo pvd bos bwi mia ( ( figure example of an execution of kruskal' mst algorithm on graph with integer weights we sh...
13,409
bos bos ord lax bwi mia ( bos bos ord pvd jfk ord lax mia bos ord jfk bwi mia ( dfw lax pvd jfk sfo dfw lax pvd bos ord ( sfo bwi ( jfk mia dfw pvd sfo bwi dfw lax (gsfo jfk mia dfw pvd sfo bwi dfw lax ord jfk sfo pvd bwi mia (lfigure an example of an execution of kruskal' mst algorithm rejected edges are shown dashed ...
13,410
bos bos ord jfk bwi lax pvd jfk sfo dfw dfw lax sfo ord pvd bwi mia mia ( (nfigure example of an execution of kruskal' mst algorithm (continuedthe edge considered in (nmerges the last two clusterswhich concludes this execution of kruskal' algorithm (continued from figure the running time of kruskal' algorithm there are...
13,411
python implementation code fragment presents python implementation of kruskal' algorithm as with our implementation of the prim-jarnik algorithmthe minimum spanning tree is returned in the form of list of edges as consequence of kruskal' algorithmthose edges will be reported in nondecreasing order of their weights our ...
13,412
disjoint partitions and union-find structures in this sectionwe consider data structure for managing partition of elements into collection of disjoint sets our initial motivation is in support of kruskal' minimum spanning tree algorithmin which forest of disjoint trees is maintainedwith occasional merging of neighborin...
13,413
figure sequence-based implementation of partition consisting of three groupsa { } { }and { sizeand inserting them in the sequence with larger size each time we take position from the smaller group and insert it into the larger group bwe update the group reference for that position to now point to hencethe operation uni...
13,414
tree-based partition implementation an alternative data structure for representing partition uses collection of trees to store the elementswhere each tree is associated with different group (see figure in particularwe implement each tree with linked data structure whose nodes are themselves the group position objects w...
13,415
at firstthis implementation may seem to be no better than the sequence-based data structurebut we add the following two simple heuristics to make it run faster union-by-sizewith each position pstore the number of elements in the subtree rooted at in union operationmake the root of the smaller group become child of the ...
13,416
class partition """union-find structure for maintaining disjoint sets "" nested position class class positionslots _container _element _size _parent def init (selfcontainere) """create new position that is the leader of its own group ""reference to partition instance self container container self element self size conv...
13,417
exercises for help with exercisesplease visit the sitewww wiley com/college/goodrich reinforcement - draw simple undirected graph that has vertices edgesand connected components - if is simple undirected graph with vertices and connected componentswhat is the largest number of edges it might haver- draw an adjacency ma...
13,418
- explain why the dfs traversal runs in ( time on an -vertex simple graph that is represented with the adjacency matrix structure - in order to verify that all of its nontree edges are back edgesredraw the graph from figure so that the dfs tree edges are drawn with solid lines and oriented downwardas in standard portra...
13,419
- compute topological ordering for the directed graph drawn with solid edges in figure - bob loves foreign languages and wants to plan his course schedule for the following years he is interested in the following nine language coursesla la la la la la la la and la the course prerequisites arela (nonela la la (nonela la...
13,420
- describe the meaning of the graphical conventions used in figure illustrating dfs traversal what do the line thicknesses signifywhat do the arrows signifyhow about dashed linesr- repeat exercise - for figure that illustrates directed dfs traversal - repeat exercise - for figure that illustrates bfs traversal - repeat...
13,421
graph algorithms - our solution to reporting path from to in code fragment could be made more efficient in practice if the dfs process ended as soon as is discovered describe how to modify our code base to implement this optimization - let be an undirected graph with vertices and edges describe an ( )-time algorithm fo...
13,422
with vertices and edges is - an euler tour of directed graph exactly once according to its direction cycle that traverses each edge of such tour always exists if is connected and the in-degree equals the describe an ( )-time algorithm for out-degree of each vertex in finding an euler tour of such directed graph - compa...
13,423
graph algorithms be weighted directed graph with vertices design variation - let of floyd-warshall' algorithm for computing the lengths of the shortest paths from each vertex to every other vertex in ( time - design an efficient algorithm for finding longest directed path from specify the vertex to vertex of an acyclic...
13,424
- an old mst methodcalled baruvka' algorithmworks as follows on graph having vertices and edges with distinct weightslet be subgraph of initially containing just the vertices in while has fewer than edges do for each connected component ci of do find the lowest-weight edge (uvin with in ci and not in ci add (uvto (unle...
13,425
graph algorithms - suppose you are given timetablewhich consists ofa set of airportsand for each airport in aa minimum connecting time (aa set of flightsand the followingfor each flight in forigin airport in destination airport in departure time arrival time describe an efficient algorithm for the flight scheduling pro...
13,426
pointer (recall that the parent pointer of the root points to itself if this pass changed the value of any position' parent pointerthen she repeats this processand goes on repeating this process until she makes scan through that does not change any position' parent value show that karen' algorithm is correct and analyz...
13,427
- write program that builds the routing tables for the nodes in computer networkbased on shortest-path routingwhere path distance is measured by hop countthat isthe number of edges in path the input for this problem is the connectivity information for all the nodes in the networkas in the following example which indica...
13,428
memory management and -trees contents memory management memory allocation garbage collection additional memory used by the python interpreter memory hierarchies and caching memory systems caching strategies external searching and -trees ( ,btrees -trees external-memory sorting multiway merging exercises
13,429
our study of data structures thus far has focused primarily upon the efficiency of computationsas measured by the number of primitive operations that are executed on central processing unit (cpuin practicethe performance of computer system is also greatly impacted by the management of the computer' memory systems in ou...
13,430
memory allocation with pythonall objects are stored in pool of memoryknown as the memory heap or python heap (which should not be confused with the "heapdata structure presented in when command such as widgetis executedassuming widget is the name of classa new instance of the class is created and stored somewhere withi...
13,431
memory management and -trees if this list were maintained as priority queue (in each algorithmthe requested amount of memory is subtracted from the chosen memory hole and the leftover part of that hole is returned to the free list although it might sound good at firstthe best-fit algorithm tends to produce the worst ex...
13,432
reference counts within the state of every python object is an integer known as its reference count this is the count of how many references to the object exist anywhere in the system every time reference is assigned to this objectits reference count is incrementedand every time one of those references is reassigned to...
13,433
memory management and -trees the mark-sweep algorithm in the mark-sweep garbage collection algorithmwe associate "markbit with each object that identifies whether that object is live when we determine at some point that garbage collection is neededwe suspend all other activity and clear the mark bits of all the objects...
13,434
additional memory used by the python interpreter we have discussedin section how the python interpreter allocates memory for objects within memory heap howeverthis is not the only memory that is used when executing python program in this sectionwe discuss some other important uses of memory the run-time call stack stac...
13,435
that interestinglyearly programming languagessuch as cobol and fortrandid not originally use call stacks to implement function calls but because of the elegance and efficiency that recursion allowsalmost all modern programming languages utilize call stack for function callsincluding the current versions of classic lang...
13,436
memory hierarchies and caching with the increased use of computing in societysoftware applications must manage extremely large data sets such applications include the processing of online financial transactionsthe organization and maintenance of databasesand analyses of customerspurchasing histories and preferences the...
13,437
memory management and -trees caching strategies the significance of the memory hierarchy on the performance of program depends greatly upon the size of the problem we are trying to solve and the physical characteristics of the computer system oftenthe bottleneck occurs between two levels of the memory hierarchy--the on...
13,438
caching and blocking another justification for the memory-access equality assumption is that operating system designers have developed general mechanisms that allow most memory accesses to be fast these mechanisms are based on two important locality-ofreference properties that most software possessestemporal localityif...
13,439
block on disk block in the external memory address space figure blocks in external memory when implemented with caching and blockingvirtual memory often allows us to perceive secondary-level memory as being faster than it really is there is still problemhowever primary-level memory is much smaller than secondarylevel m...
13,440
page replacement algorithms some of the better-known page replacement policies include the following (see figure )first-infirst-out (fifo)evict the page that has been in the cache the longestthat isthe page that was transferred to the cache furthest in the past least recently used (lru)evict the page whose last request...
13,441
memory management and -trees the fifo strategy is quite simple to implementas it only requires queue to store references to the pages in the cache pages are enqueued in when they are referenced by browserand then are brought into the cache when page needs to be evictedthe computer simply performs dequeue operation on t...
13,442
external searching and -trees consider the problem of maintaining large collection of items that does not fit in main memorysuch as typical database in this contextwe refer to the secondarymemory blocks as disk blocks likewisewe refer to the transfer of block between secondary memory and primary memory as disk transfer...
13,443
( ,btrees to reduce the number of external-memory accesses when searchingwe can represent our map using multiway search tree (section this approach gives rise to generalization of the ( tree data structure known as the (abtree an (abtree is multiway search tree such that each node has between and children and stores be...
13,444
search and update operations we recall that in multiway search tree each node of holds secondary structure ( )which is itself map (section if is an (abtreethen (vstores at most entries let (bdenote the time for performing search in mapm(vthe search algorithm in an (abtree is exactly like the one for multiway search tre...
13,445
-trees version of the (abtree data structurewhich is the best-known method for maintaining map in external memoryis called the " -tree (see figure -tree of order is an (abtree with / and since we discussed the standard map query and update methods for (abtrees abovewe restrict our discussion here to the / complexity of...
13,446
external-memory sorting in addition to data structuressuch as mapsthat need to be implemented in external memorythere are many algorithms that must also operate on input sets that are too large to fit entirely into internal memory in this casethe objective is to solve the algorithmic problem using as few block transfer...
13,447
multiway merging in standard merge-sort (section )the merge process combines two sorted sequences into one by repeatedly taking the smaller of the items at the front of the two respective lists in -way mergewe repeatedly find the smallest among the items at the front of the sequences and place it as the next element of...
13,448
exercises for help with exercisesplease visit the sitewww wiley com/college/goodrich reinforcement - julia just bought new computer that uses -bit integers to address memory cells argue why julia will never in her life be able to upgrade the main memory of her computer so that it is the maximum-size possibleassuming th...
13,449
memory management and -trees - describe an external-memory data structure to implement the queue adt so that the total number of disk transfers needed to process sequence of enqueue and dequeue operations is ( /bc- describe an external-memory version of the positionallist adt (section )with block size bsuch that an ite...
13,450
- consider the page caching strategy based on the least frequently used (lfurulewhere the page in the cache that has been accessed the least often is the one that is evicted when new page is requested if there are tieslfu evicts the least frequently used page that has been in the cache the longest show that there is se...
13,451
character strings in python string is sequence of characters that come from some alphabet in pythonthe built-in str class represents strings based upon the unicode international character seta -bit character encoding that covers most written languages unicode is an extension of the -bit ascii character set that include...
13,452
constructing related strings strings in python are immutableso none of their methods modify an existing string instance howevermany methods return newly constructed string that is closely related to an existing one table provides summary of such methodsincluding those that replace given pattern with anotherthat vary th...
13,453
calling syntax startswith(patterns endswith(patterns isspaces isalphas islowers isuppers isdigits isdecimals isnumerics isalnum description return true if pattern is prefix of string return true if pattern is suffix of string return true if all characters of nonempty string are whitespace return true if all characters ...
13,454
the other methods discussed in table serve dual purpose to joinas they begin with string and produce sequence of substrings based upon given delimiter for examplethe call red and green and blue splitand produces the result red green blue if no delimiter (or noneis specifiedsplit uses whitespace as delimiterthusred and ...
13,455
useful mathematical facts in this appendix we give several useful mathematical facts we begin with some combinatorial definitions and facts logarithms and exponents the logarithm function is defined as logb if bc the following identities hold for logarithms and exponents logb ac logb logb logb / logb logb logb ac logb ...
13,456
in additionx ** ln( xx there are number of useful inequalities relating to these functions (which derive from these definitionsproposition if - <ln( < + ex proposition for < <ex < - proposition for any two positive real numbers and <ex < + / integer functions and relations the "floorand "ceilingfunctions are defined re...
13,457
proposition if < <nthen nk <<kk proposition (stirling' approximation) ( pn where (nis ( / the fibonacci progression is numeric progression such that and fn fn- fn- for > proposition if fn is defined by the fibonacci progressionthen fn is th( )where ( )/ is the so-called golden ratio summations there are number of usefu...
13,458
proposition if > is an integer constantthen ik is th(nk+ = another common summation is the geometric sumni= ai for any fixed real number  proposition an+ ai = for any real number  proposition ai = for any real number there is also combination of the two common formscalled the linear exponential summationwhich has the...
13,459
example consider an experiment that consists of flipping coin until it comes up heads this sample space is infinitewith each outcome being sequence of tails followed by single flip that comes up headsfor probability space is sample space together with probability function pr that maps subsets of to real numbers in the ...
13,460
proposition (the linearity of expectation)let and be two random variables and let be number then ( + ( ( and (cx ce( example let be random variable that assigns the outcome of the roll of two fair dice to the sum of the number of dots showing then ( justificationto justify this claimlet and be random variables correspo...
13,461
useful mathematical techniques to compare the growth rates of different functionsit is sometimes helpful to apply the following rule proposition ( 'hopital' rule)if we have limnf (nand we have limng( +then limnf ( )/ (nlimnf ( )/ ( )where (nand (nrespectively denote the derivatives of (nand (nin deriving an upper or lo...
13,462
[ abelsong sussmanand sussmanstructure and interpretation of computer programs cambridgemamit press nd ed [ adel'son-vel'skii and landis"an algorithm for the organization of information,doklady akademii nauk sssrvol pp - english translation in soviet math dokl - [ aggarwal and vitter"the input/output complexity of sort...
13,463
[ boyer and moore" fast string searching algorithm,communications of the acmvol no pp - [ brassard"crusade for better notation,sigact newsvol no pp [ buddan introduction to object-oriented programming readingmaaddisonwesley [ burgerj goodmanand sohi"memory systems,in the computer science and engineering handbook ( tuck...
13,464
bibliography [ gammar helmr johnsonand vlissidesdesign patternselements of reusable object-oriented software readingmaaddison-wesley [ goldberg and robsonsmalltalk- the language readingmaaddisonwesley [ goldwasser and letscherobject-oriented programming in python upper saddle rivernjprentice hall [ gonnet and baeza-yat...
13,465
[ knuth"big omicron and big omega and big theta,in sigact newsvol pp - [ knuthfundamental algorithmsvol of the art of computer programming readingmaaddison-wesley rd ed [ knuthsorting and searchingvol of the art of computer programming readingmaaddison-wesley nd ed [ knuthj morrisjr and pratt"fast pattern matching in s...
13,466
bibliography [ prim"shortest connection networks and some generalizations,bell syst tech vol pp - [ pugh"skip listsa probabilistic alternative to balanced trees,commun acmvol no pp - [ sametthe design and analysis of spatial data structures readingmaaddison-wesley [ schaffer and sedgewick"the analysis of heapsort,journ...
13,467
character operator operator - operator operator operator operator operator +operator operator -operator operator /operator - operator <operator <operator operator =operator operator >operator >operator operator abs add - and bool - call contains delitem eq float floordiv ge getitem gt hash iadd imul init int invert ior...
13,468
abc module abelsonhal abs function abstract base class - abstract data typev deque - graph - map - partition - positional list - priority queue queue sorted map stack - tree - abstraction - (abtree - access frequency accessors activation record actual parameter acyclic graph adaptability adaptable priority queue - adap...
13,469
insertion removal - rotation trinode restructuring binary tree - array-based representation - complete full improper level linked structure - proper binaryeulertour class - binarytree class - binomial expansion bipartite graph bitwise operators boochgrady bool class boolean expressions bootstrapping boyerrobert boyer-m...
13,470
cormenthomas counter class cpu crc cards creditcard class - - crochemoremaxime cryptography - ctypes module cubic function cyber-dollar - - cycle directed cyclic-shift hash code - dagsee directed acyclic graph data packets data structure dawsonmichael debugging decision tree decorate-sort-undecorate design pattern decr...
13,471
element uniqueness problem - elif keyword empty exception class encapsulation encryption endpoints eoferror escape character euclidean norm euler tour of graph euler tour tree traversal - eulertour class - event except statement - exception - catching - raising - exception class expected value exponential function - - ...
13,472
directed acyclic - strongly connected mixed reachability - shortest paths simple traversal - undirected weighted - greedy method guibasleonidas guttagjohn harmonic number hash code - cyclic-shift - polynomial hash function hash table - clustering collision collision resolution - double hashing linear probing quadratic ...
13,473
kargerdavid karprichard keyboardinterrupt keyerror keyword parameter kleinphilip kleinbergjon knuthdonald knuth-morris-pratt algorithm - kosarajus rao kruskal' algorithm - kruskaljoseph 'hopital' rule landisevgenii langstonmichael last-infirst-out (lifo) lazy evaluation lcssee longest common subsequence leaves lecroqth...
13,474
benjamin baka works as software developer and has over yearsexperience in programming he is graduate of kwame nkrumah university of science and technology and member of the linux accra user group notable in his language toolset are cc++javapythonand ruby he has huge interest in algorithms and finds them good intellectu...
13,475
david julian has over years of experience as an it educator and consultant he has worked on diverse range of projectsincluding assisting with the design of machine learning system used to optimize agricultural crop production in controlled environments and numerous backend web development and data analysis projects he ...
13,476
for support files and downloads related to your bookplease visit www packtpub com did you know that packt offers ebook versions of every book publishedwith pdf and epub files availableyou can upgrade to the ebook version at www packtpub com and as print book customeryou are entitled to discount on the ebook copy get in...
13,477
thanks for purchasing this packt book at packtquality is at the heart of our editorial process to help us improveplease leave us an honest review on this book' amazon page at if you' like to join our team of regular reviewersyou can -mail us at customerreviews@packtpub com we award our regular reviewers with free ebook...
13,478
preface python objectstypesand expressions understanding data structures and algorithms python for data the python environment variables and expressions data encapsulation and properties summary python data types and structures variable scope flow control and iteration overview of data types and objects strings lists f...
13,479
collections deques chainmaps counter objects ordered dictionaries defaultdict named tuples arrays summary principles of algorithm design algorithm design paradigms recursion and backtracking backtracking divide and conquer long multiplication can we do bettera recursive approach runtime analysis asymptotic analysis big...
13,480
doubly linked list node doubly linked list append operation delete operation list search circular lists appending elements deleting an element iterating through circular list summary stacks and queues stacks stack implementation push operation pop operation peek bracket-matching application queues list-based queue enqu...
13,481
deleting nodes searching the tree tree traversal depth-first traversal in-order traversal and infix notation pre-order traversal and prefix notation post-order traversal and postfix notation breadth-first traversal benefits of binary search tree expression trees parsing reverse polish expression balancing trees heaps s...
13,482
inserting pop testing the heap selection algorithms summary searching linear search unordered linear search ordered linear search binary search interpolation search choosing search algorithm summary sorting sorting algorithms bubble sort insertion sort selection sort quick sort list partitioning pivot selection impleme...
13,483
logical serial or parallel deterministic versus nondeterministic algorithms classification by complexity complexity curves classification by design divide and conquer dynamic programming greedy algorithms technical implementation dynamic programming memoization tabulation the fibonacci series the memoization technique ...
13,484
bag of words prediction an unsupervised learning example -means algorithm prediction data visualization bar chart multiple bar charts box plot pie chart bubble chart summary index vii
13,485
knowledge of data structures and the algorithms that bring them to life is the key to building successful data applications with this knowledgewe have powerful way to unlock the secrets buried in large amounts of data this skill is becoming more important in data-saturated worldwhere the amount of data being produced d...
13,486
what this book covers python objectstypesand expressionsintroduces you to the basic types and objects of python we will give an overview of the language featuresexecution environmentand programming styles we will also review the common programming techniques and language functionality python data types and structuresex...
13,487
searchingdiscusses the most common searching algorithms and gives examples of their use for various data structures searching data structure is fundamental task and there are number of approaches sortinglooks at the most common approaches to sorting this will include bubble sortinsertion sortand selection sort selectio...
13,488
conventions in this bookyou will find number of text styles that distinguish between different kinds of information here are some examples of these styles and an explanation of their meaning code words in textdatabase table namesfolder namesfilenamesfile extensionspathnamesdummy urlsuser inputand twitter handles are sh...
13,489
reader feedback feedback from our readers is always welcome let us know what you think about this book-what you liked or disliked reader feedback is important for us as it helps us develop titles that you will really get the most out of to send us general feedbacksimply -mail feedback@packtpub comand mention the book' ...
13,490
the code bundle for the book is also hosted on github at ishing/python-data-structures-and-algorithma we also have other code bundles from our rich catalog of books and videos available at ingcheck them outerrata although we have taken every care to ensure the accuracy of our contentmistakes do happen if you find mista...
13,491
python objectstypesand expressions python is the language of choice for many advanced data tasks for very good reason python is one of the easiest advanced programming languages to learn intuitive structures and semantics mean that for people who are not computer scientistsbut maybe biologistsstatisticiansor the direct...
13,492
understanding data structures and algorithms algorithms and data structures are the most fundamental concepts in computing they are the building blocks from which complex software is built having an understanding of these foundation concepts is hugely important in software design and this involves the following three c...
13,493
repeat for each vendor does the vendor have items on my list and is the cost less than predicted cost for the item if yesbuy and remove from listif nomove on to the next vendor if no more vendorsend this is simple iteratorwith decision and an action if we were to implement thiswe would need data structures to define bo...
13,494
python for data python has several built-in data structuresincluding listsdictionariesand setsthat we use to build customized objects in additionthere are number of internal librariessuch as collections and the math objectwhich allow us to create more advanced structures as well as perform calculations on those structu...
13,495
variables and expressions to translate real-world problem into one that can be solved by an algorithmthere are two interrelated tasks firstlyselect the variablesand secondlyfind the expressions that relate to these variables variables are labels attached to objectsthey are not the object itself they are not containers ...
13,496
variable scope it is important to understand the scoping rules of variables inside functions each time function executesa new local namespace is created this represents local environment that contains the names of the parameters and variables that are assigned by the function to resolve namespace when function is calle...
13,497
the ifelseand elif statements control the conditional execution of statements the general format is series of if and elif statements followed by final else statementx='oneif == print('false'elif == print('true'elseprint('something else'#prints 'something elsenote the use of the =operator to test for the same values thi...
13,498
all data types in python are objects in factpretty much everything is an object in pythonincluding modulesclassesand functionsas well as literals such as strings and integers each object in python has typea valueand an identity when we write greet "hello worldwe are creating an instance of string object with the value ...
13,499
the following table is list of some of the most commonly used string methods and their descriptionsmethods descriptions count(substring[start,end]counts the occurrences of substring with optional start and end parameters expandtabs([tabsize]replaces tabs with spaces find(substring[startend]returns the index of the firs...