Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

bartleby

Concept explainers

Question

Write a Python program that prompts the user to enter a numeric temperature value that may be a float. A second prompt should then ask the user to indicate whether the user wants the entered temperature value converted to degrees Celsius or degrees Fahrenheit by entering either an 'F' or a 'C' for a second prompt.

For example, if the user enters 212 at the first prompt and the character C for the second prompt you are to convert 212 degrees F to the Celsius equivalent (which would be 100.0). Converted temperatures should be rounded to 1 decimal place.

If the user enters 26 at the first prompt and the character F at the second one, then your programs should convert 26 degrees C to the Fahrenheit equivalent (which is 78.8 deg F)

Your conversion formulas are:

degF = 1.8 * degC + 32       //convert Celsius to Fahrenheit

degC = (degF - 32) / 1.8     //convert Fahrenheit to Celsius

  • Have your converted values be floats rounded to 1 decimal place.
  • The F or C entry should be case-insensitive. The user should be able to enter F or f for a Fahrenheit conversion, or a C or c for a Celsius conversion. But if the user doesn't enter an F, f, C or c, then display an error message and exit the program rather than performing the calculation
  • Use the decision structure of your choosing to determine whether to convert the input value to degF or degC or to exit.
  • Your output should contain both the original temperature entered and the proper output temperature, labeled as to which is which. Something like this: 212 degrees F = 100.0 degrees C
Your prompt strings might look something like this, although you can choose your own words.
Please enter a temperature value to convert:
Convert to Fahrenheit or Celsius? Enter either F or C:
A possible example program run might look like this, where 50 deg C is converted to 122.0 deg F. Your output should indicated
which number is in which temperature system, like the following.
76 Python Shell
File Edit
Shell Debug Options Windows Help
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:4
8) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license ()" for more inf
ormation.
>>>
RESTART
>>>
Enter a temperature value to convert: 50
Convert to Fahrenheit or Celsius? Enter F or C: f
50.0 deg C = 122.0 degrees F
>>> |
And, what if the user does not enter an F, f, C, or c? Suppose they type in k or simply hit enter without typing any character at
all?. Then your output should look similar to the following. You do not have to account for all possible user input errors, and for
this program you can assume the user will not enter a number that is lower than absolute zero.
76 Python Shell
File Edit Shell Debug Options Windows Help
Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:4
8) [MSC v.1600 32 bit (Intel)] on win32
Type "copyright", "credits" or "license () " for more inf
ormation.
>>>
RESTART
==
>>>
Enter a temperature value to convert: 45.2
Convert to Fahrenheit or Celsius? Enter F or C: m
You did not enter an F or C.
Goodbye
>>> |
If you get good and stuck email me your code and we'Il get it working.
expand button
Transcribed Image Text:Your prompt strings might look something like this, although you can choose your own words. Please enter a temperature value to convert: Convert to Fahrenheit or Celsius? Enter either F or C: A possible example program run might look like this, where 50 deg C is converted to 122.0 deg F. Your output should indicated which number is in which temperature system, like the following. 76 Python Shell File Edit Shell Debug Options Windows Help Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:4 8) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license ()" for more inf ormation. >>> RESTART >>> Enter a temperature value to convert: 50 Convert to Fahrenheit or Celsius? Enter F or C: f 50.0 deg C = 122.0 degrees F >>> | And, what if the user does not enter an F, f, C, or c? Suppose they type in k or simply hit enter without typing any character at all?. Then your output should look similar to the following. You do not have to account for all possible user input errors, and for this program you can assume the user will not enter a number that is lower than absolute zero. 76 Python Shell File Edit Shell Debug Options Windows Help Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:4 8) [MSC v.1600 32 bit (Intel)] on win32 Type "copyright", "credits" or "license () " for more inf ormation. >>> RESTART == >>> Enter a temperature value to convert: 45.2 Convert to Fahrenheit or Celsius? Enter F or C: m You did not enter an F or C. Goodbye >>> | If you get good and stuck email me your code and we'Il get it working.
Expert Solution
Check Mark
Still need help?
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The code works, execpt:

Have your converted values be floats rounded to 1 decimal place.

How do you make it round to 1 decimal place?

 

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

The code works, execpt:

Have your converted values be floats rounded to 1 decimal place.

How do you make it round to 1 decimal place?

 

Solution
Bartleby Expert
by Bartleby Expert
SEE SOLUTION
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education