IT 116: Introduction to Scripting
Homework 5

Due

Sunday, March 1st at 11:59 PM

What You Need to Do

Setup On Your Machine

Specification

Output

Suggestions


  1. Get values for the variables min and max using assignment statements and the input function.
    Convert both min and max to integers.
    Print max and min.
    Run the script.
    Fix any errors you find.
  2. Remove the print statement you created above.
    Write a print statement that prints a blank line.
    Print the labels "Kms" and "Miles".
    Print a line of dashes under the labels.
    Run the script.
    Fix any errors you find.
  3. Write a for using the loop variable km and the range function.
    Range should produce all the values between min and max.
    Think carefully when choosing the arguments for range.
    Inside the loop print the value of km.
    Run the script.
    Fix any errors you find.
  4. Remove the print statement inside the for loop.
    Use the formula above to calculate the miles value and store it in the variable miles.
    Now you need to use round to turn miles into an integer.
    Print both km and miles.
    Run the script.
    Fix any errors you find.
  5. Now you have to make sure the miles values align with the "Miles" label.
    This can be done using the escape sequence for the tab character, \t.
    Change the print statement for the header label.
    Instead of giving print 2 arguments, give it one, a string that concatenates "Kms", \t and "Miles".
    Now we need to change the statement that prints km and miles.
    Remove the two arguments to print and replace them with a single string.
    That string concatenates the values of km and miles turned into strings with \t between them.
    So change the argument to print to
    str(miles) + \t + str(km)
    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.