IT 116: Introduction to Scripting
Homework 10

Due

Sunday, April 14th at 11:59 PM

What You Need to Do

Setup On Your Machine

Specification

Functions

scores_list_create

	create an empty list
	for each line in the file:
	   set values for id and score using split()
	   turn score into an integer
	   add score to the list 
	return  the list

scores_average

	set total to 0
	for each value in the list:
	   add the value to total
	find the average by dividing total by the length of the list
	return the average using round to turn it into an integer

highest_lowest_scores

	
	return the highest and lowest values in the list using max & min

Test Code

Output

Suggestions

  1. Create a hashbang line on the first line of the script.
    Copy only the function headers for the four functions listed above into your script file.
    Under each header, write pass.
    Make sure this statement is indented.
    Run the script.
    Fix any errors you find.
  2. Remove the pass from scores_list_create.
    Create a an empty list.
    Write a for loop that prints every line in the file.
    Copy all of the test code to the bottom of your script.
    Comment out all but the first three lines of the test code.
    Do this by inserting # at the beginning of the line.
    Run the script.
    Fix any errors you find.
  3. Remove the print statement.
    Replace it with a statement that calls split on the line to assign values to the variables id and score.
    Print id and score.
    Run the script.
    Fix any errors you find.
  4. Remove the print statement.
    Replace it with an assignment statement that turns score into an integer using int().
    Append score to the list.
    Outside the for loop, print the list.
    Run the script.
    Fix any errors you find.
  5. Remove the print statement.
    Replace it with a statement that returns the list.
    Uncomment the next line in the test code.
    Run the script.
    Fix any errors you find.
  6. Remove the pass statement from scores_average.
    Replace it with a statement that sets total to 0.
    Write a for loop that prints each value in the list.
    Uncomment the next line in the test code.
    Run the script.
    Fix any errors you find.
  7. Remove the print statement.
    Replace it with a statement that adds score to total.
    Outside the for loop print total.
    Run the script.
    Fix any errors you find.
  8. Remove the print statement.
    Replace it with a statement that calculates average by dividing total by the length of the list.
    Use an assignment statement to make average an integer using round.
    Return average.
    Uncomment the next commented line in the test code.
    Run the script.
    Fix any errors you find.
  9. Remove the pass statement from highest_lowest_scores.
    Find the highest and lowest values using max and min.
    Return thses values Uncomment the last three lines in the test code.
    Run the script.
    Fix any errors you find.

Testing on Your Machine

Copy the Script to Unix

Testing the Script on Unix (Optional)

Copyright © 2022 Glenn Hoffman. All rights reserved. May not be reproduced without permission.