CS 210, Intro to AI Programming

Overview of AI

Topics 
1. What is AI, Python6. ANN: Image recognition
2. Symbolic AI7. Generative AI
3. Classical Machine Learning: Training8. Custom chatbot
3. Classical Machine Learning: Inference9. LLM fine-tuning
5. Midterm10. Ethics
 11. Final

 

Contents

Learning a New Programming Language

Most programming languages have many things in common:

Once you've learned how to work with these concepts in one language, it's mostly just a mater of learning the new syntax for the next language you learn.

 

Installing Python and Running a Program

Windows

Check for Python and the Python Launcher

Open a Power Shell Terminal on your computer and check to see if Python is installed on your system using this command:

If it is installed, the version number will be reported.

Check to see if the Python launcher is installed:

If it is installed, the version number will be reported.

Install One or Both if Missing

Download the latest Python installer and run it.

Run Hello World

  1. Create the "Hello World" Script

Save the file as hello.py

  1. Run the Program in Command Prompt (CMD) or PowerShell

    Open the Command Prompt:

    • Press the Windows Key + R, type cmd, and press Enter. (Or use the Windows search bar to find "Command Prompt" or "PowerShell").

    • Use the cd (Change Directory) command to move to the folder where you saved your script. If you saved it to C:\PythonProjects, you would type: cd C:\PythonProjects

  2. Execute the Script:

Use the python command followed by the file name:

(If python doesn't work, try using py hello.py instead.)

Output: The Terminal will display the result:

 

MacOS

While macOS comes with a system version of Python pre-installed, it's outdated and should not be used for development. We will install a modern version using Homebrew, the popular package manager for macOS.

Check the version of Python

In the Terminal, run:

If it's older than 3.12 (or whtever the latest version is) then upate it.

Install or Update Python

Install Homebrew (If You Don't Have It)

Homebrew is a tool that makes installing developer software on Mac incredibly easy.

Open the Terminal:

Press Cmd + Space and type "Terminal," then press Enter.

Run the Homebrew installation command:

Copy and paste the following line into your Terminal and press Enter

The script will prompt you to enter your administrator password (it won't display as you type) and press Enter.

Follow any final on-screen instructions, such as adding Homebrew to your system's PATH.

Install Python

Once Homebrew is installed, installing Python is a single command.

In the Terminal, run:

Homebrew will download and install the latest stable version of Python (typically Python 3.x).

Verify the Installation

After the installation completes, confirm that the correct version is now recognized by your system.

Check the Python version:

In the Terminal, run:

You should see output confirming the version you just installed (e.g., Python 3.12.2).

Run Hello World

  1. Create your Python file: Use a text editor to create a file named hello.py and add the following content:

  2. Open Terminal and Navigate: Open your Terminal and navigate to the directory where you saved hello.py (using the cd command).

  3. Run the script: Execute the file using the Python 3 interpreter:

  4. Output: The Terminal will display the output:

Learning Python

Distictives of Python

FizzBuzz Example Program

Here is an implementation of the classic "FizzBuzz" program1 in Python:

 

Programming Paradigms of Python

Here is an example of Object Oriented Programming in Python. This car simulator illustrates these of OOP concepts:

 

Exercise: Translate a Dice Game into Python

Translate a simple game from either JavaScript or C# into Python.

The game is "die battle": two players each roll a single six-sided die, and the player with the higher number wins. It requires defining three simple classes:

  1. Die: Represents the physical object that can be rolled.

  2. Player: Represents a participant who interacts with the die.

  3. DiceBattle: Orchestrates the game flow and holds the game state (the players and the die).

The solution is here.

 

More Resources

More Lecture Notes on Python

Online Tutorials

Online Videos

Note: Some parts of this document were initially drafted with assistance from Gemini 2.5 Flash 9/30/25


 

Creative Commons License Intro to AI Programming Course Materials by Brian Bird, written in , are licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

 


1 The FizzBuzz program iterates from 1 up to some specified limit. It prints "Fizz" for multiples of 3, "Buzz" for multiples of 5, "FizzBuzz" for multiples of both, or just the number.