CSC108H1 Lecture Notes - If And Only If
yifanyang and 39659 others unlocked
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.