Lecture Notes on 27 Jan 2017 Active Reading: Type code as you read. Read Chapter 2: Sections 2.9 - 2.14 (leave out Graphics) Write the code from the following listings and run them: * Listing 2.6: SalesTax.py * Listing 2.7: ShowCurrentTime.py * Listing 2.8: ComputeLoan.py * Listing 2.9: ComputeDistance.py # this program determines if the three sides form a right angled triangle def main(): # prompt user to enter the sides of a triangle a = int (input ("Enter side 1: ")) b = int (input ("Enter side 2: ")) c = int (input ("Enter side 3: ")) # square the sides a2 = a * a b2 = b * b c2 = c * c # apply the Pythagorean theorem cond = ((a2 + b2) == c2) or ((b2 + c2) == a2) or ((c2 + a2) == b2) # write out the result if (cond): print ("is right angled triangle") else: print ("is not right angled triangle") main() # this program prints three numbers in ascending order def main(): # prompt user to enter three numbers a = int (input ("Enter num 1: ")) b = int (input ("Enter num 2: ")) c = int (input ("Enter num 3: ")) # assign a to have the smallest value if (a > b): a, b = b, a if (a > c): a, c = c, a # assign c to have the largest value if (b > c): b, c = c, b # print the result print (a, b, c) main() # this program determines if three sides form a triangle def main(): # prompt the user to enter three sides a = int (input ("Enter side 1: ")) b = int (input ("Enter side 2: ")) c = int (input ("Enter side 3: ")) # set up the conditions cond1 = (a + b ) > c cond2 = (b + c) > a cond3 = (c + a) > b # print the result if (cond1 and cond2 and cond3): print ("is triangle") else: print ("is not triangle") main()