OIM3640 - Problem Solving and Software Design

2025 Spring

Session 12 (3/04)

contain

Today's Agenda

Welcome/News/Announcements

  • Quiz 1: Grades posted on Canvas
  • Assignment 1: Feedback will be given on GitHub/Issues
  • Make sure you understand the code you use in your exercises and homework.
    • I may ask you to come to my office and explain any code that looks "interesting".
  • 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?

What we have learned so far...

  • Variables, Expressions, Statements
  • Types: int, float, string, boolean, NoneType, other data structures
  • Functions
  • Conditional Statements
    • if...elif...else
    • recursion
  • Pseudo-code
  • Iterations
    • for
    • while

Exercises

  • This year (2025) is a perfect square number. Can you find the next one?
  • Ex05 in String (Session 10) and Python Challenge Puzzle 1.

More Practice

How to Debug

  • Format your code first: Alt (⌥ option if macOS) + Shift + F in VS Code.
  • print()
  • PythonTutor.com
  • Debugging in VS Code
    1. Set breakpoints to pause execution at specific lines.
    2. Run debugger: Press F5 to Start Debugging
      1. "Continue" ( F5 ): Keep running until next breakpoint or stopping point.
      2. "Step Over" ( F10 ): Go through code line by line, skip over functions.
      3. "Step Into" ( F11 ): Step into functions and trace each line inside them.
    3. Inspect Variables: Use "VARIABLES" panel or "WATCH" panel.

Lecture

--- # NotebookLM - Have you tried [NotebookLM](https://notebooklm.google/)? * Do you listen to **podcasts**? * What is your **favorite** podcast? * YouTube/Podcast - [How to learn Python programming | Guido van Rossum and Lex Fridman](https://www.youtube.com/watch?v=F2Mx-u7auUs)

--- <div class="mx-auto"> <blockquote class="twitter-tweet"><p lang="en" dir="ltr">When I talk to students they often think that if they want to start a startup one day they should be learning about economics or finance. I tell them they should instead be learning how to build things. Building is the root.</p>&mdash; Paul Graham (@paulg) <a href="https://twitter.com/paulg/status/1840698085434884544?ref_src=twsrc%5Etfw">September 30, 2024</a></blockquote> <script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script> </div>

--- # Social Time * What is your favorite **TV show**? * [Tabs versus Spaces](https://www.youtube.com/watch?v=SsoOG6ZeyUI) - *Silicon Valley*

--- # Assignment 1 Feedback 1) If you read Q1's `main` function carefully, you should've realized the starting point is not necessarily `(0,0)`. 2) Break `drunkard_walk` into smaller functions. 3) Please use **comments** when necessary, e.g., `if dir == 1: # What does 1 mean?` 4) `turtle.lt(90)` might not be the correct direction as expected. * You could use `setheading()` or `goto(x, y)`. 5) Only one `if __name__ == '__main__':` should be in a `.py` file. 6) Better to use `while` for Q3. 7) Avoid using variable names such as `sum`, `round`, `class`. 8) After learning `dict`, can you improve your code? --- # Assignment Feedback & Code Review - Submitting your homework does not mark the end of the process. - Please respond to my feedback and implement any necessary modifications. - I also recommend using **ChatGPT** for code review. - What would be a good prompt?