Assignment 1
Type: Individual Assignment
Due: by 10:00 PM on Wednesday, September 12, 2018
- Part 1: Background and Logistics
- Part 2: Getting Started with the Terminal
- Part 3: Parts of Algorithms
Part 1: Background and Logistics
- Read the course syllabus and familiarize yourself with the course schedule.
- Complete the background questionnaire.
- Enroll in the Piazza course, explore its features. We will be using Piazza for all Q&A not directly tied to the readings.
- Do the assigned Reading 1 for 9/12 and post at least one question you have about it to the corresponding folder
reading1on Piazza. Note that you will need to do this for each assigned reading on the course schedule for the whole term. You are also encouraged to post questions unrelated to readings (try to put them in an appropriate folder) and help answer questions posted by your classmates!
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.
- Open a web browser and navigate to the UNIX Tutorial for Beginners website.
- Work through each of the following sections of the tutorial: Typographical Conventions, Introduction to the UNIX Operating System, and Tutorials 1–4. There’s nothing to hand in, but please post questions/comments in the
assignment1folder on Piazza. We will be practicing using Unix in class on Wednesday.
Part 3: Parts of Algorithms
Introduction
Each 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 or 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, andtime3. Later we might compute the average time and name that valuetime-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.
- 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.
- Find an interesting recipe and include a citation for it.
- For that recipe, list the inputs and variables and give a brief explanation why you chose them.
- 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?
- 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.)
- For that recipe, indicate what basic operations or subroutines the recipe author assumes that the reader already knows how to do.
- 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 to parts 1–6 to tklinge@carleton.edu with the subject title [CS111]: Assignment 1.
- Acknowledgments
- The last part of this assignment was inspired by an assignment written by Titus Klinge and Samuel Rebelsky at Grinnell College.