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

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  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 atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  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.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  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.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  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.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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