# Practical Programming.
# exercises - 2.10
# 1 - Expressions
# ------------------------------------------------------------------------------
#print '#1'
#print 'a)', '9 - 3 =', 9 - 3
#print 'b)', '8 * 2.5 =', 8 * 2.5
#print 'c)', '9 / 2 =', 9 / 2
#print 'd)', '9 / -2 =', 9 / -2
#print 'e)', '9 % 2 =', 9 % 2
#print 'f)', '9 % -2 =', 9 % -2
#print 'g)', '-9 % 2 =', -9 % 2
#print 'h)', '9 / -2.0 =', 9 / -2.0
#print 'i)', '4 + 3 * 5 =', 4 + 3 * 5
#print 'j)', '(4 + 3) * 5 =', (4 + 3) * 5
# 2 - Unary minus & Unary plus
# ------------------------------------------------------------------------------
#print '#2'
#x = -17
#print 'x =', x
#print '+x =', +x
#print '+5 =', +5
# 3 - Celsius to Fahrenheit
# ------------------------------------------------------------------------------
#temp = 24
#print 'temp former:', temp
#temp = temp * 1.8 + 32
#print 'temp now:', temp
# 4 - Assignment
# ------------------------------------------------------------------------------
#x = 10.5
#y = 4
#print 'x =', x, '\ny =', y
#x = x + y
#print 'x now:', x
#print 'y now:', y
# 5 - A statement
# ------------------------------------------------------------------------------
#x = 3
#print 'x =', x
#x += x - x
#print 'x now:', x, '\n'
#print 'x += x - x \'s bullet list'
#print '--------------------------'
#print '1. x = 3'
#print '2. x - x = 3 - 3 = 0'
#print '3. x = x + 0 = 3 + 0 = 3'
# 7 - convert_mileage
# ------------------------------------------------------------------------------
# lp100km = liters per 100 km
# kmpm = mpg = miles per gallon
# lpg = liters per gallon (US) = 3.785411784
# kmpm = kilometers per mile = 1.609344
#lpg = 3.785411784
#kmpm = 1.609344
#def convert_mileage(miles_per_gallon):
#mpg = miles_per_gallon
#return (100 * lpg)/(kmpm * mpg)
#miles_per_gallon = float(raw_input('Enter miles_per_gallon: '))
#print convert_mileage(miles_per_gallon), 'liters_per_100kilometers'
# 9 - liters_needed
# ------------------------------------------------------------------------------
#lpg = 3.785411784
#kmpm = 1.609344
#def convert_mileage(miles_per_gallon):
#mpg = miles_per_gallon
#return (100 * lpg)/(kmpm * mpg)
#def liters_needed(distance_in_kilometers, gas_mileage):
#gas_needed_in_liters = (distance_in_kilometers / 100.0) * convert_mileage(gas_mileage)
#return gas_needed_in_liters
#print liters_needed(150, 30)
#print liters_needed(100, 30)
# 10 - built-in
# ------------------------------------------------------------------------------
#print pow(3, 7)
#print int(34.7)
#print round(34.7)
#print float(abs(-86))
Practical Programming第二章习题。