Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Length Conversions Frequently in life you'll need to convert from one unit to another: feet to meters, hours to seconds, degrees to radians, etc. Usually,

Length Conversions
Frequently in life you'll need to convert from one unit to another: feet to meters, hours to seconds, degrees to radians, etc. Usually, the conversion simply involves a simple conversion factor, meaning that you multiply or divide by a real number.
In this assignment, you'll input a length as some number of feet and inches, and convert that to a number of other length values. Finally, you'll print out the results in a nice format. See the examples below.
How to ask for user input: In your program you'll need to prompt the user to enter the number of feet and the number of inches to convert. The input function is not covered until slideset 3, but it's pretty easy. To get the values of the feet and inches into two variables inputFeet and inputInches, you'll include the following two statements:
inputFeet input("Enter number of feet: "))
inputInches = int( input("Enter number of inches: "))
When each statement is executed, it prints the prompt (e.g., "Enter number of feet: ") on the screen, and waits for the user to enter a number. After the user types in a number, say 10000, this number is read by the program as a string, say "10000". Then the function int() will convert that string into the corresponding integer value which will be stored in the variable inputFeet. The second statement will do an analogous thing for variable inputInches. From there you're good to go. Notice we didn't name those variables feet and inches because we'll use those for some other values.
You can assume that the year entered is a positive integer. (It would be easy to convert this program to accept floats; that would only require changing one word in the input statements above. Can you guess what you'd change?) Your program doesn't have to check that and doesn't have to work if the user enters a bad value. We won't test your program on illegal values.
Doing the conversions: After you've input those two values, you'll then do the conversions indicated in the following table. We suggest you do them in this order.
inches
inputFeet times 12, plus inputInches
inches divided by 12
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Structured Search For Big Data From Keywords To Key-objects

Authors: Mikhail Gilula

1st Edition

012804652X, 9780128046524

More Books

Students also viewed these Databases questions

Question

Were they made on a timely basis?

Answered: 1 week ago