Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
# Streamlit app title
|
| 4 |
+
st.title("Marks and Grade Calculator")
|
| 5 |
+
|
| 6 |
+
# Input fields for total marks and obtained marks
|
| 7 |
+
a = st.number_input("Enter your Total marks:", min_value=0)
|
| 8 |
+
b = st.number_input("Enter your Obtained marks:", min_value=0)
|
| 9 |
+
|
| 10 |
+
# Ensure obtained marks are not greater than total marks
|
| 11 |
+
if b > a:
|
| 12 |
+
st.error("Obtained marks cannot be greater than total marks!")
|
| 13 |
+
else:
|
| 14 |
+
if a > 0: # To avoid division by zero
|
| 15 |
+
# Calculate percentage
|
| 16 |
+
c = (b / a) * 100
|
| 17 |
+
st.write(f"Your percentage is: {c:.2f}%")
|
| 18 |
+
|
| 19 |
+
# Grade determination
|
| 20 |
+
if c >= 80:
|
| 21 |
+
st.write("Your Grade is: A1")
|
| 22 |
+
elif c >= 70:
|
| 23 |
+
st.write("Your Grade is: A")
|
| 24 |
+
elif c >= 60:
|
| 25 |
+
st.write("Your Grade is: B")
|
| 26 |
+
elif c >= 50:
|
| 27 |
+
st.write("Your Grade is: C")
|
| 28 |
+
else:
|
| 29 |
+
st.write("Your Grade is: Fail")
|
| 30 |
+
else:
|
| 31 |
+
st.warning("Total marks should be greater than 0.")
|