CSC148H1 Lecture Notes - Eval, 1.-Class Torpedo Boat, Master Sergeant
katrinasavvy and 38715 others unlocked
1
CSC148H1 Full Course Notes
Verified Note
1 document
Document Summary
((3 + 4) (7 1): simply (3 + 4) place all digits on stack * ( , 3", 4, once reach )", evaluate the expression. Int(v2) + int(v1) v1 = 4", op: +", v2 = 3". Stack implementation choices: ex. stack. py (constant time operation) vs. bad_stack. py (linear operation, bad_stack pushes item on a list at index 0, instead of stacking it at the end. Stck. pop() when stack. is_empty(: we wrote the stack class so that other programmers (including us) could use it, there are two kinds of people who are involved with every function and class: The implementers: the people writing that code. Stck. pop(): exceptions: as discussed in week 1, these two kinds of people think about the code very differently, implementers of a service: Have to worry about how the code works. Have no idea what the code is being used for. Don"t know what to do if they"re asked to do the impossible, so they raise an exception.