Question

John Brown, career counselor, needs a program that will sort student names. Write a program that...

John Brown, career counselor, needs a program that will sort student names. Write a program that will sort a list of 10 student names that is inputted by the user. Save the program as studentsort.py. Comment the program as to which sort method was used.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

I have used insertion sort ..

Here is code:

def sortList(list):

for i in range(1, len(list)):

key = list[i]

j = i - 1

while j >= 0 and key < list[j]:

list[j+1] = list[j]

j -= 1

list[j+1] = key

return list



l = ["Otto Denekamp","Mac Andrin","Shandie Fuggles","Jenna Orknay","Flore Ezzell","Si Fernao","Ediva Edgley","Sayers Albisser","Trenna Wabersich","Morgana Symons"]

print("Array list before sort :")

print(l)

print(" Array list after sort :")

print(sortList(l))


Output:

Add a comment
Know the answer?
Add Answer to:
John Brown, career counselor, needs a program that will sort student names. Write a program that...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • Write a program in C++ to: 1. Read up to 10 names and 10 test scores...

    Write a program in C++ to: 1. Read up to 10 names and 10 test scores from the keyboard (provide a method to end the input) (2 points); 2. print out the names and scores in a two column format (2 points); 3. use the function sort (you have to develop one) to sort the list according to test scores(4 points); 4. print out the sorted names and scores in a two column format (2 points)

  • Write a program that prompts the user to enter a list of names. Each person's name...

    Write a program that prompts the user to enter a list of names. Each person's name is separated from the next by a semi-colon and a space (: and the names are entered lastName, firstName (i.e. separated by ',). Your program should then print out the names, one per line, with the first names first followed by the last names. A sample run of your program should look like Please enter your list of names: Epstein, Susan; St. John, Katherine;...

  • JAVA question: Write a program to sort the following US States in their natural order :...

    JAVA question: Write a program to sort the following US States in their natural order : Missouri, Illinois, California, Washington, Maine. HINT : Create a List of the States and user the sort method of the Collections interface. Please copy and paste your code below.

  • C++ Visual Studios Program - Simple The program must use a Vector. Topic: Carl's Cab Stand...

    C++ Visual Studios Program - Simple The program must use a Vector. Topic: Carl's Cab Stand needs a program to keep track of their daily clients. Your program shall allow the user to enter 10 names. You will then retrieve the names, one by one, from the data structure (using the appropriate method of retrieval for each data structure) and present them on-screen so that Carl knows who to service next. Include a printed line at the end of the...

  • C# Write a program that takes a list of information and grades of the students of...

    C# Write a program that takes a list of information and grades of the students of a class and perform some processing. Take the following steps to write the program. The program must give the user two options such as a menu. At the beginning of the program must ask the following from the user: Which task you want to do (choose an option between 1-2), 1- Entering new information 2- Searching a student If the user types something rather...

  • ***PLEASE USE C++ LANGUAGE*** Binary Search of Strings 1. Write a version of the selection sort...

    ***PLEASE USE C++ LANGUAGE*** Binary Search of Strings 1. Write a version of the selection sort algorithm presented in the unit, which is used to search a list of strings. 2. Write a version of the binary search algorithm presented in the unit, which is used to search a list of strings. (Use the selection sort that you designed above to sort the list of strings.) 3. Create a test program that primes the list with a set of strings,...

  • Write a Python program that keeps reading in names from the user, until the user enters...

    Write a Python program that keeps reading in names from the user, until the user enters 0. Once the user enters 0, you should print out all the information that was entered by the user. Use this case to test your program: Input: John Marcel Daisy Samantha Nelson Deborah 0 ================ Output: John Marcel Daisy 25 Samantha Nelson Deborah Hints: Create an array Names to hold the input names. Use the Names.append(x) function to add a new name to the...

  • Write a program in C language that gets a list of names from user. The list...

    Write a program in C language that gets a list of names from user. The list ends when the user gives ‘quit’. The program should then print all the names provided by the user and the frequency of each name. Assume each name is at most of size 100 characters.

  • Write a program in Java according to the following specifications: The program reads a text file...

    Write a program in Java according to the following specifications: The program reads a text file with student records (first name, last name and grade on each line). Then it prompts the user to enter a command, executes the command and loops. The commands are the following: "print" - prints the student records (first name, last name, grade). "sortfirst" - sorts the student records by first name. "sortlast" - sorts the student records by last name. "sortgrade" - sorts the...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT