I&C SCI 31 Lecture Notes - Lecture 15: Empty String, Syntactic Sugar, Control Flow

36 views3 pages

Document Summary

Big picture: a programming language lets us model the real world. Control structures: sequence, modularity (function calling/ returning), selection (if/elif/else), repetition (loops) Single-valued: int float bool str [also a sequence of characters] Lists: collections of objects of the same category/type. Namedtuples: package of possibly different-type data fields that describe an object tuples: like namedtuples without the names. T[0] t[1] files: give us persistence---stuff sticks around. We can combine these for richer, more realistic objects. + - * / % (mod) // (integer division) We can combine these in a few ways: Nesting: print(len(s)) z = 2 * (len(x) + len(y)) Each statement can be simple or compound: statement1 if boolean-expression: statement2a else: statement2b statement2c statement3. Advice: know the syntax and semantics of each statement/control structure. "indexing for-loop" (where control variable is a number, not an item) for i in range(len(l)): # i = i * 100 this doesn"t change l! print(i+1, ".

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