Lecture Notes on 06 Feb 2017 Active Reading: Type code as you read. Read Chapter 5: Sections 5.1 - 5.2 Write the code from the following listings and run them: * Listing 5.1: RepeatSubtractionQuiz.py * Listing 5.2: GuessNumberOneTime.py * Listing 5.3: GuessNumber.py * Listing 5.4: SubtractionQuizLoop.py * Listing 5.5: SentinelValue.py def main(): # prompt the user to enter a positive number num = int (input ("Enter a positive number: ")) # count upto num and sum the numbers iter = 1 sum_num = 0 while (iter <= num): sum_num = sum_num + iter iter += 1 print (sum_num) # count down to zero from num iter = num while (iter >= 0): print (iter) iter = iter - 1 # sum numbers that are multiples of 3 or 5 iter = 1 sum_num = 0 while (iter < 1000): if (iter % 3 == 0) or (iter % 5 == 0): sum_num = sum_num + iter iter = iter + 1 print (sum_num) # sum of all two digit numbers that are multiples of 15 iter = 15 sum_num = 0 while (iter < 100): sum_num = sum_num + iter iter = iter + 15 # use of sentinel value to terminate a loop sum_num = 0 iter = 0 num = input ("Enter a number, type Q to quit: ") while (num != "Q"): iter = iter + 1 num = int (num) sum_num += num num = input ("Enter a number, type Q to quit: ") if (iter > 0): avg = sum_num / iter print (iter, sum_num, avg) # sum the digits of a number # prompt the user to enter a positive number num = int (input ("Enter a positive number: ")) sum_digits = 0 while (num > 0): sum_digits += num % 10 num = num // 10 print (sum_digits) main()