Skip to content

Commit 4507ee3

Browse files
committed
sgpa_To_cgpa_converto
1 parent 6a71a03 commit 4507ee3

File tree

3 files changed

+115
-0
lines changed

3 files changed

+115
-0
lines changed

Sgpa_To_Cgpa_Convertor/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# SGPA to CGPA Converter
2+
3+
This is a simple GUI application built using Python and Tkinter that converts SGPA (Semester Grade Point Average) to CGPA (Cumulative Grade Point Average) based on user inputs.
4+
5+
## Features
6+
7+
- Allows users to enter the total number of semesters and their corresponding SGPA values.
8+
- Calculates the CGPA based on the entered SGPA values.
9+
- Supports resetting the inputs and results for a fresh calculation.
10+
11+
## Requirements
12+
13+
- Python 3.x
14+
- Tkinter library (usually included with Python)
15+
16+
## How to Use
17+
18+
1. Install Python 3.x if it's not already installed on your system.
19+
2. Clone or download this repository to your local machine.
20+
3. Open a terminal or command prompt and navigate to the project directory.
21+
4. Run the following command to install the required dependencies:
22+
```
23+
pip install tkinter
24+
```
25+
5. Run the application using the following command:
26+
```
27+
python sgpa_to_cgpa_converter.py
28+
```
29+
6. Enter the total number of semesters and the corresponding SGPA values.
30+
7. Click the "Calculate CGPA" button to compute the CGPA based on the entered values.
31+
8. To reset the inputs and results, click the "Reset" button.
61.4 KB
Loading
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
import tkinter as tk
2+
3+
4+
def create_sgpa_entries():
5+
num_semesters = int(num_semesters_entry.get())
6+
7+
for i in range(num_semesters):
8+
sgpa_label = tk.Label(sgpa_frame, text=f"SGPA for Semester {i + 1}:")
9+
sgpa_label.grid(row=i + 2, column=0, padx=10, pady=5, sticky="E")
10+
11+
sgpa_entry = tk.Entry(sgpa_frame)
12+
sgpa_entry.grid(row=i + 2, column=1, padx=10, pady=5, sticky="W")
13+
sgpa_entry.bind('<KeyRelease>', validate_sgpa_entries)
14+
15+
sgpa_labels.append(sgpa_label)
16+
sgpa_entries.append(sgpa_entry)
17+
18+
create_sgpa_entries_button.grid_remove()
19+
cgpa_calc_button.grid(row=num_semesters + 2, column=0, columnspan=2, padx=10, pady=5)
20+
21+
22+
def validate_sgpa_entries(event):
23+
filled_entries = [entry.get() for entry in sgpa_entries]
24+
if all(filled_entries):
25+
cgpa_calc_button.configure(state="normal")
26+
else:
27+
cgpa_calc_button.configure(state="disabled")
28+
29+
30+
def calculate_cgpa():
31+
sgpa_values = [float(sgpa_entry.get()) for sgpa_entry in sgpa_entries]
32+
33+
total_sgpa = sum(sgpa_values)
34+
num_semesters = len(sgpa_values)
35+
total_credit_hours = num_semesters * 18 # Assuming 18 credit hours per semester
36+
cgpa = total_sgpa / num_semesters
37+
38+
cgpa_label.configure(text=f"CGPA: {cgpa:.2f}")
39+
40+
reset_button.configure(state="normal")
41+
42+
43+
def reset_entries():
44+
for label in sgpa_labels:
45+
label.destroy()
46+
for entry in sgpa_entries:
47+
entry.destroy()
48+
sgpa_labels.clear()
49+
sgpa_entries.clear()
50+
51+
create_sgpa_entries_button.grid(row=1, column=0, columnspan=2, padx=10, pady=5)
52+
cgpa_calc_button.configure(state="disabled")
53+
cgpa_label.configure(text="CGPA: ")
54+
55+
reset_button.configure(state="disabled")
56+
57+
58+
root = tk.Tk()
59+
root.title("SGPA to CGPA Converter")
60+
61+
sgpa_frame = tk.Frame(root)
62+
sgpa_frame.pack(pady=10)
63+
64+
num_semesters_label = tk.Label(sgpa_frame, text="Total Number of Semesters:")
65+
num_semesters_label.grid(row=0, column=0, padx=10, pady=5, sticky="E")
66+
67+
num_semesters_entry = tk.Entry(sgpa_frame)
68+
num_semesters_entry.grid(row=0, column=1, padx=10, pady=5, sticky="W")
69+
70+
sgpa_labels = []
71+
sgpa_entries = []
72+
73+
create_sgpa_entries_button = tk.Button(sgpa_frame, text="Create SGPA Entries", command=create_sgpa_entries)
74+
create_sgpa_entries_button.grid(row=1, column=0, columnspan=2, padx=10, pady=5)
75+
76+
cgpa_calc_button = tk.Button(sgpa_frame, text="Calculate CGPA", command=calculate_cgpa, state="disabled")
77+
78+
cgpa_label = tk.Label(root, text="CGPA: ")
79+
cgpa_label.pack()
80+
81+
reset_button = tk.Button(root, text="Reset", command=reset_entries, state="disabled")
82+
reset_button.pack()
83+
84+
root.mainloop()

0 commit comments

Comments
 (0)