BWCha

csmc12 2nd exam review

Apr 10th, 2025
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.45 KB | None | 0 0
  1. *Function - Block of organized, reusable code that's used to perform a single related action
  2. def fxnName(formalParameters):
  3. functionBody
  4. *Function Call - An expression, and like all expressions, it has a value (The value returned by the invoked function)
  5. >Some Built-In Functions in Python:
  6. *abs(x) - Returns the absolute value of a number
  7. *int(x), float(x), bool(x) - Converts to a value to a specific type
  8. *chr(x) - Returns a character based on a Unicode number
  9. >Advantages of Using Functions:
  10. 1. It avoids redundancy.
  11. 2. It encourages reusability.
  12. 3. It improves readability.
  13. 4. It helps manage complexity.
  14. >Good Programming Style w/ Functions:
  15. 1. Use predefined functions when available.
  16. 2. Use appropriate parameters for your functions
  17. 3. Use only local variables for your functions to make them as self-contained as possible.
  18.  
  19. *Data Structure - Particular way of organizing and storing data
  20. >Sequence Data Types:
  21. *Strings - A string of characters
  22. *Indexing - Can be used to extract individual characters from a string
  23. *Slicing - Used to extract substrings of arbitrary length s[start:end]
  24. *Lists - Ordered sequences of elements and its elements can be any type
  25. *List Comprehension - Provides a concise way to create lists
  26.  
  27. >Abstract Data Types - A mathematical model for certain class of data structures that have similar behavior
  28. *Queue - Policy: First in, first out
  29. - Additions at the rear only, deletions at the front only
  30. >Some Queue Uses:
  31. *CPU Scheduling
  32. *Disk Scheduling
  33. *Traversing Graphs
  34. *Stack - Policy: Last in, first out
  35. *Top=of-stack - Additions and deletions are done only at one end
  36. >Some Stack Uses:
  37. *Syntax Parsing
  38. *Expression Evaluation
  39. *Functiona
  40. *Trees - Collection whose entries have a hierarchical organization
  41. >Some Tree Uses:
  42. *Syntax Parsing
  43. *Databases
  44. *File Systems
  45. *Graphs - A representation of a set of objects where some objects are connected
  46. >Some Graph Uses:
  47. *Networks
  48. *Routing
  49. *Data organization
  50.  
  51. SEARCHING
  52. *Linear Searching - Used when the relationship or order of the elements in the list are unknown
  53. *Binary Searching
  54.  
  55. SORTING
  56. *Selection Sort - Main idea is to iteratively find the smallest value
  57. - Two Parts: Sorted and Unsorted
  58. - The algorithm finds the smallest value in the unsorted part and puts it at the end of the sorted part
  59. *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