CMPT 120 Lecture : Decisions and Conditions

48 views2 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
29
CMPT 120 Full Course Notes
Verified Note
29 documents

Document Summary

Cmpt120: we need to write code that makes decisions, most common way to make decisions is the if statement, based on user input, result of calculations, etc, the idea: If (this is true): (do this stuff: eg. num = int(raw_input( enter ten: )) if num == 10: print very good. , when this program runs: In python, the stuff indented after the if is only executed when the condition is true. Must all be indented same amount (4 spaced) Unindented stuff after executes no matter what if (condition): (code that executes only if the condition was true) (code that executes no matter what) o o. The condition is what is used to make the decision in the if : a boolean expression, an expression that evaluates to true or false, some boolean operators: less than not equal to. == is equal to eg. 10 < 9.

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

Related Questions