|
13 | 13 | <input> |
14 | 14 | sum = 0 |
15 | 15 | for num in [1, 3, 5, 7, 9]: |
16 | | - sum = sum + num |
| 16 | + sum = sum + num |
17 | 17 | print(sum) |
18 | 18 | </input> |
19 | 19 | </program> |
|
33 | 33 | <input> |
34 | 34 | long_names = 0 |
35 | 35 | for name in ["Joe", "Sally", "Amy", "Brad"]: |
36 | | - if len(name) > 3: |
37 | | - long_names += 1 |
| 36 | + if len(name) > 3: |
| 37 | + long_names += 1 |
38 | 38 | print(long_names) |
39 | 39 | </input> |
40 | 40 | </program> |
|
51 | 51 | s = "what if we went to the zoo" |
52 | 52 | num_vowels = 0 |
53 | 53 | for i in s: |
54 | | - if i in ['a', 'e', 'i', 'o', 'u']: |
55 | | - num_vowels += 1 |
| 54 | + if i in ['a', 'e', 'i', 'o', 'u']: |
| 55 | + num_vowels += 1 |
56 | 56 | print(num_vowels) |
57 | 57 | </input> |
58 | 58 | </program> |
|
79 | 79 | nums = [9, 3, 8, 11, 5, 29, 2] |
80 | 80 | best_num = 0 |
81 | 81 | for n in nums: |
82 | | - if n > best_num: |
83 | | - best_num = n |
| 82 | + if n > best_num: |
| 83 | + best_num = n |
84 | 84 | print(best_num) |
85 | 85 | </input> |
86 | 86 | </program> |
|
98 | 98 | nums = [9, 3, 8, 11, 5, 29, 2] |
99 | 99 | best_num = nums[0] |
100 | 100 | for n in nums: |
101 | | - if n > best_num: |
102 | | - best_num = n |
| 101 | + if n > best_num: |
| 102 | + best_num = n |
103 | 103 | print(best_num) |
104 | 104 | </input> |
105 | 105 | </program> |
|
115 | 115 | scores = [85, 95, 70] |
116 | 116 | result = '' |
117 | 117 | for score in scores: |
118 | | - result = result + str(score) + ',' |
| 118 | + result = result + str(score) + ',' |
119 | 119 |
|
120 | 120 | print("The scores are " + result) |
121 | 121 | </input> |
|
139 | 139 | scores = [85, 95, 70] |
140 | 140 | result = '' |
141 | 141 | for score in scores: |
142 | | - result = result + str(score) + ',' |
| 142 | + result = result + str(score) + ',' |
143 | 143 |
|
144 | 144 | print("The scores are " + result) |
145 | 145 |
|
|
149 | 149 |
|
150 | 150 | class myTests(TestCaseGui): |
151 | 151 |
|
152 | | - def testOne(self): |
153 | | - self.assertEqual(self.getOutput().rstrip('\n'), 'The scores are 85, 95, and 70.', "Output |
154 | | - should be 'The scores are 85, 95, and 70.'") |
| 152 | + def testOne(self): |
| 153 | + self.assertEqual(self.getOutput().rstrip('\n'), 'The scores are 85, 95, and 70.', "Output should be 'The scores are 85, 95, and 70.'") |
155 | 154 |
|
156 | 155 | myTests().main() |
157 | 156 | </input> |
|
167 | 166 | scores = [85, 95, 70] |
168 | 167 | result = '' |
169 | 168 | for score in scores[:-1]: |
170 | | - result = result + str(score) + ', ' |
| 169 | + result = result + str(score) + ', ' |
171 | 170 |
|
172 | 171 | # Now, append the last score |
173 | 172 | result = result + 'and ' + str(scores[-1]) + '.' |
|
194 | 193 | s = "We are learning!" |
195 | 194 | x = 0 |
196 | 195 | for i in s: |
197 | | - if i in ['a', 'b', 'c', 'd', 'e']: |
198 | | - x += 1 |
| 196 | + if i in ['a', 'b', 'c', 'd', 'e']: |
| 197 | + x += 1 |
199 | 198 | print(x) |
200 | 199 | </input> |
201 | 200 | </program> |
|
253 | 252 | list= [5, 2, 1, 4, 9, 10] |
254 | 253 | min_value = 0 |
255 | 254 | for item in list: |
256 | | - if item < min_value: |
257 | | - min_value = item |
| 255 | + if item < min_value: |
| 256 | + min_value = item |
258 | 257 | print(min_value) |
259 | 258 | </input> |
260 | 259 | </program> |
|
319 | 318 |
|
320 | 319 | class myTests(TestCaseGui): |
321 | 320 |
|
322 | | - def testNine(self): |
323 | | - self.assertEqual(past_tense, ['adopted', 'baked', 'beamed', 'confided', 'grilled', |
324 | | - 'planted', 'timed', 'waved', 'wished'], "Testing that the past_tense list is correct.") |
325 | | - self.assertIn("else", self.getEditorText(), "Testing output (Don't worry about actual and |
326 | | - expected values).") |
327 | | - self.assertIn("for", self.getEditorText(), "Testing output (Don't worry about actual and |
328 | | - expected values).") |
| 321 | + def testNine(self): |
| 322 | + self.assertEqual(past_tense, ['adopted', 'baked', 'beamed', 'confided', 'grilled', 'planted', 'timed', 'waved', 'wished'], "Testing that the past_tense list is correct.") |
| 323 | + self.assertIn("else", self.getEditorText(), "Testing output (Don't worry about actual and expected values).") |
| 324 | + self.assertIn("for", self.getEditorText(), "Testing output (Don't worry about actual and expected values).") |
329 | 325 |
|
330 | 326 | myTests().main() |
331 | 327 | </input> |
|
0 commit comments