ankithpatel commited on
Commit
b54e258
·
verified ·
1 Parent(s): 33f758c

Create home.py

Browse files
Files changed (1) hide show
  1. home.py +35 -5
home.py CHANGED
@@ -1,8 +1,38 @@
1
  import streamlit as st
2
- st.markdown("""<h1 style="border-bottom: 2px solid black; text-align: center;"> About Data Science</h1>:""",unsafe_allow_html = True)
3
- st.markdown("""<h2 style="text-decoration:underline; text-align:left;"> INTRODUCTION </h2>:""",unsafe_allow_html=True)
4
- st.markdown("<p1>Data science is a multidisciplinary field that combines statistics, programming, and domain expertise to extract meaningful insights from data. It involves collecting, cleaning, and analyzing vast amounts of structured and unstructured data to uncover patterns, trends, and valuable information.</p1>", unsafe_allow_html=True)
5
- st .markdown("<p1>With the rise of digital technology, data is being generated at an unprecedented rate, and data science helps organizations make sense of it. By leveraging tools like Python, R, and machine learning algorithms, data scientists solve real-world problems in areas like healthcare, finance, marketing, and more.</p2>",unsafe_allow_html=True)
6
-
7
 
 
8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import streamlit as st
 
 
 
 
 
2
 
3
+ st.title("Calculator App using Streamlit")
4
 
5
+ # creates a horizontal line
6
+ st.write("---")
7
+
8
+ # input 1
9
+ num1 = st.number_input(label="Enter first number")
10
+
11
+ # input 2
12
+ num2 = st.number_input(label="Enter second number")
13
+
14
+ st.write("Operation")
15
+
16
+ operation = st.radio("Select an operation to perform:",
17
+ ("Add", "Subtract", "Multiply", "Divide"))
18
+
19
+ ans = 0
20
+
21
+
22
+ def calculate():
23
+ if operation == "Add":
24
+ ans = num1 + num2
25
+ elif operation == "Subtract":
26
+ ans = num1 - num2
27
+ elif operation == "Multiply":
28
+ ans = num1 * num2
29
+ elif operation == "Divide" and num2 != 0:
30
+ ans = num1 / num2
31
+ else:
32
+ st.warning("Division by 0 error. Please enter a non-zero number.")
33
+ ans = "Not defined"
34
+
35
+ st.success(f"Answer = {ans}")
36
+
37
+ if st.button("Calculate result"):
38
+ calculate()