About This Course

This website contains instructional content and programming lab assignments for Math 495R. Template files are provided for each lab (see Setting Up Google Colab), and completed files are uploaded to Gradescope for automatic grading. Assignments are due about once a week; see Canvas and the course syllabus for details and specific deadlines.

This page describes how to read the lab content and best practices for learning the material quickly and thoroughly.

Reading Lab Content

In addition to regular text, the lab pages have several special content boxes to help demonstrate concepts and point out important ideas.

Code Examples

Programming is usually best learned by example. The following boxes show Python code and the outputs that it produces.

# Code appears in these kinds of boxes.
print(1 + 2)

# The outputs appear below.
3
print("This is a cell that prints multiple things.")
print("Every use of print() shows up in the same output box.")
print(1 + 2 + 3 + 4 + 5 + 6)
This is a cell that prints multiple things.
Every use of print() shows up in the same output box.
21

The above code boxes give actual code outputs, but others only show code and do not provide the outputs.

# This is a code block without outputs.
print("This statement does not show up in a box below this cell.")

Some code boxes contain intentionally incorrect code to demonstrate potential pitfalls. These are followed by the error message generated by Python, outlined in red.

print(your_password)
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
Cell In[3], line 1
----> 1 print(your_password)

NameError: name 'your_password' is not defined

Exercises

Every lab has several exercises that describe the tasks that you must complete to earn points. Exercises are interspersed throughout the lab content and are repeated on an Exercises page at the end of the lab.

Problem X

The statement of an exercise appears here. Most often, this will be a description of a Python function to be implemented.

Test Cases

Many exercises come with test cases that show the expected outputs to a few sample commands.

code_to_execute(with_these_inputs)
Exact Code Outputs Here.

Admonitions

The following colored boxes are used to point out especially important information.

Attention

Warnings of high importance.

Warning

Warnings about common pitfalls and mistakes.

Important

Information about topics, assignments, and grading.

Tip

Tips and additional context that may be helpful.

Quick Check

Short questions to check comprehension and provide additional examples. Try to answer these questions without running any code or asking the Internet.

Quick Check questions are not graded.

Answer

The answer will appear here.

How to Succeed

The way you approach the labs affects how quickly and effectively you will learn the material.

Practice Makes Permanent

Learning to program is like learning to speak a foreign language. In addition to learning vocabulary and grammar, one must practice producing complete sentences unassisted. As you read through a lab, keep a Google Colab notebook open (different from the lab template) and type the example code yourself. Doing this instead of just reading or using copy-paste will help the programming grammar sink in. Experiment often by making small tweaks to the example code and observing the resulting changes.

Read Sequentially

Every part of the lab material is important. Take your time and resist the temptation to skip ahead. You will almost always complete assignments faster if you work patiently and sequentially through all of the material than if you try to skip straight to the exercises.

Test Everything

Most exercises come with test cases. Run the included test cases and additional test cases of your own making where appropriate. This is a much faster way to find most problems than waiting for the autograder on Gradescope to fail and provide feedback.

Write Comments

Comments are parts of code that are not executed. The main purpose of a comment is to describe to the programmer what the code near the comment is supposed to be doing. Even though comments do not affect the behavior of a program, descriptive comments are extremely important for readable code. Without comments, the human programmer must interpret code using only the syntax of the programming language; with comments, a programmer can see the intention, design, and nuances of a piece of code. Get in the habit now of writing informative comments for every few lines of code. This will help you organize your thoughts as you design a program and help you pick up where you left off after a break. Think of comments as a gift to your future self.

Embrace Struggle

Programming requires a lot of thinking, trial, and error. Solutions seldom come immediately. Give yourself sufficient time to try to work out problems yourself before turning to outside help. Finding solutions on your own is significantly better for your learning than surviving on a stream of hints. A good rule of thumb is to only get help when you’ve been stuck on the same issue for about 10 minutes.

Where to Get Help

Real learning requires doing the work yourself. However, we all get stuck from time to time, and there are several good ways to get help without compromising your learning or integrity.

Work with a Friend First

When possible, work with a teaching assistant or a classmate instead of relying on Internet-based resources. The following are examples of good ways to collaborate with other students.

  • Strategizing together about how to solve a problem or design a solution.

  • Explaining why a piece of code is or isn’t working as intended.

  • Giving a hint to point a friend in the right direction.

  • Sharing useful functions or syntax with each other (“did you know that reversed() does this?”)

Make Learning your Shared Goal

Work together with friends in a way that promotes learning for everyone involved.

  • If you explain something to a friend, make them explain it back to you; if a friend explains something to you, make them listen to you explain it back to them.

  • Lead your friend to discover solutions for themselves; don’t let an eager friend rob you of your own discoveries.

Cheating

The following are examples of inappropriate collaboration and are considered cheating.

  • Revealing a complete problem solution to another student.

  • Sending code files to another student.

  • Typing another student’s code for them.

Always type your own code.

Work Wisely with the Internet

When friends and teaching assistants are unavailable, the Internet can be a helpful resource. On the other hand, the Internet has much more information than you need for this class, and it can be hard to narrow down a search to just what you need. Try to stick to resources that relate directly to the course material, such as the following.

Avoid websites for asking and answering software questions. These are aimed toward professionals, not new programmers, and are more likely to confuse than help.

Cheating

Copying code from Internet sources is considered cheating. Always type your own code.

Because most search engines (like Google) now have AI capabilities, search engines must be treated like AI tools and used in accordance with the following policy.

Avoid Generative AI

Because this is an introductory class, generative AI tools like ChatGPT, Gemini, Claude, or search engines with AI summaries (including Google) can be detrimental to your learning. Just as knowing how to use Google Translate does not make you a native French speaker, knowing how to use ChatGPT does not make you a good Python programmer. Generative AI tools can be extremely helpful as programming assistants, but only to programmers who already have a firm understanding of the basics. Generative AI is therefore off limits in this course except in the following approved ways.

  • Context. “I’m learning about <Python or linear algebra concept>, please provide a few examples and explanations. Why is it important?”

  • Practice. “I just learned about <Python or linear algebra concept>, please give me a short practice problem that requires me to use that concept.”

  • Errors. “I have the following Python error message. Tell me what it means but not how to fix it.”

Never use code in an AI prompt, and never copy code from an AI response. For example, to ask about an error message, only type in the error message, not the code that generated it. Consider the following example.

x = [3, 1, 4, 1, 5, 9, 2]
print(x[9])
---------------------------------------------------------------------------
IndexError                                Traceback (most recent call last)
Cell In[4], line 2
      1 x = [3, 1, 4, 1, 5, 9, 2]
----> 2 print(x[9])

IndexError: list index out of range

An acceptable AI prompt in this case is “What does IndexError: list index out of range mean in Python? What triggers this error?” An inappropriate AI prompt could be “the following code results in an IndexError. Why?” and then providing the actual code.

Cheating

Using AI for anything other than the exceptions listed above is considered cheating.

When in doubt, don’t use AI! You will be a more effective programmer and be better prepared to unlock the potential of AI if you first legitimately learn the basics on your own or with human help.