maria355 commited on
Commit
a8cfae2
Β·
verified Β·
1 Parent(s): cf2a1c8

Upload 3 files

Browse files
Files changed (3) hide show
  1. app.py +148 -0
  2. readme.md +71 -0
  3. requirements.txt +4 -0
app.py ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ import matplotlib.pyplot as plt
4
+
5
+ # Title of the app
6
+ st.title("πŸŽ“ CGPA Calculator: Unlock Your Academic Potential πŸš€πŸ“ˆ")
7
+
8
+ # Custom CSS for background and sidebar
9
+ st.markdown("""
10
+ <style>
11
+ /* Main page background */
12
+ [data-testid="stAppViewContainer"] {
13
+ background-image: url("https://img.freepik.com/free-photo/abstract-blur-pastel-beautiful-peach-pink-color-sky-warm-tone-background-design-as-bannerslide-show-others_1258-100366.jpg?semt=ais_hybrid&w=740");
14
+ background-size: cover;
15
+ background-position: center;
16
+ background-repeat: no-repeat;
17
+ }
18
+
19
+ /* Sidebar background */
20
+ [data-testid="stSidebar"] {
21
+ background-image: url("https://i.pinimg.com/236x/ff/39/6f/ff396fca7f47cc3d2ca55ebc53e93bc7.jpg");
22
+ background-size: cover;
23
+ background-repeat: no-repeat;
24
+ background-position: center;
25
+ color: white;
26
+ }
27
+
28
+ /* Button style */
29
+ .stButton>button {
30
+ background-color: #4CAF50;
31
+ color: white;
32
+ font-size: 16px;
33
+ font-weight: bold;
34
+ border-radius: 8px;
35
+ padding: 12px;
36
+ margin-top: 10px;
37
+ width: 100%;
38
+ }
39
+ .stButton>button:hover {
40
+ background-color: #45a049;
41
+ }
42
+
43
+ /* Text input border style */
44
+ .stTextInput>div>div>input {
45
+ border: 2px solid #8B0000 !important;
46
+ border-radius: 5px;
47
+ }
48
+
49
+ /* Footer style */
50
+ .footer {
51
+ font-size: 14px;
52
+ color: #666666;
53
+ text-align: center;
54
+ padding: 20px 0;
55
+ }
56
+ </style>
57
+ """, unsafe_allow_html=True)
58
+
59
+ # Sidebar content
60
+ st.sidebar.markdown("## πŸ‘¨β€πŸ’» Connect with Me")
61
+ st.sidebar.markdown("""
62
+ <div>
63
+ <a href="https://github.com/marianadeem755" target="_blank">
64
+ <img src="https://cdn-icons-png.flaticon.com/512/25/25231.png" width="30px"> GitHub
65
+ </a><br><br>
66
+ <a href="https://www.kaggle.com/marianadeem755" target="_blank">
67
+ <img src="https://cdn4.iconfinder.com/data/icons/logos-and-brands/512/189_Kaggle_logo_logos-512.png" width="30px"> Kaggle
68
+ </a><br><br>
69
+ <a href="mailto:marianadeem755@gmail.com">
70
+ <img src="https://cdn-icons-png.flaticon.com/512/561/561127.png" width="30px"> Email
71
+ </a><br><br>
72
+ <a href="https://huggingface.co/maria355" target="_blank">
73
+ <img src="https://huggingface.co/front/assets/huggingface_logo-noborder.svg" width="30px"> Hugging Face
74
+ </a>
75
+ </div>
76
+ """, unsafe_allow_html=True)
77
+
78
+ # Input Section
79
+ st.header("Enter Your Semester GPAs")
80
+ num_semesters = st.number_input("How many semesters have you completed?", min_value=1, max_value=20, step=1, value=1)
81
+
82
+ # GPA input fields
83
+ gpa_list = []
84
+ for i in range(1, num_semesters + 1):
85
+ gpa = st.number_input(f"Enter GPA for Semester {i}:", min_value=0.0, max_value=4.0, step=0.01, value=0.0)
86
+ gpa_list.append(gpa)
87
+
88
+ # Calculate CGPA
89
+ if st.button("Calculate CGPA"):
90
+ if gpa_list:
91
+ cgpa = sum(gpa_list) / len(gpa_list)
92
+ st.success(f"Your CGPA is: {cgpa:.2f}")
93
+
94
+ highest_gpa = max(gpa_list)
95
+ lowest_gpa = min(gpa_list)
96
+ average_gpa = sum(gpa_list) / len(gpa_list)
97
+
98
+ st.header("Advanced Features")
99
+
100
+ st.subheader("GPA Summary")
101
+ st.write(f"Highest GPA: {highest_gpa:.2f}")
102
+ st.write(f"Lowest GPA: {lowest_gpa:.2f}")
103
+ st.write(f"Average GPA: {average_gpa:.2f}")
104
+
105
+ st.subheader("GPA Trend")
106
+ fig, ax = plt.subplots()
107
+ ax.plot(range(1, len(gpa_list) + 1), gpa_list, marker='o', linestyle='-', color='b')
108
+ ax.set_title("GPA Trend Over Semesters")
109
+ ax.set_xlabel("Semester")
110
+ ax.set_ylabel("GPA")
111
+ ax.set_ylim(0, 4.0)
112
+ st.pyplot(fig)
113
+
114
+ # Create DataFrame for download
115
+ data = {
116
+ "Semester": [f"Semester {i+1}" for i in range(len(gpa_list))],
117
+ "GPA": gpa_list
118
+ }
119
+ df = pd.DataFrame(data)
120
+ summary_df = pd.DataFrame({
121
+ "Metric": ["CGPA", "Highest GPA", "Lowest GPA", "Average GPA"],
122
+ "Value": [cgpa, highest_gpa, lowest_gpa, average_gpa]
123
+ })
124
+
125
+ combined_df = pd.concat([df, pd.DataFrame([["", ""]], columns=["Semester", "GPA"]),
126
+ summary_df.rename(columns={"Metric": "Semester", "Value": "GPA"})],
127
+ ignore_index=True)
128
+
129
+ csv = combined_df.to_csv(index=False).encode('utf-8')
130
+ st.download_button(
131
+ label="πŸ“₯ Download Results as CSV",
132
+ data=csv,
133
+ file_name="cgpa_results.csv",
134
+ mime='text/csv'
135
+ )
136
+ else:
137
+ st.error("Please enter at least one GPA.")
138
+
139
+ # Reset Button
140
+ if st.button("Reset"):
141
+ st.experimental_rerun()
142
+
143
+ # Footer
144
+ st.markdown("""
145
+ <div class="footer">
146
+ <p>Β© 2025 CGPA Calculator | Made by Maria Nadeem</p>
147
+ </div>
148
+ """, unsafe_allow_html=True)
readme.md ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # πŸŽ“ CGPA Calculator
2
+
3
+ This is a **Streamlit** web application that helps users calculate their CGPA (Cumulative Grade Point Average) based on their semesters GPA. This app provides advanced features like GPA trend visualization, GPA summary and the ability to download results as a CSV file.
4
+
5
+ ---
6
+
7
+ ## πŸš€ Features
8
+
9
+ - **Input Semester GPAs**: Enter GPAs for multiple semesters.
10
+ - **CGPA Calculation**: Automatically calculates the CGPA based on the entered GPAs.
11
+ - **GPA Summary**:
12
+ - Highest GPA
13
+ - Lowest GPA
14
+ - Average GPA
15
+ - **GPA Trend Visualization**: Displays a line chart showing GPA trends over semesters.
16
+ - **Download Results**: Export GPA data and summary as a CSV file.
17
+ - **Reset Functionality**: Reset the app to start fresh.
18
+
19
+ ---
20
+
21
+ ## πŸ› οΈ Installation
22
+ 1. Navigate to the project directory:
23
+ ```bash
24
+ cd cgpa-calculator
25
+ ```
26
+ 2. Install the required dependencies:
27
+ ```bash
28
+ pip install -r requirements.txt
29
+ ```
30
+
31
+ ---
32
+
33
+ ## ▢️ Usage
34
+
35
+ 1. Run the Streamlit app:
36
+ ```bash
37
+ streamlit run app.py
38
+ ```
39
+
40
+ 2. Enter the number of semesters and their respective GPAs.
41
+ 3. Click **Calculate CGPA** to view the results.
42
+ 4. Optionally, download the results as a CSV file or reset the app.
43
+
44
+ ---
45
+
46
+ ## πŸ“Š GPA Trend Visualization
47
+
48
+ The app generates a line chart to visualize GPA trends over semesters. This helps users track their academic performance over time.
49
+
50
+ ---
51
+
52
+ ## πŸ“₯ Download Results
53
+
54
+ Users can download their GPA data and summary as a CSV file for future reference.
55
+
56
+ ---
57
+
58
+ ## πŸ“š Technologies Used
59
+
60
+ - **Python**
61
+ - **Streamlit**: For building the web app.
62
+ - **Pandas**: For data manipulation.
63
+ - **Matplotlib**: For GPA trend visualization.
64
+
65
+ ---
66
+
67
+
68
+ ## 🌟 Acknowledgments
69
+
70
+ - Built with [Streamlit](https://streamlit.io/).
71
+ ---
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ streamlit
2
+ pandas
3
+ matplotlib
4
+ fpdf