Question: Python 3.6 - How do I write the entire output to another text file. Send screeshot of indented source code and screenshot of new text

Python 3.6 - How do I write the entire output to another text file. Send screeshot of indented source code and screenshot of new text file?

Python 3.6 - How do I write the entire output to another

text file. Send screeshot of indented source code and screenshot of new

import math # imports math library to use square root function def calcHyp (sidel, side2): To calculate the length of the hypotenuse of a right triangle. Test data: input: N/A output: N/A Params: sidel (float); side2 (float) Returns: Gives the calculated hypotenuse of a triangle (float) side3 -math-sqrt( ( side! * sidel) + (side2 * side2)) # calculates hypotenuse return (side3) # returns hypotenuse def main(): To open and read given values in a text file, call functions to get hypotenuse, and display the results on the screen. Test data: input: N/A output: Side 1; Side 2; Side 3 where Side 3 is the hypotenuse of the right triangle Params: N/A returns: Gives three sides of a right triangle (float) and states that Side 3 is the hypotenuse (string) count int(1)z with open ('Sides.txt') as f: # 0pens file for line in f: # reads line by line # Splits line and stores the two values in variables sidel, side2 [float (x) for x in line.split()] # calls function to get hypotenuse side3 = float (calcHyp ( side1, side2 )) # prints details print("For triangle number"str(count) + ", the three sides are: ") print(" Side 1 str (sidel)) print(" Side 2: str (side2,)) print( " Side 3: " + str (round(side3, 4))) # rounds off to 4 decimal places print("where Side 3 is the hypotenuse of the right triangle.") print() count -count+1 # calls for main function if_name main' main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!