Question

In: Computer Science

(Python) Write a code converting degrees in Fahrenheit to degrees Kelvin, using this conversion equation conversion...

(Python)

Write a code converting degrees in Fahrenheit to degrees Kelvin, using this conversion equation

conversion from degrees Fahrenheit to Celcius:

? = (? − 32) x 5/9

and then to degrees Kelvin:

? = ? + 273.15

with the following properties

1) the code should take into account that temperature in degrees Kelvin cannot be smaller than zero. In other words, your code should return 0 Kelvin as the smallest temperature for any input value of degrees Fahrenheit).

2) arrange calculation in a loop and print out a table showing equivalent temperatures in Fahrenheit, Celcius and Kelvin in one line (outputing only numbers) starting from 100 Fahrenheit down until temperature in Kelvin becomes 0, using step of 5 degrees Fahrenheit.

Hint: you can use tab '\t' in your print statement to line up different numbers in your code.

3) rewrite this code to compute temperature in degrees Fahrenheit given an input in degrees Kelvin. Compute temperature of the surface of the Sun (≈6600 degrees Kelvin) in Fahrenheit.

Solutions

Expert Solution

The indentation in the answering window sometimes disappear automatically due to some technical issue on the website, please refer to the screenshots for indentation.

If you have any queries please comment in the comments section I will surely help you out and if you found this solution to be helpful kindly upvote.

Solution :

# part 1
# input the temperature in Fahrenheit
F = float(input("Enter the temperature in Fahrenheit: "))
# Convert to Celcius
C = (F-32)*(5/9)
# Now convert to Kelvin
K = C + 273.15
# if K is less than 0 then make K = 0
if K<0:
K=0
# display the result
print("Temperature in Kelvin:",round(K,2))

# part 2
print("")
# print Fahrenheit, Celcius and Kelvin
print("Fahrenheit\tCelcius\t\tKelvin")
# run an infinite loop until K becomes 0
F = 100
while(True):
# calculate Celcius
C = (F-32)*(5/9)
# calculate Kelvin
K = C + 273.15
# if K is negative then it must be 0
if K<=0:
K=0
# print Fahrenheit, Celcius and Kelvin and break from the loop
print(round(F,2),end="\t\t")
print(round(C,2),end="\t\t")
print(round(K,2),end="\t\t")
print("")
break
# print Fahrenheit, Celcius and Kelvin
print(round(F,2),end="\t\t")
print(round(C,2),end="\t\t")
print(round(K,2),end="\t\t")
print("")
# decrement F by 5
F = F - 5
  
# part 3
# convert from Kelvin to Fahrenheit
# input the temperature in Kelvin
K = float(input("\nEnter the temperature in Kelvin: "))
# Convert to Celcius
C = K - 273.15
# Convert to Fahrenheit
F = C*(9/5) + 32
# display the result
print("Temperature in Fahrenheit:",round(F,2))


Related Solutions

Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The...
Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The table should include rows for all temperatures between 0 and 100 degrees Celsius that are multiples of 10 degrees Celsius. Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit can be found on the internet. Python 3
Convert the boiling temperature of gold, 2966 °C, into degrees Fahrenheit and kelvin.
Convert the boiling temperature of gold, 2966 °C, into degrees Fahrenheit and kelvin.  
Temperature Conversion Menu (100 pts) The three common temperature scales are Celsius, Fahrenheit and Kelvin. The...
Temperature Conversion Menu (100 pts) The three common temperature scales are Celsius, Fahrenheit and Kelvin. The conversion formulae for each of the scales is shown below (where °C, °F and K represent the temperatures in degrees Celsius, degrees Fahrenheit and Kelvin respectively): Celsius to Fahrenheit: °F = (9.0/5) ´ (°C) + 32 Celsius to Kelvin: K = °C + 273.15 Kelvin to Celsius: °C = K – 273.15 Kelvin to Fahrenheit: °F = (9.0/5) ´ (K – 273.15) + 32...
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in...
Write a java program to convert Celsius degrees to Fahrenheit degrees the user enters degrees in Celsius and the program Coverts the input to Fahrenheit using the following formula T(°F) = T(°C) × 1.8 + 32 submit the source code Design output Load: 1. Design (Pseudocode ) 2. Source file (Java file, make sure to include comments) 3. Output file (word or pdf or jpig file)
a) write a python programme for converting url.to html please provide valid code and please share...
a) write a python programme for converting url.to html please provide valid code and please share screenshots to me
For these of string functions, write the code for it in C++ or Python (without using...
For these of string functions, write the code for it in C++ or Python (without using any of thatlanguage's built-in functions) You may assume there is a function to convert Small string into the language string type and a function to convert your language's string type back to Small string type. 1. int [] searchA,ll(string in...str, string sub): returns an array of positions of sub in in...str or an one element array with -1 if sub doesn't exist in in...str
Using python as the coding language please write the code for the following problem. Write a...
Using python as the coding language please write the code for the following problem. Write a function called provenance that takes two string arguments and returns another string depending on the values of the arguments according to the table below. This function is based on the geologic practice of determining the distance of a sedimentary rock from the source of its component grains by grain size and smoothness. First Argument Value Second Argument Value Return Value "coarse" "rounded" "intermediate" "coarse"...
"PYTHON" Write some code " USING PYTHON" to keep reading numbers from the user until the...
"PYTHON" Write some code " USING PYTHON" to keep reading numbers from the user until the users enters a negative number. The program then prints out: a) the sum of all the numbers b) the average of all the numbers c) the max of the numbers d) the min of the numbers Note we did not cover lists (array) so you will not use them in this problem. Finally, ask the user for their name, then print their name as...
(Python) a) Using the the code below write a function that takes the list xs as...
(Python) a) Using the the code below write a function that takes the list xs as input, divides it into nss = ns/nrs chunks (where nrs is an integer input parameter), computes the mean and standard deviation s (square root of the variance) of the numbers in each chunk and saves them in two lists of length nss and return these upon finishing. Hint: list slicing capabilities can be useful in implementing this function. from random import random as rnd...
Write a python code which prints triangle of stars using a loop ( for loop )...
Write a python code which prints triangle of stars using a loop ( for loop ) Remember what 5 * "*" does The number of lines of output should be determined by the user. For example, if the user enters 3, your output should be: * ** *** If the user enters 6, the output should be: * ** *** **** ***** ****** You do NOT need to check for valid input in this program. You may assume the user...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT