CGSC 1005 Lecture 4: COMP SCI Sept. 17
Document Summary
The data types we have discussed (integers, floats, strings, boolean) are called immutable (unchangeable) This is because once python creates them they cannot be changed. Possibility 1: condition(s) is met + indented code (the body) is executed. Possibility 2: condition is not met + indented code is not executed. What can change is what the variable refers to. Not changing the string but what the variable points" to and the old value is left dangling unassigned. Often times we want something to happen is the condition is true, something else if it is not true and something else if another condition is true etc. if < condition (s) > : elif < condition (s) > : else: Else is an alternate, if not if then . If-elif make code easier to write and read. In an if-elif statement, once a condition is satisfied, subsequent ones are not checked.