Answered step by step
Verified Expert Solution
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
Design questions answers please
Assume 10 summations for question one
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started