Files
misc/python/atms-310/notebooks/MT1 Review.ipynb
2025-07-02 00:07:49 -07:00

230 lines
8.9 KiB
Plaintext
Executable File

{
"cells": [
{
"cell_type": "markdown",
"id": "1bf363de-ca7c-44a6-bd2f-4ca809666863",
"metadata": {
"tags": []
},
"source": [
"<h1>MIDTERM 1 REVIEW</h1>\n",
"\n",
"<h2>10/16/2023</h2>"
]
},
{
"cell_type": "markdown",
"id": "51a1ad77-a7f8-4438-a7da-f082e340f798",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Introduction to Python and Computer Architecture</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 01 W.pdf</h3>\n",
" \n",
"<h3><b>Class Date:</b> 09/27/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li>Programming is the act of writing an <b>algorithm</b> using a specific syntax to solve a problem.\n",
" <ul>\n",
" <li>A big part of programming is taking a problem apart into smaller pieces that can be understood by a computer\n",
" </ul>\n",
" <li>A computer's structure consists of:\n",
" <ul>\n",
" <li>Input and output devices\n",
" <li>A central processing unit composed of a control unit and an arithmetic/logic unit\n",
" <li>A memory unit"
]
},
{
"cell_type": "markdown",
"id": "e30ff5c5-2236-400b-9157-73a77cae261c",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Print, Calculator, Variable Types and Operators</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 01 F.ipynb</h3>\n",
" \n",
"<h3><b>Class Date:</b> 09/29/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li>An <b>integer</b> variable is a number with no decimal point\n",
" <li>A <b>floating point</b> variable is a number with a decimal point\n",
" <li>A <b>string</b> variable is text\n",
" <li>A <b>Boolean</b> variable can take on the values <b>True</b> and <b>False</b>\n",
" <li>A <b>NoneType</b>variable can take on the value <b>None</b>\n",
" <li>Python uses dynamic typing, which means you don't need to define a variable's type when you first use that variable\n",
" <li>The type() command lets you see what type a given variable is. int(), float(), and str() can be used to convert to different variable types\n",
" <li>Combining a float and an integer results in a float\n",
" <li>Combining a string and an integer or float results in a TypeError\n",
" <li>Floats are often prone to rounding errors\n",
" <li><b>and</b> and <b>or</b> can be used to combine Boolean variables"
]
},
{
"cell_type": "markdown",
"id": "c8dcb344-0708-4ba9-9ccb-df22e34edea2",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Lists and Dictionaries</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 02 M.ipynb</h3>\n",
" \n",
"<h3><b>Class Date:</b> 10/02/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li> A list is a <b>mutable</b>, <b>ordered</b> sequence of elements\n",
" <li> Python counts starting with 0, not 1\n",
" <li> You can also count backwards from the end of a list using negative numbers\n",
" <li> A list can be sliced, where the slice is defined by a range that has an inclusive lower bound and an exclusive upper bound\n",
" <li> Values in a list can be changed by assignment or by particular methods\n",
" <li> A tuple is an <b>immutable</b>, <b>ordered</b> sequence of elements\n",
" <li> A dictionary is a <b>mutable</b>, <b>unordered</b> sequence of elements consisting of key:value pairs"
]
},
{
"cell_type": "markdown",
"id": "0af5f1b7-48e9-4131-a331-5e35826a677a",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Functions and Logic</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 02 W.ipynb</h3>\n",
" \n",
"<h3><b>Class Date:</b> 10/04/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li> A <b>function</b> is a block of code that can be called\n",
" <li> Functions can be called using either positional or keyword arguments\n",
" <li> Positional arguments can be described via lists and keyword arguments can be desribed via dictionaries\n",
" <li> Python uses if statements for logical constructs\n",
" <li> The code within an <b>if</b> statement is run if the current statement is true\n",
" <li> The code within an <b>elif</b> statement applies if prior statements are not true <b>and</b> the current statement is true\n",
" <li> The code within an <b>else</b> statement applies if all prior statements are not true"
]
},
{
"cell_type": "markdown",
"id": "44c499c2-bab1-48be-8edc-c6c59a23659f",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Loops</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 02 F.ipynb</h3>\n",
" \n",
"<h3><b>Class Date:</b> 10/06/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li> A <b>for loop</b> lets you repeat an operation a specified number of times\n",
" <li> Indentation is critical for lists in Python\n",
" <li> The range() function will create a list of all values up to (but not including) the specified integer\n",
" <li> Hardcoding is the act of restricting a piece of code so it only works under specific circumstances (generally want to avoid this)\n",
" <li>A <b>while loop</b> lets you repeat an operation until a particular condition is met\n",
" <li>The index in a while loop must be initialized and care should be taken to avoid infinite loops"
]
},
{
"cell_type": "markdown",
"id": "7a2a73cf-6155-42d8-b792-7144f1821844",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Modules and Exception Handling</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 03 M.ipynb</h3>\n",
" \n",
"<h3><b>Class Date:</b> 10/09/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li>A <b>module</b> is a library of Python source code that gives access to new variables and functions\n",
" <li>Modules can be imported as whatever name you like\n",
" <li>A <b>raise</b> statement lets you define your own error conditions and stop code when they're met\n",
" <li>A <b>try/except</b> block will let you fix common issues that would otherwise result in exceptions"
]
},
{
"cell_type": "markdown",
"id": "1972b16e-0c87-482b-8e05-dd4c99b3c11c",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Arrays</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 02 W.ipynb</h3>\n",
" \n",
"<h3><b>Class Date:</b> 10/11/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li> An array is NumPy's version of a list, which allows you to work with matrices\n",
" <li> All elements of an array are of the same type\n",
" <li> You can either create a new array or convert an existing list into one\n",
" <li> The zeros() function is useful for initializing an array when you know the shape and size but not the contents\n",
" <li> The arange() function serves a similar purpose to the range() function with lists\n",
" <li> Similar to lists, arrays can be sliced, but arrays can also be sliced across each of their dimensions"
]
},
{
"cell_type": "markdown",
"id": "31e2ef42-a0ec-468a-8c53-189b314186ee",
"metadata": {},
"source": [
"<h3><b>Lecture Name:</b> Testing Inside Arrays</h3>\n",
" \n",
"<h3><b>File Name:</b> Week 03 F.ipynb</h3>\n",
" \n",
"<h3><b>Class Date:</b> 10/13/2023</h3>\n",
"\n",
"<b>Key Points:</b>\n",
"\n",
"<ul>\n",
" <li> You can use functions within NumPy to find the shape, number of dimensions, and number of elements in any array\n",
" <li> <b>numpy.where()</b> will let you find the locations of elements within an array that meet a specified criterion\n",
" <li> Some functions within NumPy allow you to manipulate arrays, such as reshaping, transpoing, unraveling, concatenation, and repeating individual array elements\n",
" <li> When you're in a situation with multiple nested loops, often you can instead perform all operations a lot more easily by using array syntax\n",
" <li> Mathematical operations act on arrays elementwise\n",
" <li> When testing within an array, <b>and</b> and <b>or</b> cannot be used; instead, use NumPy's built-in functions"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4d9362ec-b4ad-421d-8e13-74527bc19ede",
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 5
}