0% found this document useful (0 votes)
16 views2 pages

Diksha Baride TE A1 T611005: Int Input

Mini Project 3rd year Mechanical

Uploaded by

salebharat5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Diksha Baride TE A1 T611005: Int Input

Mini Project 3rd year Mechanical

Uploaded by

salebharat5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

9/16/24, 3:05 PM straight line - Jupyter Notebook

Diksha Baride TE A1 T611005

In [1]: import numpy as np

In [2]: n = int(input("Enter number of data points:"))

Enter number of data points:7

In [3]: x = np.zeros(n)
y = np.zeros(n)

In [4]: for i in range(n):


x[i] = float(input("Enter x data point = "))
y[i] = float(input("Enter y data point = "))

Enter x data point = 0


Enter y data point = 10
Enter x data point = 2
Enter y data point = 12
Enter x data point = 4
Enter y data point = 18
Enter x data point = 6
Enter y data point = 22
Enter x data point = 8
Enter y data point = 20
Enter x data point = 12
Enter y data point = 30
Enter x data point = 20
Enter y data point = 30

In [5]: sX,sX2,sY,sXY = 0,0,0,0

In [6]: for i in range(n):


sX = sX + x[i]
sX2 =sX2 + x[i]*x[i]
sY = sY + y[i]
sXY = sXY + x[i]*y[i]
print(sX,sX2,sY,sXY,sep='|')

0.0|0.0|10.0|0.0
2.0|4.0|22.0|24.0
6.0|20.0|40.0|96.0
12.0|56.0|62.0|228.0
20.0|120.0|82.0|388.0
32.0|264.0|112.0|748.0
52.0|664.0|142.0|1348.0

In [8]: B = (n*sXY-sX*sY)/ (n*sX2-sX*sX)


A = (sY-B*sX)/n
print(A,B,sep='|')
print("And equation is: y= %f + %fx" %(A,B))

12.444444444444445|1.0555555555555556
And equation is: y= 12.444444 + 1.055556x

localhost:8888/notebooks/TE A1 5/straight line.ipynb 1/2


9/16/24, 3:05 PM straight line - Jupyter Notebook

In [ ]: ​

localhost:8888/notebooks/TE A1 5/straight line.ipynb 2/2

You might also like