File size: 960 Bytes
6ad20d4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import streamlit as st

# Streamlit app title
st.title("Marks and Grade Calculator")

# Input fields for total marks and obtained marks
a = st.number_input("Enter your Total marks:", min_value=0)
b = st.number_input("Enter your Obtained marks:", min_value=0)

# Ensure obtained marks are not greater than total marks
if b > a:
    st.error("Obtained marks cannot be greater than total marks!")
else:
    if a > 0:  # To avoid division by zero
        # Calculate percentage
        c = (b / a) * 100
        st.write(f"Your percentage is: {c:.2f}%")

        # Grade determination
        if c >= 80:
            st.write("Your Grade is: A1")
        elif c >= 70:
            st.write("Your Grade is: A")
        elif c >= 60:
            st.write("Your Grade is: B")
        elif c >= 50:
            st.write("Your Grade is: C")
        else:
            st.write("Your Grade is: Fail")
    else:
        st.warning("Total marks should be greater than 0.")