OIM3640 - Problem Solving and Software Design

2025 Spring

Session 04 (1/30)

contain

Today's Agenda

  • Welcome/News/Announcements
  • Class Review
    • Quick Quiz
    • More about f-strings
  • Lecture

Welcome/News/Announcements

  • Class GitHub:
  • 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?

Keeping Up with Each Chapter

  • Read the chapter after every class, regardless of whether we finish it in class.
  • Create a separate .py file for that chapter and re-run all the demo code.
    • Experiment with variations or create derivations from the examples.
    • Ask "what if" questions.
    • Take notes as you experiment.
    • If you're stuck, ask ChatGPT or post your questions on Slack.
  • Pre-read the next chapter before class, making note of anything you think might be challenging or interesting.

How to Ask Questions via Slack/GitHub/Email

  • What were you trying to do?
    • The problem and context.
  • What did you do?
    • Any relevant code snippets, or GitHub link to the code.
  • What did you expect to happen?
  • What actually happened?
    • Screenshots or descriptions of any strange behavior or errors.
    • Any relevant debug console or terminal output, such as error messages.

What we have learned so far...

  • Basic operations of software:
    • VS Code
    • GitHub
  • Python Basics:
    • Variables
    • Expressions
    • Statements

Quick Quiz

  1. What is the shortcut to open Command Palette in VS Code?
  2. What functions have we used/seen?
    • print(), input(), ...
  3. Is increase perc a valid variable name?
  4. Is file a valid variable name?
  5. What is the output?
    x = 123
    y = x
    x = 'abc'
    print(y)
    
  6. When using f-string, how do we justify the strings to the right?

Resources: f-string formatting in Python

More Questions

Whenever we learn a new feature, we should try it out and make errors on purpose to see what goes wrong.

  1. We’ve seen that n = 42 is valid. What about 42 = n?
  2. How about x = y = 1?
  3. In some languages every statement ends with a semi-colon, ;. What happens if you put a semi-colon at the end of a Python statement?
  4. What if you put a period . at the end of a statement?
  5. In math notation you can multiply x and y like this: xy. What happens if you try that in Python?

Exercises

  • All feedback will be provided in the GitHub Issues section of your oim3640 repo.
    • Regularly check the Issues section on your GitHub repository.
    • Reply if further discussion is needed.
    • Reply with evidence and close the issue if you believe it is resolved.
  • If you have any question regarding class content/demo code

Programming Suggestions

  • File/folder names
    • Use lowercase, i.e., session03
    • Use underscore, i.e., demo_types.py
  • Add comments properly,
  • Use descriptive and meaningful variable names, i.e., radius = 5
  • Whenever possible, please use f-strings for printing the results.

Debugging

  • Alt + Shift + F (or ⌥ Option + Shift + F on MacOS)
  • Always read the error message and try to understand it.
  • Pylance (in VS Code) is very helpful

Lecture

global styles

--- <style scoped> section kbd { font-size: 1rem; padding: 0.5rem; box-shadow: 2px 2px 2px rgba(0, 0, 0, 0.2); } </style> # Computer Tips (Windows 10) 1) How do you take a screenshot? 1) Screenshot tool - [Snip & Sketch](https://www.microsoft.com/en-us/p/snip-sketch/9mz95kl8mr0l) 2) <kbd><i class="fa fa-windows"></i></kbd> + <kbd>Shift</kbd> + <kbd>S</kbd> 3) <kbd><i class="fa fa-windows"></i></kbd> + <kbd>PrtScn</kbd> 2) How do you record the screen as a video? 1) Webex/Zoom 2) PowerPoint 3) [OBS Studio](https://obsproject.com/)

---

![bg fit](images/debug-session03-2.png)