CSC108H1 Lecture Notes - If And Only If

20 views2 pages
11 Jan 2013
School
Course
yifanyang and 39659 others unlocked
CSC108H1 Full Course Notes
21
CSC108H1 Full Course Notes
Verified Note
21 documents

Document Summary

Given the variables name1 and name2, write a fragment of code that assigns the larger of their associated values to first. Top-level code: code that isn"t inside a function definition or guarded by an if _ _name_ _ == _ _main_ _": condition. While loops: while , [statement after] How they work: general format, while expression: statements, sounds like; while the expression is true, execute the statements, but really means: if the expression is true, execute the statements one [more] time. Then go back and consider doing it all again: the difference: if the expression becomes false during the statements, it still completes all of them. Ex: n = 3, while (n > 0): if n % 5 == 0: n = -99 print n n = n + 1, print all done output: 4 # go through the second time, n + 1.

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