Question 15
AQA Computer Science Specimen Paper 1B (8525/1B)GCSE4 marks
On the specification
- 3.2 Programming
Question text
15 A program has been written in Python to display all the odd integers between 1 and the largest odd number smaller than an integer entered by the user. The program is shown in Figure 6. Figure 6 odd = 1 number = int(input("Enter an integer: ")) while odd != number: print(odd) odd = odd + 2 print("Finished!") The program works correctly if the integer entered by the user is an odd, positive integer. For example, if 7 is entered the program correctly displays the values 1, 3 and 5 The program does not work correctly if an odd integer less than 1 is entered by the user. For example, when -7 is entered the program should display the values 1, -1, -3 and -5 but it does not do this. Using Python only, change the program code inside the while loop so that it will work correctly for any odd integer entered by the user. [4 marks]