Sample Programs
These sample programs were written by Assem Kishore, one of the 2008 instructors of this course.
PROGRAMS | DESCRIPTIONS | FILES |
---|---|---|
Tic-Tac-Toe |
This is a program that you could have coded. This code was written with the intention of being polished. Feel free to download, experiment with, and improve the code! | tictactoe.py (PY) |
Connect Four |
This is also a program that you could have coded. This sample program was written with the goal of being polished. This is a great example where the implementation is not trivial (unlike in Tic-Tac-Toe), so abstraction is vital to prevent bugs and to keep the code readable. There are some Python things in the code that you may not know yet. The assert statement just throws an error if the following condition isn't true. Writing a string with the % symbol lets you plug in the variables that follow into that spot in the string (%s means string, %i means integer and %c means one letter). | connectfour.py (PY) |