CMPT 120 Lecture Notes - Lecture 3: Duplicate Code, Tempura, Starbucks

14 views2 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
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.

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents