CGSC 1005 Lecture 4: COMP SCI Sept. 17

21 views1 pages

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.

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