1/14
15 vocabulary flashcards covering matrix operations, module construction, geometry functions, and exception handling as presented in the Week 5 lecture notes.
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
Matrix
A two-dimensional array (list of lists) in which elements are arranged in rows and columns.
Square Matrix
A matrix with the same number of rows and columns (e.g., 3 × 3).
print_matrix( )
Helper function that iterates through each row of a matrix and prints the elements joined by spaces.
Matrix Addition
Element-wise summing of two matrices of identical dimensions, producing a new matrix where each entry is the sum of corresponding entries.
add_matrices( )
User-defined Python function that adds two square matrices by looping through indices i, j and storing sums in a result matrix.
Matrix Multiplication
Operation that multiplies two matrices by taking the dot product of rows of the first matrix with columns of the second, producing a new matrix.
multiply_matrices( )
Custom Python function that performs square-matrix multiplication using triple-nested loops (i, j, k) to accumulate sum_product values.
Module (Python)
A file containing Python definitions and statements that can be imported and reused in other programs.
main
Special name set by Python; code under if name == 'main': runs only when the module is executed directly, not when imported.
math Module
Built-in Python library providing mathematical constants (e.g., pi) and functions such as sqrt().
circle_area( )
Geometry-module function that returns π × radius² using math.pi.
triangle_area( )
Function that computes a triangle’s area via Heron’s formula using the semi-perimeter s = (a + b + c)/2.
Exception Handling
Mechanism for catching and responding to runtime errors with try, except, else, and finally blocks.
try-except Block
Code structure that runs statements in try and executes except clauses if specified exceptions occur, preventing program crashes.
General-Purpose Exception (Exception)
Base class for all built-in, non-system-exit exceptions; catching it (except Exception as e) intercepts most runtime errors.