Assignment 0: Getting Started with Python

Introduction

In this course, you will continue to develop the programming skills you began building in ICS 31, with an ever-sharpening focus on solving larger, more complex problems at a level of quality that edges closer to work done by professionals. While the projects we’ll work on this quarter might be simple for someone who has years of prior experience, we will nonetheless attack these problems with the same approach that a professional software engineer might. We’ll consider each problem in its full depth, think about how to work on it incrementally, spend some time testing our solution to ensure that it works correctly, and make sure that we’ve got the little details correct and not just the big ideas. Larger programs that solve real-world problems succeed or fail on being completely correct, and even a one-character mistake in input or output can sometimes make all the difference, so we need to get accustomed to that level of scrutiny, so that we can apply it when it is warranted.

Note

This first assignment is adapted directly from Alex Thornton’s previous version of this course. Alex has done an excellent job of writing up the installation process and first steps required to get started with python. So rather than reinvent the wheel, I will ask that you follow his instructions here.

This assignment will consist of two parts:

  1. Set up your development environment, so you will be ready to work on your assignments this quarter.

  2. Write a short program and submit it, to ensure that you’re aware of the mechanisms of the course — how to write short Python programs, how to submit your work — and so you can become acclimated to how automated testing will be used to grade at least some of your work this quarter.

Setting up your development environment

It is very common in real-world software development jobs to be given, at the outset of a new job, a list of tools that you will be required to use. Flexibility is great, and it’s nice to be able to choose one’s own toolset, but, unfortunately, many software tools introduce constraints on how a program can be written, how its components can be arranged, what functions can be called, what documentation can be written and how, what additional software it can be combined with, how it can be “built” to be distributed to end users, and so on. So, like it or not, real-world software development usually requires at least some of the tools to be set in stone and used by all members of a team, even if not all members have the same preferences; this is simply a reality that software developers have to face.

Since we will be poking our heads into a fair number of darker “real-world” corners in this course, it becomes necessary for us to agree on the set of development tools that we’ll use. Not only will it be important to agree on the right tools, but it will be important to agree to use the right versions of those tools, as each differs in not-insignificant ways. One goal of this assignment is to introduce you to those tools, provide instructions on how to install and configure them on your own machines, and get you ready to use them for your work this quarter.

Writing a short program

This assignment will also require you to write and submit a short program. Unlike most of our assignments, we’re less concerned about how you solve the problem than we normally will be. There are no points for what we call “quality of solution,” meaning that issues like style, organization of your program, and so on, are not relevant on this assignment. All that matters is that the program works, but that is a very precise requirement: The output of your program has to be correct to the character to receive full credit. Paying attention to the exact requirements, then, will be paramount.

The ICS 32 development environment

The development environment for this course may seem quite familiar if you took ICS 31 recently. As a standard, we will use the IDLE environment that is included with Python. However, we will be using a particular version of Python (3.10.1) and certain configuration that was less important previously will become more important to us this quarter. So rather than installing the tools yourself, I’d like each of you to follow these instructions, even if you think there is a better way to do it; this way, everyone is on an equal footing, and later needs you may not be aware of — if, for example, we start installing and using third-party libraries — will be met.

Note that Python 3.10.1 was released in October 2021, and that’s the version you’ll want to obtain for your use this quarter. It’s fine, in principle, to use anything greater than 3.8.0 instead, if you’ve already got it installed — I wouldn’t expect there to be any differences that are all that meaningful to us, though it is possible that 3.10.1 will have fixed a bug or two that affects us, so you might still consider upgrading. If you have a version older than 3.8.0, you’ll definitely need to upgrade, though, as there are some differences that will potentially affect your work this quarter.

What do I do to get things set up?

Assuming that you will be wanting to do at least some of your work on your own machine, how you prepare your environment depends on what operating system you’re running on your machine.

Installing and Configuring the ICS 32 Development Environment on Windows

Installing and Configuring the ICS 32 Development Environment on macOS

Once you’re done following the installation instructions for your chosen operating system, you’re ready to proceed with your work in this course, beginning with this assignment.

The program

Your program is required to read a single line of input from the user (without printing any input prompt), which is expected to be a positive integer n (i.e., n will be neither zero nor negative). You can freely assume that your program will be given a positive integer, and it’s not important what you do in any other case; we’ll only test your program with positive integer input. You can also freely assume that n will not be greater than 999.

