Skip to content

Repository files navigation

Tic-Tac-Toe Coding Challenge

This is your first coding challenge: write a simple command-line Tic-Tac-Toe game in Python that two players can play against each other. Along the way you will practice planning a program before you write it, using program-design tools and splitting your code into small, focused functions. The repository gives you the assignment, a few supporting lessons, and a starter script to build on.

Learning Objectives

By the end of this repository, you should be able to:

  • Break a programming problem into small, well-named functions before writing code.
  • Apply program-design tools (flowcharts, requirements, skeleton code) to plan a solution.
  • Write pseudocode to outline an algorithm before you implement it.
  • Build a working command-line Tic-Tac-Toe game in Python (board display, player turns, win and draw detection).
  • Explain what if __name__ == "__main__" does and use it as a script entry point.
  • Read Python error messages and stack traces to debug your own code.

Learning Path

File / Folder Description
01 - Assignment The coding challenge: build a command-line Tic-Tac-Toe game, with step-by-step suggestions.
02 - Program Design Design tools (flowcharts, requirements, pseudocode, skeleton code) for planning a program before you code.
03 - Intro to Pseudocode A short primer on writing pseudocode to outline an algorithm.
Tic Tac Toe Starter script where you write your game; it already includes the if __name__ == "__main__" entry point.

Additional Folders and Files

File / Folder Description
Examples Two small scripts showing how if __name__ == "__main__" behaves when a file is run directly versus imported.
Solutions Reference solution.
Assets Images used in the lessons.
pyproject.toml Project configuration and dependencies.
uv.lock Pinned dependency lock file.

Setup

Note

Throughout these steps, text in angle brackets like <repo-name> is a placeholder. Replace it, including the < > brackets, with your own value. For example, cd <repo-name> becomes cd tic-tac-toe.

1. Create the Repository from the Template

Click Use this template on GitHub.

When creating the repository:

  • Set yourself as the Owner
  • Choose a repository name
  • Enable Include all branches
  • Click Create repository

Important

If you are working in pairs or groups, only one person should complete this step.


2. Add Collaborators (Pairs/Groups Only)

If working with teammates:

  1. Open the repository on GitHub
  2. Go to Settings → Collaborators
  3. Add your teammates as collaborators
  4. Share the repository link with your team

Teammates should accept the invitation before continuing.


3. Clone the Repository

Copy the SSH URL from the Code button on GitHub, then run:

git clone <copied-ssh-url>

The copied SSH URL will look like git@github.com:<your-username>/<repo-name>.git.


4. Move into the Project Folder and Install Dependencies

This installs all dependencies and creates a virtual environment in .venv/, including the Jupyter kernel (ipykernel).

cd <repo-name>
uv sync

5. Open the Project in VS Code

Note

Make sure you open VS Code from the project root so it automatically detects the environment created by uv sync.

Launch VS Code from the terminal:

code .

If you want to work interactively, create a notebook (for example scratch.ipynb) and select the Python environment created by uv sync as the kernel.

Tip

Prototype and test small pieces of your game in notebook cells, then move the working code into tic_tac_toe.py.

Usage

Work through the material in order, and plan before you code.

  1. Read 01 - Assignment to understand what the game should do.

  2. Review 02 - Program Design and 03 - Intro to Pseudocode for planning techniques.

  3. Sketch your solution using a flowchart or pseudocode.

  4. Implement and test small functions, then move working code into tic_tac_toe.py.

  5. Connect your functions inside the if __name__ == "__main__" block.

  6. Run the finished game:

    uv run python tic_tac_toe.py

Coding practices to keep in mind

  • Give your functions explicit, descriptive names.
  • Write a docstring for each function explaining how to call it.
  • Keep functions short, roughly 4 to 10 lines each.

References & Further Reading

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages