CMPT 120 Lecture Notes - Lecture 3: Duplicate Code, Tempura, Starbucks
![CMPT 120 Full Course Notes](https://new-docs-thumbs.oneclass.com/doc_thumbnails/list_view/2242525-class-notes-ca-sfu-cmpt-120-lecture27.jpg)
29
CMPT 120 Full Course Notes
Verified Note
29 documents
Document Summary
Advanced: based on what other ppl liked that you liked as well. /n is the escape sequence for newline (enter/return) Basically it double spaces when usually its single space. We use loops to avoid code duplication (copy/paste) So to instead of making it print a bunch of times, you can make a list, and get it to loop through all the items in the list + do a task (if needed) Print( starbucks: + str(starbucks_tally)) = starbucks: 3. Use str( ) to convert to string. Use int( ) to convert to integer. It"s called this because these #s are in a format called floating-point . Use float( ) to convert to float. Operators = special tokens that represent computations like addition, division, multiplication. Operands = the values the operators work on. This counts [0, 1, 2, 3], which is 4 values (computers start from 0) This counts [1, 2, 3, 4, 5] because you told the computer to start from.