IT 116: Introduction to Scripting
Homework 3
Due
Sunday, February 16th at 11:59 PM
What You Need to Do
- Create the script hw3.py
- Make sure it obeys the rules in
Rules for Homework Scripts
- Move it to an an hw3
directory on pe15.cs.umb.edu
Setup On Your Machine
- Open a text editor.
I would suggest the text editor built into the program IDLE
.
- Save the file as hw3.py
Specification
- This program will convert inches into centimeters and vice versa
- The program must prompt the user for a value in inches
- Then convert this value to centimeters
- And print the converted value
- The converted value must be an integer
- Then a blank line should be printed
- Now the program must prompt the user for a value in centimeters
- This value must be converted to inches
- Then print the converted value
- Again the converted value must be a integer
- You convert inches to centimeters using the formula
cm = inches * 2.54
- You convert centimeters to inches using the formula
inches = cm * 0.39370079
Output
Suggestions
- Write this script in stages
- Test your script at each step
- Print the steps below
- And check them off as you finish each one
-
Write an assignment statement which asks the user for a value in
inches and stores it in the variable
inches.
Convert the value of inches using
int()
.
Write a print statement to print the value of
inches.
Save the file and quit.
Run the script to make sure it works properly.
If it does not work, fix the problem.
-
Write an assignment statement that calculates the centimeters value
and assigns it to the variable cm.
Use the formula above and the value of the variable
inches.
Write a print statement to print the rounded Centimeter value.
Save the file and quit.
Run the script to make sure it works properly.
An inches value of 6 should give a centimeters value of 15.
A centimeters value of 15 should give a inches value of 6.
If it does not work, fix the problem.
-
Repeat the above to convert centimeters to inches.
Testing on Your Machine
Copy the Script to Unix
- Open FileZilla and connect to
pe15.cs.umb.edu
- Go to your it116 directory
- Go to your hw directory
- Right-click in the whitespace inside the
hw directory
- Enter hw3 in the dialog box
- Click and drag your script from the bottom left panel
to the bottom right panel
Testing the Script on Unix (Optional)
Copyright © 2021 Glenn Hoffman. All rights reserved. May not be reproduced without permission.