Type: Individual Assignment

Due: by 10:00 PM on Tuesday, January 8, 2019

Part 1: Background and Logistics

  1. Read the course syllabus and familiarize yourself with the course schedule.
  2. Complete the background questionnaire.
  3. Do the assigned Reading 1 for 1/9 and post at least one question/comment you have about it to the corresponding forum on Moodle. Note that you will need to do this for each assigned reading on the course schedule for the whole term.

Part 2: Getting Started with the Terminal

To introduce you to the Terminal application (a Unix-like environment), there is a tutorial for you to work through before the second class meeting.

  1. Open a web browser and navigate to the UNIX Tutorial for Beginners website.
  2. Work through each of the following sections of the tutorial:
    • Typographical Conventions,
    • Introduction to the UNIX Operating System, and
    • Tutorials 1–4.

I recommend that you complete the tutorials on one of the lab machines in the Terminal app. (Remember that you need boot into the Mac OSX instead of Windows!)

There’s nothing to hand in for this part, but it is important that you complete these tutorials. I also reserve the right to randomly call on you and ask you questions about the commands on Wednesday!

Part 3: Parts of Algorithms

Introduction

Every algorithm consists of various parts and can often be thought of as a recipe. These parts are summarized below:

  • Basic values are the basic building blocks that can be used in an algorithm. In Python, we will be using numeric values (e.g. 1, 2, 3) and textual values (e.g. “Harry Potter”) a lot, but we will see many others. In the context of a literal recipe, the values might be different food products or ingredients (e.g. flour and sugar).
  • Basic operations are simple tasks that can always be performed. For example, addition and multiplication are basic operations on numeric values. Every programming language has basic operations built-in to the language, and we will learn them over time.
  • Sequencing is the order in which operations are performed to complete the algorithm correctly. When following a recipe, it is often important to complete certain operations before others, or when computing the average of two numbers, you must add them before you divide by two.
  • Variables are named values. These are important since we often want to refer to a specific object by a shorter name. For example, we might have the swim times for three different swimmers and need to name them time1, time2, and time3. Later we might compute the average time and name that value time_avg.
  • Conditionals enable us to make decisions that depend on context. For example, you might need to include special cases if a value is equal to zero or handle a special scenario of a recipe depending on which ingredient you chose to use.
  • Repetition is when you need to perform an operation repeatedly until some condition is satisfied. For example, if you are computing the average of 100 different swim times, you will need to repeatedly add all 100 numbers together before completing the average by dividing.
  • Subroutines are named helper algorithms. We also sometimes refer to these as “procedures” or “functions”.
  • Inputs are values that are “passed into” the algorithm. For example, you might write an algorithm to add two numbers together. In order to execute the algorithm, you must provide two numbers to be added—these are the inputs to your algorithm. Inputs can be provided in many ways. We will initially ask the user of our program for inputs when needed, but they can also be provided from another file, a website, etc.
    • NOTE: Inputs to an algorithm almost always have an associated name and are therefore also considered variables. However, it is common to use helper variables that are NOT inputs. (e.g. naming the sum of two numeric inputs my_sum, etc.)
  • Outputs are what the algorithm produces as a final product. How the output is presented by the program can vary. When working with the Python interpreter, we will often print the output to the screen so that the user can read it. Later we will see other approaches like writing to a file or showing an image.

Analyzing a Recipe

We talked in class that algorithms are akin to recipes, and we will explore that relationship in more detail in this part of the assignment. Your task is to do the following.

  1. Find an interesting recipe and cite it.
  2. For that recipe, list its variables and identify which of them are inputs to the recipe. Give a brief explanation.
  3. For each input, list any implicit or explicit limitations on it. For example, if you say that “flour” is an input for your recipe, must the flour be wheat flour, or will rice flour do?
  4. For that recipe, indicate any situations in which repetition and conditionals are used. (If neither repetition nor conditionals are used, indicate how the recipe might be extended to include repetition or conditionals.)
  5. For that recipe, indicate what basic operations or subroutines the author assumes that the reader already knows how to do.
  6. Most recipes are written for “average” cooks. Either rewrite the algorithm for a beginning cook or write a detailed set of instructions for one of the “assumed knowledge” subroutines of the algorithm.

Email your answers above to tklinge+recipe@carleton.edu. (The extra “+recipe” in the email address causes your email to automatically be filtered out of my inbox into an appropriate label. Thus, I wont see your emails until I start grading them after the deadline.)

Acknowledgments
The last part of this assignment was inspired by an assignment written by Titus Klinge and Samuel Rebelsky at Grinnell College.