cs2370 Notes: 23 Mid Semester Review
··2 mins
Why write computer programs? #
- Computers run the world
- Programs run the computers
- Code vs. Law
- Automatic speed limits vs. police judgement
- DRM on movies vs. fair use
Software Setup #
- Most dev environments take some setup.
- We’re specifically using a python setup with
- The miniconda package manager.
- The Spyder editor / IDE
Python code #
Overview:
- A series of statements
- Executed in order, top to bottom
- import statements cause code from other files to run
- Execution of blocks (indented code after a colon) may be conditional or delayed.
- Functions are an important case of delayed code blocks
- Most of the execution order of a program is about a bunch of functions calling each other.
Parts of Speech:
- Literals
- Operators
- Arithmetic of numbers and strings
- Function calls
- Expressions vs. statements
Control flow:
- If / Else
- While
- For-each
- For-range
Design Recipe #
Core steps:
- Stub with names
- Purpose statement
- Types
- Tests
- Standard pattern
- Body
Standard patterns:
- Atomic data; boring.
- More complex data, two basic cases:
- What do we do with a list?
- How do we build a list to return?
Data #
- Lists
- Tuples / Structs
- Sets
- Dictionaries
- Quick dictionary review
Graphical programs with the sim library #
- https://homework.quest/classes/2025-01/cs2370/notes/08-eat-bugs/
- https://homework.quest/classes/2025-01/cs2370/notes/10-snake/
Computational complexity #
- There’s more than one way to do it.
- If you do it too slow a way, you’re wasting resources.
- If you do it too complicated a way, you’re wasting other resources.
Next topics #
- A little more with dictionaries
- Classes and methods
- Then, we’re going to try to solve a hard problem.