Pure Python codeVersión en línea Test your knowledge of pure Python code por Álvaro Manuel Navarro Cruz 1 Which line is not correct? Pay attention to the indentation. a 2 b 3 c 4 d 5 2 Is this correct if we want to generate a random number between 1 and 100? a Yes b No, we need to use random.randint(1, 100) 3 Is it necessary to specify the last "elif" condition? a Yes, because otherwise we can't know what it's referring to. b No, because we've already checked whether the number is greater or smaller, and the only option left is that it's equal. We can use else directly. 4 Which of the following statements about the filterEvenNumbers() function are correct? Choose one or more answers a It returns all the odd numbers in the list. b It uses a for loop to iterate over the list. c It uses the % operator to check if a number is even. d It directly modifies the original numberList. 5 What is the purpose of the while loop in the timesTable program? a To repeat the multiplication table until the number 0 is entered b To keep printing multiplication tables until the user types -1 c To create an infinite loop regardless of input d To generate a multiplication table for the number -1 Feedback 1 If we leave line 5 in place, the if condition will be empty. 2 The function random.randint(a, b) generates a random integer including both endpoints a and b. So, random.randint(1, 98) will only generate numbers from 1 up to 98, excluding 99 and 100. 3 Using else here simplifies the code because all other possibilities have been eliminated by previous checks (if and elif). Since the only remaining case is that the number is equal, else handles it cleanly and reduces redundancy. This approach is common and accepted in programming to keep the code concise. 5 The while loop in the timesTable program is designed to repeatedly prompt the user to enter numbers and print the corresponding multiplication tables. The loop continues executing as long as the user does not enter the sentinel value -1. When the user inputs -1, the loop terminates, effectively stopping the repetition of multiplication tables. This allows the program to keep running and displaying new tables for different numbers until the user decides to stop by typing -1. Therefore, the purpose of the while loop is to keep printing multiplication tables until the user types -1.