After reading the input, your program will print a downward block diagonal of size n. The precise format of a downward block diagonal is best demonstrated with an example. If the input to the program was 4, the output would look like this:

+-+
| |
+-+-+
  | |
  +-+-+
    | |
    +-+-+
      | | 
      +-+

A few additional requirements apply:

  • Though I’ve indented the text above to set it apart from the rest of the project write-up, note that the left edge of the topmost block must begin in the leftmost column of the output (i.e., it should not be indented at all).

  • There must be no whitespace (e.g., spaces or tabs) at the end of each line of output.

  • There must be a newline on the end of each line, including the last one.

This is a complete specification of the structure of a downward block diagonal; the description is enough to solve the problem, so we will not be answering any additional questions about its structure. However, we are providing a tool that will give you a basic understanding of whether your program is reading the correct input and generating output in the correct format.

Naming and organizational requirements

How you organize your program is, for the most part, up to you, with a couple of requirements that you’ll need to follow.

Your program must be written entirely in a single Python module, in a file named a0.py. Note that capitalization and spacing are important here (i.e., no letters in the filename are capitalized and there are no spaces); they’re part of the requirement.

Executing your a0 module — by, for example, pressing F5 or selecting Run Module from the Run menu in IDLE — must cause your program to read its input and then print its output. It must not be necessary to call a function manually to make your program run.

Other than that, anything goes; you can organize your solution in any way you’d like. Note that future assignments will take what we call “quality of solution” a lot more seriously, but the name of the game in this warm-up assignment is simply to submit a program that works.

Validity-checking your output

We are also providing a tool that you can use to check whether you’ve followed the basic requirements above. It will only give you a “passing” result in these circumstances:

You’ve named your file a0.py. Executing that module is enough to execute your program. Your program reads its input and generates character-by-character correct input for one test scenario.

Note that additional test inputs will be used when we grade your assignment. The way to understand the validity checker’s output is to think of it this way: Just because the validity checker says your program passes doesn’t mean it’s perfect, but if you cannot get the validity checker to report that your program passes, it surely will not pass all of our automated tests.

Running the validity checker is simple. Just ensure that the validity checker file is in the same directory as your a0.py file. Running the a0_validitycheck.py module — for example, by loading it in IDLE and pressing F5 (or selecting Run Module from the Run menu) — will run the validity checker and report a result, which will be printed to the Python shell.

Starter Project

To keep the naming and validity checking requirements simple, you will start by creating a code repository on GitHub Classroom.

Assignment 0 Starter Repository

Git and GitHub

Git is the most prevalent version control software today. Git and GitHub are different products! Git is freely-available open source software, GitHub is a popular hosting service for Git projects that includes many social networking and collaboration features.

Most Git repositories are managed from your favorite terminal. GitHub provides some resources for picking up Git. The cheatsheet can be a particularly useful reference.

GitHub also provides desktop apps for managing Git repositories on macOS and Windows. These have the classic advantages and disadvantages of interfaces. The desktop apps have a much shallower learning curve and make completing simple tasks easier, but lack expressivity for the more advanced Git and GitHub features. You’re welcome to choose either a desktop app or the terminal in this class.

The desktop apps automatically install Git. It’s also possible to install Git on its own, such as with the Debian package manager on Linux or via HomeBrew for Mac.

At a minimum you should create a GitHub account and make use of the starter code repository for each assignment. However, you are strongly encouraged to take some time to learn how to add, commit, and push your code back to your repository. If the thought of learning version control feels overwhelming right now, don’t worry, it should! We will discuss this topic and how to make use of version control in labs throughout the quarter. You will not be graded on your use of git or GitHub.

How we will grade your submission

Unlike other assignments, this assignment will be graded on a 50-point scale, with the 50 points being allocated completely to whether or not you submitted something that meets all of the above requirements. The following rubric will be used:

  • If all of our automated tests pass, you will receive 50 points.

  • If any of our automated tests pass (i.e., at least one of them passes, even if all the others fail), you will receive 45 points.

  • If none of our automated tests pass, but you did submit a file named a0.py, you will receive 25 points.

  • If you did not submit a file named a0.py, but you did submit a Python module in a file whose name ends in .py, you will receive 10 points.

  • If you did not submit a Python module at all, you will receive 0 points.