Question: Do not use break or continue Write a program that inputs an integer base and a list alist of integers. The list should be set
Write a program that inputs an integer base and a list alist of integers. The list should be set up using assignment in the program. The goal of the program is to print the largest value in alist that is smaller than base. The program also needs to print the position of this value in alist (see the example below). Note, do not sort this list. You should be able to solve this problem going through the list only once (or twice). Do not use built-in functions other than those allowed in the course (e.g. len, input, int, range, list, print). If there is no value smaller than the base then the program will print an appropriate message as indicated below. Remember that the TAs will potentially change the list (and its size) in order to test your program so your program must be general for different base numbers, list values and list sizes. You can assume that the integers in alist are unique. For example If [52,4,1,17,81,2,75,24] is assigned to alist and base is 14 , then the output will be "4 at position 1 is the largest value in the list that is smaller than 14" If instead the base was 10, then the output will be "There are no numbers smaller than 10 in this list
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
