ai-lover commited on
Commit
7185003
·
verified ·
1 Parent(s): b21343d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +48 -0
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+
3
+ def main():
4
+ st.title("Power Calculation App")
5
+
6
+ # User selects type of power calculation
7
+ power_type = st.radio(
8
+ "Select the type of power calculation:",
9
+ ("DC Power", "Single-Phase Power", "Two-Phase Power", "Three-Phase Power")
10
+ )
11
+
12
+ if power_type == "DC Power":
13
+ st.header("DC Power Calculation")
14
+ voltage = st.number_input("Enter DC Voltage (V):", min_value=0.0, step=0.1)
15
+ current = st.number_input("Enter DC Current (I):", min_value=0.0, step=0.1)
16
+ if st.button("Calculate DC Power"):
17
+ power = voltage * current
18
+ st.success(f"DC Power (P) = {power} W")
19
+
20
+ elif power_type == "Single-Phase Power":
21
+ st.header("Single-Phase Power Calculation")
22
+ voltage = st.number_input("Enter AC Voltage (V):", min_value=0.0, step=0.1)
23
+ current = st.number_input("Enter AC Current (I):", min_value=0.0, step=0.1)
24
+ power_factor = 0.9
25
+ if st.button("Calculate Single-Phase Power"):
26
+ power = voltage * current * power_factor
27
+ st.success(f"Single-Phase Power (P) = {power} W")
28
+
29
+ elif power_type == "Two-Phase Power":
30
+ st.header("Two-Phase Power Calculation")
31
+ voltage = st.number_input("Enter AC Voltage (V):", min_value=0.0, step=0.1)
32
+ current = st.number_input("Enter AC Current (I):", min_value=0.0, step=0.1)
33
+ power_factor = 0.9
34
+ if st.button("Calculate Two-Phase Power"):
35
+ power = 2 * voltage * current * power_factor
36
+ st.success(f"Two-Phase Power (P) = {power} W")
37
+
38
+ elif power_type == "Three-Phase Power":
39
+ st.header("Three-Phase Power Calculation")
40
+ voltage = st.number_input("Enter AC Voltage (V):", min_value=0.0, step=0.1)
41
+ current = st.number_input("Enter AC Current (I):", min_value=0.0, step=0.1)
42
+ power_factor = 0.9
43
+ if st.button("Calculate Three-Phase Power"):
44
+ power = (3 ** 0.5) * voltage * current * power_factor
45
+ st.success(f"Three-Phase Power (P) = {power} W")
46
+
47
+ if __name__ == "__main__":
48
+ main()