OIM3640 - Problem Solving and Software Design

2025 Spring

Session 13 (3/06)

contain

Today's Agenda

  • Welcome/News/Announcements
  • Class Review
  • Debugging Practice
  • Lecture

Welcome/News/Announcements

  • Next Class: Quiz on strings and list
  • 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

Recommendations:

More Practice

  1. ⭐ Codingbat (OIM3640/codingbat)
  2. Python Challange
  3. More learning resources

Debugging

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

Python Tips - Rubber Duck Debugging

alt=""

Q&A

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

Lecture

- **Assignment 1**: Feedback given on GitHub/Issues

--- # 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? --- ![bg 80% drop-shadow](images/hw1-feedback-chatgpt.png) --- ![bg 80% drop-shadow](images/hw1-feedback-chatgpt-2.png) --- ![bg 80% drop-shadow](images/hw1-feedback-chatgpt-3.png) --- # 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?