KunaalNaik commited on
Commit
797ada8
·
verified ·
1 Parent(s): 3e315d1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -0
app.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import numpy as np
3
+ import pandas as pd
4
+ import matplotlib.pyplot as plt
5
+
6
+ # Streamlit application
7
+ def app():
8
+ st.title("Linear Equation Visualizer")
9
+
10
+ # Input fields for the equation y = mx + c
11
+ m = st.number_input("Enter the slope (m):", value=1.0)
12
+ c = st.number_input("Enter the y-intercept (c):", value=0.0)
13
+ x_value = st.number_input("Enter the x value to predict y:", value=0.0)
14
+
15
+ # Calculating y based on the input
16
+ y = m * x_value + c
17
+
18
+ # Displaying the calculated y
19
+ st.write(f"The calculated y value is: {y}")
20
+
21
+ # Generating data for the line
22
+ x = np.linspace(-10, 10, 100)
23
+ y_line = m * x + c
24
+
25
+ # Plotting the line
26
+ plt.figure(figsize=(10, 6))
27
+ plt.plot(x, y_line, '-r', label=f'y = {m}x + {c}')
28
+ plt.scatter(x_value, y, color='blue', label='Predicted Point')
29
+ plt.title("Graph of y = mx + c")
30
+ plt.xlabel("x")
31
+ plt.ylabel("y")
32
+ plt.legend()
33
+ plt.grid(True)
34
+
35
+ # Displaying the plot
36
+ st.pyplot(plt)
37
+
38
+ if __name__ == "__main__":
39
+ app()