Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Do not use break or continue image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Intranet And Web Databases For Dummies

Authors: Paul Litwin

1st Edition

0764502212, 9780764502217

More Books

Students also viewed these Databases questions

Question

Is the person willing to deal with the consequences?

Answered: 1 week ago