# Ryan Martin
# macid: abcd123
# student number: #######
# July 12, 2011
#
# This is a solution for Marked Assignment 1 (Lab 03) on Friday.

import math

def main():

    print """\

This program is a solution to Marked Assignment 1 (Lab 03) on Friday.

"""

    #INPUTS
    qc = input("Enter a value for the impact pressure, qc: ")
    P = input("Enter a value for the static pressure, P: ")
    T = input("Enter a value for the air temperature, T: ")
    print 

    STANDARDAIRTEMP = 15.0
    STANDARDSOUNDSPEED = 340

    #CALCULATION
    A = STANDARDSOUNDSPEED * math.sqrt( ( 5 * T / STANDARDAIRTEMP ) * ( pow(( float(qc) / P ) + 1, 2./7) - 1 ) )
    B = STANDARDSOUNDSPEED * math.sqrt( ( 10 * T / STANDARDAIRTEMP ) * ( pow(( float(qc) / P ) + 1, 2./7) - 1 ) )
    C = 100.0 * abs((A - B) / B)

    #OUTPUT
    
    print "The true airspeed for qc, P and T, A=", A
    print "The true airspeed for qc, P and 2T, B=", B
    print "The relative difference between these values, C=", C
    print ""

main()


##Design Question
##
##There are two ways to express that statement in Python syntax.
##In both methods, the key point is that a power of 2/7 must be
##expressed as 2./7 (or 2.0/7, etc.) to avoid any loss of
##precision due to integer division. The two methods are:
##
##((qc / P) + 1)**(2./7)
##or
##pow((qc / P) + 1, 2./7)
##
##Testing Report
##
##Test: 1
##Input: [150,90,12]
##Expected Output: [386.730137735,546.919005763,29.2893218813]
##Actual Output: [386.730137735,546.919005763,29.2893218813]
##Result: Pass
##
##Test: 2
##Input: [string,85.6,13.1]
##Expected Output: [error]
##Actual Output: [NameError]
##Result: Pass
##
##Test: 3
##Input: [150,0,13.1]
##Expected Output: [error]
##Actual Output: [ZeroDivisionError]
##Result: Pass