Question: Help with this I Python would be great. Solution Complete the following program to prompt for a filename print a heading for the output print
Help with this I Python would be great.


Solution Complete the following program to prompt for a filename print a heading for the output print a line with the side and triangle properties for each triangle in the file Example Input Each line in the file contains 3 numbers separated by spaces that represent the side lengths of the triangle as in the following example. The lengths may be in any order on the line. 5 43 Example Output The side lengths and properties should align with the column headings as in the following example. The side lengths should be right justified and in the same order as the input file, while the properties should be left justified. 111 222 333 angle side 5 3 right scal 4 acute equi Test Data File There is a single test file,triangles you may use to test your program during development. 3 5 4 3 4 1 3 3 6 2 11 4 643 1 # Triangle Properties 2# 3 # This program: # * prompts for a filename 5 # * prints a heading for the output 6 # * prints a line with the side and triangle properties for each triangle in the file 8 # Refer to the above description for definitions of triangles/angles 10 def side(a, b, c): Returns scalene', 'isosceles', 'equilateral', or 'none' based on the triangle side relationships given the lengths of the sides. 12 13 14 15 16 # add code to return the correct side relationship 18 def angle(a, b, c): 19 20 21 Returns 'acute', 'obtuse', 'right, or 'none' based on the triangle angle relationships given the lengths of the sides where c is the longest side 23 24 # add code to return the correct angle relationship 26 27 def triangle_properties(sides) 28 29 30 31 32 33 abc[int (sides[e]),int(sides[1]),int(sides [2])] 34 35 36 37 38 Returns a properly formatted string containing the triangle properties from a list of strings containing the lengths of the sides # Don't change this code that figures out the longest side cmax (abc) abc.remove(c) aabc [0] babc[1] # add code to return a properly formatted string that matches the column headings 41 def column_headings() Return a string containing the column headings DO NOT CHANGE THIS CODE return '111 222 333 angle side' 46 47 49 def triangles(filename): 50 Prints column headings and a line containing the properties of each triangle in the file 52 53 54 print (column_headings ()) # add code to process the file, printing the triangle properties for each line in file 56 57 def main): 58 59 60 61 62 63 triangles (filename) 64 Prompts for filename and processes the file DO NOT CHANGE THIS CODE filenameinput( 'filename? ) 66 if-name__== '-main-' : 67 main() 68 Solution Complete the following program to prompt for a filename print a heading for the output print a line with the side and triangle properties for each triangle in the file Example Input Each line in the file contains 3 numbers separated by spaces that represent the side lengths of the triangle as in the following example. The lengths may be in any order on the line. 5 43 Example Output The side lengths and properties should align with the column headings as in the following example. The side lengths should be right justified and in the same order as the input file, while the properties should be left justified. 111 222 333 angle side 5 3 right scal 4 acute equi Test Data File There is a single test file,triangles you may use to test your program during development. 3 5 4 3 4 1 3 3 6 2 11 4 643 1 # Triangle Properties 2# 3 # This program: # * prompts for a filename 5 # * prints a heading for the output 6 # * prints a line with the side and triangle properties for each triangle in the file 8 # Refer to the above description for definitions of triangles/angles 10 def side(a, b, c): Returns scalene', 'isosceles', 'equilateral', or 'none' based on the triangle side relationships given the lengths of the sides. 12 13 14 15 16 # add code to return the correct side relationship 18 def angle(a, b, c): 19 20 21 Returns 'acute', 'obtuse', 'right, or 'none' based on the triangle angle relationships given the lengths of the sides where c is the longest side 23 24 # add code to return the correct angle relationship 26 27 def triangle_properties(sides) 28 29 30 31 32 33 abc[int (sides[e]),int(sides[1]),int(sides [2])] 34 35 36 37 38 Returns a properly formatted string containing the triangle properties from a list of strings containing the lengths of the sides # Don't change this code that figures out the longest side cmax (abc) abc.remove(c) aabc [0] babc[1] # add code to return a properly formatted string that matches the column headings 41 def column_headings() Return a string containing the column headings DO NOT CHANGE THIS CODE return '111 222 333 angle side' 46 47 49 def triangles(filename): 50 Prints column headings and a line containing the properties of each triangle in the file 52 53 54 print (column_headings ()) # add code to process the file, printing the triangle properties for each line in file 56 57 def main): 58 59 60 61 62 63 triangles (filename) 64 Prompts for filename and processes the file DO NOT CHANGE THIS CODE filenameinput( 'filename? ) 66 if-name__== '-main-' : 67 main() 68
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
