Skip to content

Muhdal-Amin/CSC_120_pg15

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CSC_120

Computer as a Problem solving tool : Page 15, Exercises 1 - 3

Exercise 1 (Length Conversion)

Write a program that asks the user to enter a length in centimeters. If the user enters a negative length, the program should tell the user that the entry is invalid. Otherwise, the program should convert the length to inches and print out the result.

There are 2.54 centimeters in an inch.

Exercise 2 (Temperature Conversion)

Write a program that asks the user for a temperature. Then asks them what units ( Celsius or Fahrenheit ) the temperature is in. Your program should convert thet temperature to the other unit.

The conversions are;

  • F = (temp * 1.8) + 32
  • C = (temp - 32) / 1.8

Exercise 3 (Temperature Message)

Write a program that asks the user to enter a temperature in celsius.

The program should print the following messages based on the temperature;

  • If the temperature is less than -273.15, print that the temperature is invalid because it is below absolute zero.
  • If it is exactly -273.15, print that the temperature is absolute 0.
  • If the temperature is between -273.15 and 0, print that the temperature is below freezing.
  • If it is 0, print that the temperature is at the freezing point.
  • If it is between 0 and 100, print that the temperature is in the normal range.
  • If it is 100, print that the temperature is at the boiling point.
  • If it is above 100, print that the temperature is above the boiling point.

About

Control Structures in Python

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages