WARMUP

The game Tic-Tac-Toe (Noughts and Crosses, Xs and Os) has two players alternating turns marking their symbol on a 3x3 board, with winner being the player making the 3rd mark in a row.

Since this is the very first warmup, I will give you some hints about what to consider for your paper program:

When you do the warmups, you should NOT be writing Python code. Write English directions, but they need to be succinct and specific enough for a person that has never played the game to be able to “run” your program. You will be trading your pseudo-program with a classmate for critical evaluation.

HW Review

What did people have the most trouble figuring out? ask random

Programming

Thing big: what was this homework about? ask random

Key Python Ideas

Advanced Version

Create a hw3.py in your homework directory, which behaves like:

$ ./hw3.py
hello World!
$ ./hw3.py Carl Des
hello Carl and Des!
$ ./hw3.py Carl Des Ghana
hello Carl, Des and Ghana!
$ ./hw3.py Some Other Names Too
hello Some, Other, Names and Too!

When you have completed this, add it to your repository. You can’t use the turnin script for this, since it only updates existing files, so you’ll need to add the file:

$ git status
...output about your repository
$ git add hw3.py
$ git commit -m "add hw3 to repo"
$ git push

The tool git is for doing version control. This is very important for complicated projects, so we will be using it as part of the course. However, we won’t go into details very deeply, since it’s a lot of extra work for this level of coding. You can take this opportunity to familiarize yourself with the tool, however.

Project Advice

The project assignments both entail programs run from the command line and that receive arguments.

For the SEIR model, formatted outputs (which we talked about as part of hw3.py) are also useful.

You should now know how to at least draft that part of the problem. You can start on your code by creating the appropriate files in your repository, and adding comments (or even actual code) that solves just this piece of the problem. Later you can adjust that code as necessary, and integrate it with the rest of your solution.

HOMEWORK

Update the files triangle.py, rectangle.py, circle.py so that they work as follows:

$ ./triangle.py 1 1 1
area 0.433
perimeter 3
$ ./rectangle.py 5 3
area 15
perimeter 16
$ ./rectangle.py 5
area 25
perimeter 20
$ ./circle.py 2
area 12.56
perimeter 12.56

These programs should also provide a useful error if given nonsensical inputs (e.g., negative side lengths, impossible triangles) or no inputs.

Additionally, the file basic_shapes.py (already implemented, no need to fiddle with it) should now work as follows:

$ ./basic_shapes.py
Equilateral Triangle, side 4:
a: ..., p: ...
Square, side 4:
a: ..., p: ...
Rectange, sides 4, 5:
a: ..., p: ...
Circle, radius 3:
a: ..., p: ...

The basic_shapes.py file imports those other files, and then uses functions from them. You will need to figure out how to define functions in Python (and examine basic_shapes.py to know what function names to use).

As you work through this homework, you should consider committing your incremental progress. For example, when you get the input parsing working for triangles:

$ git add triangle.py
$ git commit -m "implement triangle input parsing"
$ git push