diff --git a/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/.loops.py.swp b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/.loops.py.swp index 653e8be..a88d85b 100644 Binary files a/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/.loops.py.swp and b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/.loops.py.swp differ diff --git a/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/loops.py b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/loops.py index 155499e..c4f5f72 100644 --- a/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/loops.py +++ b/archives/01-introduction-to-computer-science-and-programming/archives/UNIT-01/03-problem-solving/loops.py @@ -1 +1,23 @@ # Loops - http://beastie.cs.ua.edu/cs150/book/index_14.html + +i = 0 +while i < 5: + print i + i += 1 + +# Other loops +for i in range(0, 5, 1): # 5 exclusive + print i + +# The counting pattern +count = 0 +for i in range(0, len(items), 1): + count += 1 + +# The filtered-count pattern +count = 0 +for i in range(0, len(items), 1): + if items[i] % 2 == 0: + count += 1 + +