Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def m(file1,file2): File1 = open(Fx.txt, r)#open file1.txt Lx = [] for val in File1.read().split(): Lx.append(float(val))#append values to lx File1.close()#close file1 File2 = open(Fy.txt, r)#open file2.txt

def m(file1,file2):
File1 = open("Fx.txt", "r")#open file1.txt
Lx = []
for val in File1.read().split():
Lx.append(float(val))#append values to lx
File1.close()#close file1
File2 = open("Fy.txt", "r")#open file2.txt
Ly = []
for val in File2.read().split():
Ly.append(float(val))#append values to ly
File2.close()
n = len(Lx)
xy = [x*y for x,y in zip(Lx,Ly)]#list whose elements are xi*yi
xy_sum = sum(xy)#sum of sy
x_sum = sum(Lx)#sum of Lx
y_sum = sum(Ly)#sum of Ly
x_squ = [x*x for x in Lx]#square of terms in Lx
x_squ_sum = sum(x_squ)#sum of squares
numerator = n*xy_sum + x_sum*y_sum
denominator = n*x_squ_sum + x_sum*x_sum
m = float(numerator)/denominator
return Lx,Ly,m
infile1 = open("Fx.txt", 'w')
infile1.write('-19 -42 3 5 22 -7')#incomplete line in the image.
infile1.close()
infile1 = open("Fy.txt", 'w')
infile1.write("24 13 45 17 18 37")#incomplete line in the image
infile1.close()
result = m("Fx.txt", "Fy.txt")
print("Lx = ", result[0])
print("Ly = ", result[1])
print("m = ", result[2])
Refer to image
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
Design questions answers please
Assume 10 summations for question one
..11 ROGERS 11:42 AM jhub.cas.mcmaster.ca major2_v2 Menu Not Trusted Python 3 Markdown Validate Design Questions (4 Points) 1. How many different summations are there in Equation 1? How will you calculate each of these summations? 2. what is the difference between read0 and 3. What do you need to do differently in order to 4. What must you do, after you have opened a readlines0? open a file for writing instead of reading? file and processed its contents? Enter your answers into the Markdown cell below Your Answer Here (Do NOT DELETE L pr> or )

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Object Oriented Databases Prentice Hall International Series In Computer Science

Authors: John G. Hughes

1st Edition

0136298745, 978-0136298748

More Books

Students also viewed these Databases questions