\n",
""
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Recitation 2"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"We tested if a positive integer (or a range of integers) satisfies the Collatz conjecture (using \"while\" and \"for\" loops). \n",
"We discussed the basics of lists, the efficiency of list operations and how to efficiently concatenate a list to another. We also demonstrated list comprehension. \n",
"Finally, we discussed functions, short circuit evaluation and analyzed the efficiency of the functions we saw.\n",
"\n",
"#### Takeaways:\n",
"\n",
"\n",
"
Lists can be a highly modular and useful data structure. Make sure that you understand their functionality and also their limits (figuratively and literally).
\n",
"
Avoid using the + operator for extending a given list. Use += or list.extend() instead.\n",
"
Functions can be used in one another (max2 in max3_v3) and can be composed together.
\n",
"
When analyzing a function's performance, think about the input that will cause the largest amount of work and then measure how many operations the function does.
\n",
"
Using short circuit evaluation, if e.g. you have a long \"and\" condition, place the part that is most easy to compute first since if it is false, all other parts of the condition will not be computed.