BELOW is the problemi have been working on and below that i

BELOW is the problemi have been working on , and below that is the python code. I feel like I am on the right path. I am having trouble bringing it all together. If someone can just do the problem and breifly explain by each line what is going on, I will greatly appreciate it. for the following program I need to:

Program functionality should execute as follows: o Create an array of 10 names that is initially populated with values. The pseudocode format for this array is given below: Declare String names[10] = “Ross Harrison”, “Hannah Beauregard”, “Bob White”, “Ava Fischer”, “Chris Rich”, “Xavier Adams”, “Sasha Ricci”, “Danielle Porter”, “Gordon Pike”, “Matt Hoyle”

Sort the array of 10 names in ascending (a to z) order using either the Bubble, Selection, or Insertion Sort algorithms. The names will be sorted by first and last name together (NOTE: Do not parse out the last name and sort by last name.) o Display the sorted list of names to the user with a descriptive message. o Prompt the user to enter a name to search and use the search name to determine if it is in the array of names. o If the name is found in the list, identify the ordered number (in the array) of the user requested name. If the name is not found in the list, display an error message indicating the name is not in the list. o Include a modular approach: no global variables, use parameters and return values to transfer data between modules and functions. • Include and use modules (at least) to do the following: o Main controlling start module to create variables, call sort and display modules, prompt for search name, call search function and display search results o Sort names array. o Display the names array • Include and use a function (at least) to do the following: o Search the names array for a given name and return the index of found, -1 otherwise. Use either the L

i am using idle python version 3.5 for this code.

# Author: asdf
# Date:    MM/DD/YYYY
# Program: Prog9_2.py
# Descr:
# In-class exercise to create the Python implementation
# of Bubble Sort Program 9-2 in Gaddis.

def main():
    testscores=[]
    # Constant for the array size
    SIZE = 9
    # Array to hold test scores
    testScores = [0, 0, 0, 0, 0, 0, 0, 0, 0]
    # Get the test scores
    getTestScores(testScores, SIZE)
    # Sort the test scores
    Sortnames(testScores, SIZE)
    # Display the test scores
    print(\'Here are the test scores sorted from lowest to highest.\')
    showTestScores(testScores, SIZE)
    displaynames(testscores)
    again = \"Y\"
    searchName=\"\"
    index=int()

    while again == \"Y\" or again == \"y\":
                  searchName= input(\'enter a name to search for: \')
                  index = testScores[0,0,0,0,0,0,0,0,0]
                  if index != -1:
                           print(\'The phone number is \' + str(testScores[0,0,0,0,0,0,0,0,0]))
                  else:
                                 print(searchName + \"was not found.\")

                  again=input(\"do you want to search again? (y=yes, n=no)\")
               

# The getTestScores module prompts the user
# to enter test scores into the array that is
# passed as an argument.
def getTestScores(array, arraySize):
    # Counter variables
    index = 0
    # Get the test scores
    for index in range (0, arraySize):
        array[index] = input(\'Enter score number \' + str(index + 1) + \' as integer: \')

# The showTestScores module displays the contents
# of the array that is passed as an argument.
def showTestScores(array, arraySize):
    # Counter variables
    index = 0
    # Display the test scores
    for index in range (0, arraySize):
        print(array[index])

# The bubbleSort module accepts an array of Integers
# and the array\'s size as arguments. When the module
# is finished, the values in the array will be sorted
# in ascending order.
def Sortnames(array, arraySize):
    #local variables declarations
    maxElement=int() #subscript of last element to compare.
    index = int(0) #array index variable
    #starting at end of array, push largest elements to end
    for maxElement in range(arraySize - 1, -1, -1):
        #inner loop from 0 to maxElement push largest to end
        for index in range(0, maxElement):
            #compare current with next and swap if needed
            if array[index] > array[index+1]: #change it to less then if you want least to greatest sort order.
                temp = array[index]
                array[index] = array[index+1]
                array[index + 1] = temp

        
    return

def displaynames(testscores):
    testscores=0
    print(testscores)

# start program
main()

Solution

def sort(names): # function to sort names list
   names = sorted(names)
   return names

def display(names): # function to display names list
   for name in names:
       print(name)

def search(name, names): # function to search name in names list
   for index in range(0,len(names)):
       if name == names[index]:
           return index
           break
   if index == len(names)-1: # name is not present in the names list
       return -1
      

def main():
   names = [\"Ross Harrison\", \"Hannah Beauregard\", \"Bob White\", \"Ava Fischer\", \"Chris Rich\", \"Xavier Adams\", \"Sasha Ricci\", \"Danielle Porter\", \"Gordon Pike\", \"Matt Hoyle\"]
   names = sort(names)
   display(names)
   print(search(\"Gordon Pike\", names))

main()

BELOW is the problemi have been working on , and below that is the python code. I feel like I am on the right path. I am having trouble bringing it all together
BELOW is the problemi have been working on , and below that is the python code. I feel like I am on the right path. I am having trouble bringing it all together
BELOW is the problemi have been working on , and below that is the python code. I feel like I am on the right path. I am having trouble bringing it all together

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site