Input a temperature as a floating point

Assignment Help Python Programming
Reference no: EM13168079

A standard first program to give to students is to ask them to convert between these temperatures. That's what we'll be doing.

Your program should input a temperature as a floating point number with an appended unit letter. It should then print the temperature in all four of the units above, as a floating point number with a unit letter. Printed temperatures should have one decimal point of precision. For this assignment only, assume that the user of the program won't make a mistake, and will always enter a valid number immediately followed by a valid unit letter.

Here's a sample run from my version of the program:

    Enter a temperature with units F, C, K or R (e.g. 32.1F): 212F
    373.1K
    100.0C
    212.0F
    671.7R

Some hints on writing your conversion program:

  • The easiest way to proceed is to convert whatever temperature is input into K, and then convert that back to the four different output temperatures. That way you only have to write 6 lines of conversion instead of 12.

    The formula for conversion are as follows:

    • K = C + 273.15
    • K = (F - 32) * 5 / 9 + 273.15
    • K = R * 5 / 9
    • C = K - 273.15
    • F = (K - 273.15) * 9 / 5 + 32
    • R = K * 9 / 5
  • A function that might be useful to you when writing this, beyond the ones documented in the book, is round().

    • round(x, 1) rounds the floating point value x to 1 decimal place.
  • You will probably want to use string subscripting and array slicing to split the number from the unit indicator.

    numberStr = inputStr[0:-1]
    unitStr = inputStr[-1]
    

Reference no: EM13168079

Questions Cloud

Explain what is the volume of the balloon when it bursts : If the atmospheric pressure at 30 km is 28.0 torr and the temp is -48 C, what is the volume of the balloon when it bursts?
Using the following program as a guide : Using the following program as a guide, write a program reads in 2 scores in the main function.. Calls a function that will triple each number. In the function and the print the result in the main function.
Compute the volume of the bottle could deliver to a climber : calculate the volume of O2 the bottle could deliver to a climber at an altitude where the temp is -38 C and the atmospheric pressure is 0.40 atm.
A "mynum" class that will read "randfile.txt" file : A "MyNum" class that will read "randFile.txt" file and obtain the 20,000 integer numbers
Input a temperature as a floating point : Your program should input a temperature as a floating point number with an appended unit letter. It should then print the temperature in all four of the units above
Explain the total pressure in the flask : determine the total pressure in the flask AND the height difference between the two arms of the manometer.
Accept positive and negative numbers in its input sequence : the program must accept positive and negative numbers in its input sequence, and ?nd the largest and smallestof the numbers entered whether they are all positive, all negative, or a combination of both positive and negative.
The analog to digital converter : The Analog to Digital converter has V(t) as its input, and it outputs a binary word B(t) with a fixed length of k bits, which is its best approximation to V(t). Suppose that V(t) can vary continuously between zero and 5 volts
Explain what is the total pressure above the solution : What is the vapor pressure of each of the solution components in the mixture? What is the total pressure above the solution?

Reviews

Write a Review

Python Programming Questions & Answers

  Design a function that accepts an integer

Design a function that accepts an integer argument and returns the sum of all the integers from 1 up to the number passed as an argument. For example, if 50 is passed as an argument, the function will return the sum of 1, 2, 3, 4, . . . 50. Use recur..

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Implement functions for insertion sort

Implement functions for Insertion sort and bubble sort in python programming language and a function that calculates the function execution time.

  The interest rate per period

The interest rate per period. For example, if your loan's interest is 6.5% per year, and you are paying monthly, this would be 6.5%/12. If you are paying every two weeks, r would be 6.5%/26, because there are 26 two-week periods in a year.

  Specializes in solving the equations ax=b by doolittle''s dec

Write a  program that specializes in solving the equations Ax=b by Doolittle's decomposition method, where a is the HIbber matrix of arbitrary size nxn

  The dictionary order based on the ascii order

Needless to say, the dictionary order based on the ASCII order is not what a real-world indexing software wants. So, we want to implement the dictionary order of strings in the standard wa

  Write a program using the ''requetinteger''

using python/jython programming write a program using the 'requetInteger' function that will ask the user to type a value that will draw a line from one point on a picture to another. I don't need specific help just a gerneral idea.

  Define three types of programming errors

Define three types of programming errors and explain with examples

  The initial number for generating the sequences

Then, after the functions, read in the initial number for generating the sequences. Here, check that it is a positive integer. If it is not, give an error message and exit the program.

  Write a function rmduplic(l), where l is any list

Write a function rmDuplic(L), where L is any list. The function should return a list M that contains the same items as L, except that repetitions (duplicates) have been removed: only the first occurrence of each entry is kept (i.e., order is prese..

  Turn the turtle image into a .gif picture

How can you turn the turtle image into a .gif picture when using the built-in turtle for Python? If that's impossible how do you remove the line when you move the turtle around?

  Python errors

python errors, please correct them that are located in this program,

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd