APS106H1 Midterm: APS106H1_20171_631492476452Midterm1_marking

43 views9 pages

Document Summary

[8 marks: [3 marks] consider the following piece of code: def test_function(a_boolean_variable): if a_boolean_variable != true: return true else: return false. Circle your answer. (a) if not (number_of_days + 1) % 2 == 1) (b) if not (number_of_days % 2 == 1) (c) if number_of_days % 2 == 0. [12 marks: [4 marks] the following poorly written python function is intended to identify if an integer be- tween 5 and 12 is even or odd and divisible by three or four. It should then print those properties to the screen. Circle each error and fill in the table on the right-hand side, indicating line number and writing the complete correct line of code. There% are% 5% errors% (line% 2% is% arguable)% and% so% the. " 0. 5$ for$ error," 0. 5" for" the" cor" rection. &" 22 if num == 5: print("odd. ") if num == 9: else: also acceptable: elif num == 12: if num == 12: