COMP 1005 Lecture 5: Lecture 5

16 views4 pages

Document Summary

The outcome of this lesson is to learn about the various structures of if statements. Example: if x > 0: print( x is positive ) print ( goodbye ) x value output. Type 2 - alternative execution if (condition): do the true part else: do the false part do the rest of the program. Example: if x > 0: print( x is positive ) else: print( x is negative ) print( goodbye ) Type 3 - chained execution if (condition): do the true part elif (condition): do the else-if part else (condition): Do the else part do the rest of the program. A nested conditional is a combination of type 1, type 2, and type 3. if x == y: print( x and y are equal ) else: if x < y: print( x is less than y ) else: print( x is greater than y )

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

Related Questions