Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

DO NOT USE BREAK COMMAND!!!!! At this point, if you try to run the file, you will get an error. That is because the file

DO NOT USE BREAK COMMAND!!!!!

At this point, if you try to run the file, you will get an error. That is because the file is only partially completed for you.

You will need to update the file to complete the three function definitions and three function calls. If you open the file, you should see comments boxed in by#--------# characters these are where you need to write new code. Read the function header comments to see the details about the three functions.

You should have written code similar to all of these functions previously, either in homeworks, labs, or in-class exercises. The code for printList()should be familiar to you, as you have printed quite a few lists during in-class exercises. Thebigdifferenceisthatinthisfunction,theindexofeachelement should also be printed out.

The functions printMinStr() and printMaxStr() are very similar; once you complete one function, the other should be very easy to code up. Think carefully about what the function needs to accomplish: it needs to iterate over the entire list, keeping track of which string is the shortest or longest its found so far. (HINT: When choosing a starting value to compare every other string to, use the first string in the list.)

(If two strings are the same length and are the shortest/longest length, picking either one for the final answer is fine. In the sample output below, we pick the first one we see, but your code may work differently.)

You will also need to write calls to each of these functions. The places where these calls need to happen in main() are indicated for you. You shouldnt need to write any other code.

Here is some sample output of the completed program, with user input in blue. (Yours does not have to match this word for word, but it should be similar.)

linux[0]$ python3 names.py Enter a name (or -1 to quit): Dr. GibsonEnter a name (or -1 to quit): -1 At index 0 the name is "Dr. Gibson" The shortest string in the list is Dr. Gibson The longest string in the list is Dr. Gibson

linux[0]$ python3 names.py Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): Enter a name (or -1 to quit): At index 0 the name is "Matt" At index 1 the name is "Zoee" At index 2 the name is "Ben" At index 3 the name is "Brianna" At index 4 the name is "Emily" At index 5 the name is "Kristin" At index 6 the name is "Sahil" At index 7 the name is "Celeste" At index 8 the name is "Ren" 
At index 9 the name is "Nsikan" The shortest string in the list is Ben The longest string in the list is Brianna 

MattZoeeBenBriannaEmilyKristinSahilCelesteRenNsikan-1

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

Databases And Information Systems 1 International Baltic Conference Dbandis 2020 Tallinn Estonia June 19 2020 Proceedings

Authors: Tarmo Robal ,Hele-Mai Haav ,Jaan Penjam ,Raimundas Matulevicius

1st Edition

303057671X, 978-3030576714

More Books

Students also viewed these Databases questions

Question

4. Explain the strengths and weaknesses of each approach.

Answered: 1 week ago

Question

3. Identify the methods used within each of the three approaches.

Answered: 1 week ago