Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- *Function - Block of organized, reusable code that's used to perform a single related action
- def fxnName(formalParameters):
- functionBody
- *Function Call - An expression, and like all expressions, it has a value (The value returned by the invoked function)
- >Some Built-In Functions in Python:
- *abs(x) - Returns the absolute value of a number
- *int(x), float(x), bool(x) - Converts to a value to a specific type
- *chr(x) - Returns a character based on a Unicode number
- >Advantages of Using Functions:
- 1. It avoids redundancy.
- 2. It encourages reusability.
- 3. It improves readability.
- 4. It helps manage complexity.
- >Good Programming Style w/ Functions:
- 1. Use predefined functions when available.
- 2. Use appropriate parameters for your functions
- 3. Use only local variables for your functions to make them as self-contained as possible.
- *Data Structure - Particular way of organizing and storing data
- >Sequence Data Types:
- *Strings - A string of characters
- *Indexing - Can be used to extract individual characters from a string
- *Slicing - Used to extract substrings of arbitrary length s[start:end]
- *Lists - Ordered sequences of elements and its elements can be any type
- *List Comprehension - Provides a concise way to create lists
- >Abstract Data Types - A mathematical model for certain class of data structures that have similar behavior
- *Queue - Policy: First in, first out
- - Additions at the rear only, deletions at the front only
- >Some Queue Uses:
- *CPU Scheduling
- *Disk Scheduling
- *Traversing Graphs
- *Stack - Policy: Last in, first out
- *Top=of-stack - Additions and deletions are done only at one end
- >Some Stack Uses:
- *Syntax Parsing
- *Expression Evaluation
- *Functiona
- *Trees - Collection whose entries have a hierarchical organization
- >Some Tree Uses:
- *Syntax Parsing
- *Databases
- *File Systems
- *Graphs - A representation of a set of objects where some objects are connected
- >Some Graph Uses:
- *Networks
- *Routing
- *Data organization
- SEARCHING
- *Linear Searching - Used when the relationship or order of the elements in the list are unknown
- *Binary Searching
- SORTING
- *Selection Sort - Main idea is to iteratively find the smallest value
- - Two Parts: Sorted and Unsorted
- - The algorithm finds the smallest value in the unsorted part and puts it at the end of the sorted part
- *Bubble Sort - Iteratively goes through the list, swapping item-pairs that are in the wrong order
Advertisement
Add Comment
Please, Sign In to add comment