OIM3640 - Problem Solving and Software Design

2025 Spring

Session 19 (4/03)

contain

Today's Agenda

  • Welcome/News/Announcements
  • Introducing Term Project
  • Lectures:
    • OpenAI API
    • Automation
  • Revisit Quiz 4 (if time permits)

Welcome/News/Announcements

  • Assignment 2:
    • Only 10 forks as of 8 AM today
    • Due 4/04, Friday 4/05, Saturday
  • Assignment 3: Create a Web Application (will be introduced next class)
  • Term Project posted
  • Communications
    • Meet with me in person during office hours at least once this semester.
    • Email - specify course # in subject title, e.g., "OIM3640: GitHub settings"
    • Use Slack/GitHub when asking code-related questions
  • Questions?

Introduction to Term Project

  • Project Instruction
  • Teaming: due 4/07, Monday
  • Proposal: due 4/12, Saturday
  • GitHub repository for project:
    • Only one creates a public project repository.
    • The other member needs to fork this repository as a collaborator.
    • Everyone needs to submit URL of GitHub repository to Canvas.

Fun Time

What we have learned so far...

  • Variables, Expressions, Statements
  • Types: int, float, string, boolean, Nonetype, string, list, dictionary, tuple, set
  • Functions
  • Conditional Statements
  • Iterations
  • Pseudo-code
  • Debugging
  • Error Handling
  • APIs

Assignment 2 - Text Analysis Project

API

API (Application Programming Interface)

  • An API is a set of protocols, tools, and standards for building software applications, that allows different applications to communicate with each other.

  • Example: Let's say you want to know the current price of Bitcoin

API Example: OpenWeather

  • Create an API key from https://openweathermap.org/api
  • Download the sample code, weather.py, from OIM3640/resources/code
  • Use the urllib.request library to send HTTP requests to the OpenWeather API and retrieve data in JSON format
  • Remember to protect sensitive data (e.g., API keys, API tokens, passwords)
    • Create .env file and store your API key, e.g., OPENWEATHER_API_KEY=...
    • Install python-dotenv in terminal: python -m pip install python-dotenv
    • import os
      from dotenv import load_dotenv
      
      load_dotenv()
      APIKEY = os.getenv("OPENWEATHER_API_KEY")
      
    • Add .env to .gitignore file to prevent committing it to a public repository.

OpenAI API Quick Start

Recommendations on API

OpenAI API Quick Start

Automation

More APIs

Q&A

  • Questions from past exercises, quizzes, assignments.
  • Issues on GitHub
  • Any question today?

--- # Revisit [Quiz 4](https://gist.githubusercontent.com/lzblack/b9a66123d2fe51aa084d959ebcedb903/raw/b7fbfcab2043105b0021ed6bec1d519c5d1e6ccb/quiz4.py)