CS 110 Lecture 7: CS 110 Lesson 7 notes

59 views2 pages
20 Sep 2016
Course
Professor

Document Summary

Only good for constants needed in multiple functions, such as pi or e. Defined by the surrounding block: def main(): x = 2 for j in [1,2,3]: x = j print x. This will print 3, because the x in the for loop block overshadows the original x. Can only be used in the function it was defined in. Some list of values that need to be tallied up in some way: example: sum = 0 ----- sum is the accumulator for j in [1,2,3,4]: sum = sum+j. *the booleans must be capitalized! print (5 == 5) This will print true print (5 == 6) There are 6 boolean operators: == : tests equality. != : tests inequality: < : less than, >= : greater than or equal, <= : less than or equal. Logical operators and : requires both boolean operators to yield true for the and operator to return true.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents