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.")