IT 116: Introduction to Scripting
Homework 10

Due

Thursday, October 23rd at 11:59 PM

What You Need to Do

Setup On Your Machine

Specification

Functions

temp_list_from_file


mean_temp

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

max_min_temp

Test Code

Output

Suggestions

  1. Create a hashbang line on the first line of the script.
    Copy only the function headers for the three 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 statement from temp_list_from_file.
    Replace it with a statement that creates the empty list list.
    Write a for loop that prints every line in the file.
    Add the test code to the bottom of the sfgcript.
    Comment out all but the first three lines of the test code.
    Run the script.
    Fix any errors you find.
  3. Remove the print statement.
    Replace it with a statement that uses split on the line to assign values to the variables date and temp.
    Print temp.
    Run the script.
    Fix any errors you find.
  4. Remove the print statement.
    Replace it with a statement that turns each temp value into an integer and appends temp to list.
    Outside the for loop print list.
    Run the script.
    Fix any errors you find.
  5. Remove the print statement.
    Replace it with a statement that returns list.
    Remove the pass statement from mean_temp.
    Replace it with a statement that sets total to 0.
    Print the parameter list.
    Uncomment the next line in the test code.
    Run the script.
    Fix any errors you find.
  6. Remove the print statement.
    Replace it with a for loop over list using temp as the loop variable.
    Inside the loop print temp.
    Run the script.
    Fix any errors you find.
  7. Remove the print statement.
    Replace it with a statement that adds temp 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 sets average to total divided by the length of list.
    Print average.
    Run the script.
    Fix any errors you find.
  9. Remove the print statement.
    Replace it with a return statement that returns average turned into an integer using round.
    Uncomment the next line in the test code.
    Run the script.
    Fix any errors you find.
  10. Remove the pass statement from max_min_temp.
    Replace it with a statement that sets maximum by running max on list.
    Add as statement that sets minimum by running min on list.
    Print maximum and minimumn.
    Uncomment the next line in the test code.
    Run the script.
    Fix any errors you find.
  11. Remove the print statement.
    Replace it with a statement that returns the maximum and the minimum.
    Uncomment the last 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.