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 prgram using python

Design a prgram USING PYTHON that students can use to calculate what score they need on final exam to get a certan final grade for a course.

  Assume an n × n matrix a is given

Assume an n × n matrix A is given, containing only 1's and 0's, such that, in each row, all 1's come before all 0's. Give an O(n log n) algorithm to count all 1's in A.

  A stack data structure that uses a linked list for storing

In Python, implement a stack data structure that uses a linked list for storing its elements. In particular, you will need to implement the following three functions: 1. top(): This function returns the element that is at the top of the stack, but it..

  Code for the haunted house game

Improve the game by adding more features, for example you can examine more items, more props etc. You may implement this using more lists regarding items and props, remember, you should check if the object is being carried or in the location of th..

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  Project will be a simple, working program

This programming project will be a simple, working program, using Python language, which utilizes a good design process and includes:Sequential, selection, and repetitive programming statements as well as,At least one function call.

  Interaction between the customer and the machine

In Python:Simulate a cash register or ATM including the interaction between the customer and the machine (i.e. assume that you are automating the responses)

  Console program where you will implement

Create a console program where you will implement coding constructs and variables that are needed for this program and will implement the code within Main and any required static methods.

  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?

  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.

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