Question
Solve the following python question,
Use only if, else, elif
solve in clear formats.
Exercise 5: Write a Python program that reads a temperature value and the letter C for Celsius of F for Fahrenheit. Your prog
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Exercise 5:

temp, unit = input('Please enter temperature: ').split() #Input
temp = int(temp) # Convert temperature to int
if unit == "C": # If temperature is in Celsius
  if temp <= 0:
    print('Water in solid state')
  elif temp >= 100:
    print('Water in gaseous state')
  else:
    print('Water in liquid state')
else: # Temperature is in Fahrenheit
  if temp <= 32:
    print('Water in solid state')
  elif temp >= 212:
    print('Water in gaseous state')
  else:
    print('Water in liquid state')

SAMPLE OUTPUT:
main.py 日 っsaved temp, unit input(. Please enter temperature: ).split() #Input temp int(temp) # Convert temperature to int i

main.py 日 っsaved temp, unit input(Please enter temperature: ).split() #Input temp int(temp) # Convert temperature to int if

Add a comment
Know the answer?
Add Answer to:
Solve the following python question, Use only if, else, elif solve in clear formats. Exercise 5:...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Create a program using MIPS that does the following: The program will do the following: Prompt...

    Create a program using MIPS that does the following: The program will do the following: Prompt the user to enter a letter indicating Celsius or Fahrenheit C or c indicates that temperature entered is in Celsius. F or f indicates that temperature entered is in Fahrenheit. If the letter entered is not C, c, F, or f, print out error message "Wrong Letter!". Prompt the user to enter an integer indicating the temperature matching the letter just entered. Convert the...

  • Programming Language: C# We all know that water can exist in solid, liquid and gaseous form....

    Programming Language: C# We all know that water can exist in solid, liquid and gaseous form. Using Visual Studios Write a program that inputs the temperature for water in degrees Celsius, converts the temperature to degrees Fahrenheit according to the formula F = 9.0/5.0 * C + 32.0 and then prints both temperatures to a list box, message box or text box(s). In addition, the program will print the form of water (solid, solid or liquid, liquid, liquid or gas,...

  • Create a Python list (use first three letters of your name followed by the letter L...

    Create a Python list (use first three letters of your name followed by the letter L as the name of the list.) with the following data: 10, 20.0, 50.00, 7000, 7500, 7700, 7800, 8000, 9000, ‘python’. Display the entire list with an appropriate message. Display the 4th element in the list with an appropriate message. Display the first 3 values of the list only. Display all the values starting from the sixth element to the end of the list. Change...

  • Solve This Problem using python and please comment on every line. also, use function to solve...

    Solve This Problem using python and please comment on every line. also, use function to solve this. thanks The result will be like as below: Write a program that asks the user to enter five test scores. The program should display a letter grade for each score and the average test score. Write the following functions in the program: This function should accept five test scores as arguments and return the average of the scores. This function should accept a...

  • THE ATTACHMENTS:( needed to solve the problem above) (1) My Morse Code Program: #03/22/2018 #Creating a...

    THE ATTACHMENTS:( needed to solve the problem above) (1) My Morse Code Program: #03/22/2018 #Creating a program that translates sentences in to morse code def main():    morsecode_dict={}    line=""   f1 = open("MorseCode.txt",'r');    content = f1.readlines()    for x in content: #print x x=x.split() my_dict[x[0]]=x[1] print (morsecode_dict)    val=raw_input("Enter a String value: ") val.upper() output=""    for i in val: print (i.upper()) if(i!=' '): output = output + morsecode_dict[i.upper()]+' ' else: output = output+'\n' print ("-----Morse Code of The...

  • Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b):...

    Use only if else nested if else only otherwise your answer won't be entertained. Problem 1(b): Write a program that gives remainder without using modulus operator and loops. The first number entered will be dividend and second number entered will be divisor. Sample input: 15 6 Sample output: Remainder is 3 In a right triangle, the square of the length of one side is equal to the sum of the squares of the length of the other two sides. Write...

  • Use both pseudocode and flowcharts to solve the problems below: 1. Write a program that converts...

    Use both pseudocode and flowcharts to solve the problems below: 1. Write a program that converts a user-entered Fahrenheit temperature to equivalent Celsius temperature. Use the formula c = (5 / 9) * (f - 32) where c is representing a Celsius temperature and f a Fahreinheit temperature. 2. A program is required that will read two operands and print the product to a file. 3. A program will ask the user to enter his/her name. Upon entering the name...

  • Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save...

    Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save the data Update the program so it reads the player data from a file when the program starts andwrites the player data to a file anytime the data is changed What needs to be updated: Specifications Use a CSV file to store the lineup. Store the functions for writing and reading the file of players in a separate module than the rest of the...

  • You need not run Python programs on a computer in solving the following problems. Place your...

    You need not run Python programs on a computer in solving the following problems. Place your answers into separate "text" files using the names indicated on each problem. Please create your text files using the same text editor that you use for your .py files. Answer submitted in another file format such as .doc, .pages, .rtf, or.pdf will lose least one point per problem! [1] 3 points Use file math.txt What is the precise output from the following code? bar...

  • Please solve the following problem and show all work. Thank you! You are a field engineer working for Far North Arctic Insulates Inc. Your company has come up with a new insulation material to be use...

    Please solve the following problem and show all work. Thank you! You are a field engineer working for Far North Arctic Insulates Inc. Your company has come up with a new insulation material to be used under road beds to keep the permafrost from warming during the summer months. Since this material is quite costly, you want to be able to use the least amount of material (i.e. smallest thickness possible). You have collected the following temperature data in degrees-Fahrenheit)...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT