OIM3640 - Problem Solving and Software Design

2025 Spring

Session 17 (3/27)

contain

Today's Agenda

  • Welcome/News/Announcements
  • Midterm Feedback Survey
  • Lecture

Welcome/News/Announcements

  • Assignment 2
    • Due 4/04 Friday. Please start early!
    • I suggest you finish analyze_book.py first.
  • Next class:
    • Introducing Project
    • Quiz on Data Structures/APIs
  • 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?

Midterm Feedback Survey

  • Canvas - Session 17

Reflection on Learning Programming

  • Programming is HARD.
  • To help you reflect on your progress, ask yourself:
    1. Did you take this class out of a genuine interest in coding, or just for credits?
    2. Do you feel excited when solving problems, or just satisfied to get it done?
    3. Have you ever experienced an "aha!" moment when it suddenly clicked?
    4. When faced with a problem, do you first think it through yourself, or do you immediately turn to Google/ChatGPT?
    5. Have you tried explaining your code to yourself or others and writing comments to clarify your thinking?
    6. Have you looked back to see how much you've improved and learned since the beginning of the course?

Assignment 2 - Text Analysis Project

  • Due 4/04 Friday
  • To get started:
    • Fork the base repository to your GitHub account.
    • Clone the forked repository to your computer.
  • To submit:
    • Push all the code and update the README.md file in your GitHub repository.
    • Create a pull request from your forked repository to the upstream repository.
    • Submit the URL of your project's GitHub repository to Canvas.
  • Please Start early!

What we have learned so far...

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

Recommendations

Session 16

  • Case - Text Analysis
  • Download following file(s) from OIM3640/resources/code/data to data folder
    • Pride and Prejudice.txt
  • Download following file(s) from OIM3640/resources/code/ to session16 folder
    • analyze_book.py

Error Handling

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