Question
  • Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list,
    a = [
        [93, 80, 99, 72, 86, 84, 85, 41, 69, 31],
        [15, 37, 58, 59, 98, 40, 63, 84, 87, 15],
        [48, 50, 43, 68, 69, 43, 46, 83, 11, 50],
        [52, 49, 87, 77, 39, 21, 84, 13, 27, 82],
        [64, 49, 12, 42, 24, 54, 43, 69, 62, 44],
        [54, 90, 67, 43, 72, 17, 22, 83, 28, 68],
        [18, 12, 10, 73, 81, 40, 56, 33, 37, 19],
        [81, 72, 88, 92, 76, 21, 25, 20, 23, 58],
        [28, 79, 33, 22, 16, 66, 35, 84, 74, 55],
        [21, 46, 75, 21, 52, 74, 79, 91, 42, 20],
        [63, 37, 67, 48, 14, 91, 47, 87, 83, 34],
        [70, 85, 28, 19, 40, 50, 23, 23, 70, 11],
        [58, 89, 69, 43, 56, 30, 99, 27, 11, 32],
        [70, 34, 33, 41, 49, 47, 72, 92, 45, 29],
        [71, 85, 90, 31, 98, 74, 13, 83, 20, 49],
        [56, 46, 76, 66, 93, 19, 56, 71, 16, 77],
        [12, 22, 71, 71, 90, 44, 97, 18, 51, 29],
        [66, 96, 64, 67, 12, 71, 29, 78, 13, 27],
        [31, 71, 56, 22, 40, 13, 46, 81, 34, 51],
        [83, 10, 26, 56, 34, 24, 51, 65, 27, 70]
    ]

    like this,

    [93, 80, 99, 72, 86, 84, 85, 41, 69, 31]
    [15, 37, 58, 59, 98, 40, 63, 84, 87, 15]
    [48, 50, 43, 68, 69, 43, 46, 83, 11, 50]
    ...
    [21, 46, 75, 21, 52, 74, 79, 91, 42, 20]
    [63, 37, 67, 48, 14, 91, 47, 87, 83, 34]
    [70, 85, 28, 19, 40, 50, 23, 23, 70, 11]
    ...
    [66, 96, 64, 67, 12, 71, 29, 78, 13, 27]
    [31, 71, 56, 22, 40, 13, 46, 81, 34, 51]
    [83, 10, 26, 56, 34, 24, 51, 65, 27, 70]
    

    if called with the arguments a and 3. Note: If your version prints the middle section like this, instead,

    [28, 79, 33, 22, 16, 66, 35, 84, 74, 55]
    [21, 46, 75, 21, 52, 74, 79, 91, 42, 20]
    [63, 37, 67, 48, 14, 91, 47, 87, 83, 34]

    that's fine, too. It probably means that your function is selecting "middle" elements from the list slightly differently from my solution. However, you should adjust the comments in the test code at the bottom of the module to reflect changes in expected output.

    Your completed function must conform to the CISC 121 Programming Style Guide for Python 3.

  • Create a dict_bin_search.py module that works with a4.py's code as written. Note: You are not allowed to make changes to a4.py. Your new module should implement a binary search function called search(). Unlike the example shown in lecture, this function need to search lists of dictionaries based on the value of a particular key, so in addition to a list parameter, it will need a parameter for the selected key, and you'll have to make slight adjustments to the code for the function to accommodate the extra parameter.

    Your completed module must conform to the CISC 121 Programming Style Guide for Python 3, and include useful, correctly formatted docstrings and comments.

  • Create a dict_quad_sorts.py module that works with a4.py's code as written. Note: You are not allowed to make changes to a4.py. Your new module should implement the quadratic sorts shown in lecture, that is,
    • insertion sort, in a function called insersion_sort()
    • bubble sort, in a function called bubble_sort()
    • optimized bubble sort, in a function called bubble_sort_opt()
    • selection sort, in a function called selection_sort()

    Unlike the examples shown in lecture, these functions need to sort lists of dictionaries based on the values of particular keys, so in addition to a list parameter, they'll need a parameter for the selected key, and you'll have to make slight adjustments to the code for each function to accommodate the extra parameter.

    def print_list (a_lit, section_size): Print entire list a_list if its length is less than or equal to 3 times section_size (

  • # Test with demo list from Assignment 4. a = 1 [93, 80, 99, 72, 86, 84, 85, 41, 69, 31), [15, 37, 58, 59, 98, 40, 63, 84, 87,

  • import web_scraper import parse_logons import dict_quad_sorts import dict_bin_search import long_list_printer import menu def

* -*_* _*vvvv if sort_on_choice is None: break # Return to main menu. sort_on_key = sort_on_menu_choices[sort_on_choice-1] #

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

Given below is the code for the question. PLEASE MAKE SURE INDENTATION IS EXACTLY AS SHOWN IN IMAGE.
Please do rate the answer if it helped. Thank you.


def print_list(a_list, section_size):
   if len(a_list) <= 3*section_size or section_size == 0:
       for e in a_list:
           print(e)
   else:
       #print first section
       for e in a_list[0:section_size]:
           print(e)
       print('...')
      
       #print mid section
       half = section_size // 2
       start = len(a_list)//2 - half
       end = len(a_list)//2 + half + 1
       for e in a_list[start:end]:
           print(e)
       print('...')
      
       #print last section
       for e in a_list[-section_size:]:
           print(e)

def print_list (a_list, section_size): if len(a_list) <= 3*section_size or section_size =-.0: - > for.e.ina_list: --> > print

Add a comment
Know the answer?
Add Answer to:
Complete function long_list_printer.print_list(). When it's finished, it should be able to print this list, a =...
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
  • Consider the below matrixA, which you can copy and paste directly into Matlab.

    Problem #1: Consider the below matrix A, which you can copy and paste directly into Matlab. The matrix contains 3 columns. The first column consists of Test #1 marks, the second column is Test # 2 marks, and the third column is final exam marks for a large linear algebra course. Each row represents a particular student.A = [36 45 75 81 59 73 77 73 73 65 72 78 65 55 83 73 57 78 84 31 60 83...

  • NUMBER OF PEOPLE 10.2 10.0 10.1 8.5 10.2 8.2 8 Source: United States Census. 11. In...

    NUMBER OF PEOPLE 10.2 10.0 10.1 8.5 10.2 8.2 8 Source: United States Census. 11. In the Sanitary District of Chicago, operating engineers are hired on of a competitive civil-service examination. In 1966, there were 223 appl for 15 jobs. The exam was held on March 12; the test scores are s arranged in increasing order. The height of each bar in the histogram next page) shows the number of people with the correspondin examiners were charged with rigging the...

  • 1. Forecast demand for Year 4. a. Explain what technique you utilized to forecast your demand....

    1. Forecast demand for Year 4. a. Explain what technique you utilized to forecast your demand. b. Explain why you chose this technique over others. Year 3 Year 1 Year 2 Actual Actual Actual Forecast Forecast Forecast Demand Demand Demand Week 1 52 57 63 55 66 77 Week 2 49 58 68 69 75 65 Week 3 47 50 58 65 80 74 Week 4 60 53 58 55 78 67 57 Week 5 49 57 64 76 77...

  • Please show how you did this in excel. :13-19 Every home football game for the past...

    Please show how you did this in excel. :13-19 Every home football game for the past eight years at Eastern State University has been sold out. The revenues from ticket sales are significant, but the sale of food, beverages, and souvenirs has contrib- uted greatly to the overall profitability of the football program. One particular souvenir is the football pro- gram for each game. The number of programs sold at each game is described by the following probabil- ity distribution:...

  • Calculate the range, mean, mode, median, Standard deviation Calculate the skewness and kurtosis for the above...

    Calculate the range, mean, mode, median, Standard deviation Calculate the skewness and kurtosis for the above data and interpret the data. The following is data collected from the daily salary employees of ZZ COMPANY.. 68 19 43 11 37 30 19 67 65 34 96 23 93 73 46 39 21 12 89 52 33 21 18 57 80 56 91 62 56 48 84 23 78 96 49 36 90 42 65 15 43 36 65 59 34 71...

  • The given data is the grades for people in this class. The goal here is to...

    The given data is the grades for people in this class. The goal here is to determine the factors that effect student's Grade in the class. 4) Find the mean and median for the men's and the women's Quizzes. Gender Men Women 5) Test the claim that the majority of students at this class are women. F M F F M F F F F M M F F F M F F F F M M F F M...

  • Write a python nested for loop that prints out the following pattern 100 99 98 97...

    Write a python nested for loop that prints out the following pattern 100 99 98 97 96 95 94 93 92 91 90 89 88 87 86 85 84 83 82 81 80 79 78 77 76 75 74 73 72 71 70 69 68 67 66 65 64 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33...

  • Use the accompanying data set on the pulse rates​ (in beats per​ minute) of males to...

    Use the accompanying data set on the pulse rates​ (in beats per​ minute) of males to complete parts​ (a) and​ (b) below. LOADING... Click the icon to view the pulse rates of males. a. Find the mean and standard​ deviation, and verify that the pulse rates have a distribution that is roughly normal. The mean of the pulse rates is 71.871.8 beats per minute. ​(Round to one decimal place as​ needed.) The standard deviation of the pulse rates is 12.212.2...

  • python program do not use dictionary, list only Complete the program found in assignment4.py. You may...

    python program do not use dictionary, list only Complete the program found in assignment4.py. You may not change any provided code. You may only complete the sections labeled: #YOUR CODE HERE Write a program that does the following. Reads the contents of Text from the include file, input.txt Create a dictionary of key-value pairs called index.txt Key: This represents the individual word Value: This is a list of the line number from Text where Key appeared Example: If the word...

  • The following data represent glucose blood levels (mg/100 ml) after a 12-hour fast for a random...

    The following data represent glucose blood levels (mg/100 ml) after a 12-hour fast for a random sample of 70 women (Reference American Journal of Clinical Nutrition, Vol. 19, pp. 345-351) 45 668) 71 75 64 59 59 75 82 B0 81 85 77 82 90 87 72 70 69 83 71 87 69 81 76 96 83 67 94 101 94 89 94 73 99 93 85 83 90 78 80 85 83 84 74 81 70 65 89 70...

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