Math 110 CS Homework 2 1. What is the problem with the Python

Math 110 CS Homework 2
1. What is the problem with the Python program below? Check your answer in IDLE.
import math
radius = 7
area = pi * radius**2
print area
2. Find all of the errors (syntax, run-time, and logic) in the Python program below:
import Math
radius = input("Enter the radius of a circle:)
area = math.Pi * Radius*2
print "The area of the circle with radius", r 'is', area
3. Write a Python program that prompts a user to enter a distance in yards, convert the distance to miles, and then
prints the output in sentence form. Conversion: 1760 yards = 1 mile. To check your program, try to convert 200
yards. The answer should be 0.1136 miles.
4. Write a Python program that prompts a user to enter a volume in gallons, converts it to cups, and then prints
the output in sentence form. Conversion information: 1 quart = 4 cups and 1 gallon = 4 quarts. To check your
program, try to convert 2.2 gallons. The answer should be 35.2 cups.
5. Optional Homework (A little harder than the above programs): Relative humidity is a term used to describe the
amount of water vapor in a mixture of air and water vapor. It depends on the temperature of the air as well as
the dew point (the temperature to which a given parcel of humid air must be cooled for water vapor to
condense into water). Generally, days with high relative humidity are considered uncomfortable (although
having very low relative humidity can lead to uncomfortable weather as well). Write a Python program that asks
the user to enter a temperature and dew point (both in degrees Celsius), uses them to compute relative
humidity (which has units of percent) using the following formula
112 − 0.1𝑇 + 𝐷 8
𝑅 = 100 �
�
112 + 0.9𝑇
(where T = temperature in degrees Celsius and D = dew point in degrees Celsius), and prints the output (rounded
to 2 decimal places) in sentence form. To check your work, for a temperature of 25°C and a dew point of 20°C,
the relative humidity is 73.85%.