IT 116: Introduction to Scripting
Homework 5

Due

Sunday, March 2nd 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 "inches" and "Centimeters".
    Print a line of dashes under the labels.
    Run the script.
    Fix any errors you find.
  3. Write a for using the loop variable inches 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 inches.
    Run the script.
    Fix any errors you find.
  4. Remove the print statement inside the for loop.
    Use the formula above to calculate the centimeters value and store it in the variable cm.
    Use round to turn this value into an integer.
    Print both inches and cm.
    Run the script.
    Fix any errors you find.
  5. Now you have to make sure the centimeter values align with the "centimeters" label.
    This can be done using the escape sequence for the tab character, \t.
    Replace the space between "inches" and "centimeters" in the label with \t.
    Now we need to concatenate the values of inches and cm into a string with \t between them.
    But numbers cannot be concatenated with strings.
    So you have to run the str string conversion function on both inches and cm.
    The easiest way to do this is to create the variable line which gets the value formed by concatenating str(inches) with \t and concatenating that with str(cm).
    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.