CSCI 152 Lists Practice

Skill set for this LAB:

  1. In this program you will process inventory of some store. In that store, there is a DOLLAR value section which has items that cost LESS than 1 dollar, FIVE_BELOW section which has items that cost between 1 and 5 dollars (inluding 1 and 5), and the GENERAL_AREA section which has the rest of the items. The largest price in the store is 500 dollars. Write a function

    def separate(price_list)

    that has one parameter - list of prices, the function creates and RETURNS 3 new lists - list of prices in DOLLAR secion, list of prices in FIVE_BELOW secion, and list of prices in GENERAL_AREA section.

    Write a program that randomly generates the list of prices of size 20, call function separate to get list of prices for each section, and then find the section with the LARGEST number of items.

    Pay attention: you have to use random.uniform(0, 500) to generate FLOATING POINT number in required range.

  2. Write a function def sum_ave_odd_index(my_list) that finds and returns the sum and average of ALL elements on ODD positions in the list. Write main to test your program

  3. In figures skating, there is a pre-competetion assessment. During the assessment, all skaters who received the score below certain threshold are not allowed to compete in the actual tournament. Write a function def remove_below(scores, threshold) that has two parameters, list of scores and the score threshold. The function removes all scores below the threshold from the list and creates a list of all scores below the threshold. The function returns the number of skaters who would not be able to compete and the list of their scores. Write a program that asks user to enter the number of skaters and the score for each skater - FLOAT NUMBER between 1.0 and 100.0 and uses functon remove_below to find the number of the skaters who would be able to continue, along with their scores, and the number of skaters who would not be able to continue along with their scores.

  4. In this program you will perform some statistical analysis of the grades in some course. Write a program that first asks user to enter the number of students in the class. Then the program asks user to enter the grade for each student in class. The results are stored in the list of integers. Assume that the input is valid. The program must find the following (write separate function for each task):