







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








.init() - ANSdeclare which attributes each instance of the class should have .ipynb - ANSThe .ipynb file extension stands for "Interactive PythonNotebook". It is a file format used by Jupyter Notebook to store andshare documents that contain live code, equations, visualizations, andnarrative text. .py files - ANSThe Files with the .py extension contain the Python sourcecode. ** Exponent - ANSRaises a number to a power // Integer division: - ANSDivides one number by another and gives the result as int % Remainder - ANSDivides one number by another and gives the remainder A value-returning function: - ANS• Executes the statements it contains, and then it returns a value back to the statement that called it.
An anonymous (lambda) function definition: - ANSlambda parameter list: statements lambda x, y: x + y Argument: - ANSa piece of data that is sent into a function
continue - ANSSkip the rest of the statements and jump to the next iteration. Design an algorithm to place, in an empty chessboard (8x8), 8 Queens, so that no two queens threaten each other. Include a flowchart and pseudo- code for this situation - ANSThe algorithm starts by placing a queen on the first column, then it proceeds to the next column and places a queen in the first safe row of that column. If the algorithm reaches the 8th column and all queens are placed in a safe position, it prints the board and returns true.If the algorithm is unable to place a queen in a safe position in a certain column, it backtracks to the previous column and tries a different row. The "isSafe" function checks if it is safe to place a queen on a certain row and column by checking if there are any queens in the same row, diagonal or anti-diagonal. It's worth to notice that this is just a high-level pseudocode and it might need to be adapted depending on the specific implementation and language you are using. dynamic-type programming language - ANSVariable assigned to one type can be reassigned to another type ie int -> float Every instruction (line of code) will take one second, how much time will take to execute the myFunction(10) for the following code? def myFunction(n) i= while i Exception ValueError - ANSRaised when an operation or function receives an argument that has the right type but an inappropriate value Explain Why Big O Notation is relevant for a big dataset, and it is not so relevant if you have a small set of data (for example, less than 1000) - ANSScaling with Input Size: Big O Notation primarily focuses on how an algorithm's performance scales with the size of the input data. In other words, it tells you how the algorithm's runtime increases as the dataset becomes larger. For small datasets, the differences in runtime between algorithms with different time complexities might not be noticeable or significant. When you have a small dataset, the actual runtime of even a less efficient algorithm might be fast enough for practical purposes. Therefore, the need for detailed analysis of time complexity is less critical when the dataset is small. when dealing with big datasets (often referred to as "big data"), the differences in algorithm efficiency become much more pronounced. Even small improvements in algorithmic efficiency (e.g., moving from O(n^2) to O(n log n)) can lead to substantial reductions in runtime, which is crucial for processing and analyzing massive amounts of data efficiently. Find the time complexity for a given code - ANSBig O notation, often denoted as O(), is a way to describe the upper bound or worst-case time complexity of an algorithm in computer science. It provides a theoretical analysis of how the runtime of an algorithm grows in relation to the size of its input. float - ANSfloat: a numeric value has decimal points flow chart process - ANScomputations performed , square boy
Identifiers of Variables - ANSVariables have identifiers - their names.
Merge Sort - ANSMerge sort has two parts: divide and merge. Divide: A list will be divided into sublists until they are sorted by themselves (one element per list). Merge: Then sublists will be merged to be a sorted list until there is only one list. Time Complexity: O(n*log 2n) Modules: - ANSfiles that store functions of the standard library
Keep doing this until the last element; we have a list [x m1, x m2, x m3,... x mn ], and it is sorted. Time Complexity: O(n^2) Standard library: - ANSlibrary of pre-written functions that comes withPython store end time - ANSimport time end = time.time() store starting time - ANSimport time begin = time.time() Strength of Python (Why we use Python) - ANSSmaller code length, More friendly to beginners, Extensive libraries (packages), Best for Data Science! string - ANSIt is a sequence of characters The benefits of using functions include: - ANS• Simpler code