IT 116: Introduction to Scripting
Homework 4

Due

Sunday, September 28th at 11:59 PM

What You Need to Do

Setup On Your Machine

Specification

Color Wavelength (nm)
No color Greater than 760
Red 610–760
Orange 590–609
Yellow 570–589
Green 500–569
Blue 450–499
Violet 380–449
No color Less than 380

Output

Suggestions


  1. Write an assignment statement which asks the user for a wavelength and stores it in the variable wavelen.
    Convert the value of wavelen using int().
    Print the value of wavelen .
    Save the file and quit.
    Run the script to make sure it works properly.
    If it does not work, fix the problem.
  2. Remove the print statement you wrote in the previous step.
    Replace it with an if statement that will run if the value of wavelen is more than 750.
    Inside the if write an assignment statement that gives color the value "No color".
    Outside this statement, print the value of color.
    Run the script.
    Fix any errors you find.
  3. Underneath the if statement but before the print statement, write and elif clause that runs if the value of wavelen is greater than or equal to 610.
    Inside the elif clause write an assignment statement that gives color the value "Red".
    Run the script.
    Fix any errors you find.
  4. Repeat the steps above for the remaining colors.
  5. After the last elif clause, write an assignment statement that gives color the value "No color".
    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.