Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b2a36b2

Browse files
Merge pull request avinashkranjan#2126 from KmKalpana/sgpa_to_cgpa
sgpa_To_cgpa_convertor
2 parents e168ecc + a333b26 commit b2a36b2

File tree

3 files changed

+114
-0
lines changed

3 files changed

+114
-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.

‎Sgpa_To_Cgpa_Convertor/Sgpa_to_Cgpa.JPG

61.4 KB
Loading[フレーム]

‎Sgpa_To_Cgpa_Convertor/sga_to_cgpa.py

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
import tkinter as tk
2+
3+
4+
def create_sgpa_entries(): # Create SGPA entries based on the total number of semesters entered by the user.
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_buttons.grid_remove()
19+
cgpa_calc.grid(row=num_semesters + 2, column=0, columnspan=2, padx=10, pady=5)
20+
21+
22+
def validate_sgpa_entries(): # Validate the SGPA entries to enable or disable the CGPA calculation button.
23+
filled_entries = [entry.get() for entry in sgpa_entries]
24+
if all(filled_entries):
25+
cgpa_calc.configure(state="normal")
26+
else:
27+
cgpa_calc.configure(state="disabled")
28+
29+
30+
def calculate_cgpa(): # It is used to 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+
cgpa = total_sgpa / num_semesters
36+
37+
cgpa_label.configure(text=f"CGPA: {cgpa:.2f}")
38+
39+
reset_button.configure(state="normal")
40+
41+
42+
def reset_entries(): # This is used to reset entries after calcuting Cgpa.
43+
for label in sgpa_labels:
44+
label.destroy()
45+
for entry in sgpa_entries:
46+
entry.destroy()
47+
sgpa_labels.clear()
48+
sgpa_entries.clear()
49+
50+
create_sgpa_buttons.grid(row=1, column=0, columnspan=2, padx=10, pady=5)
51+
cgpa_calc.configure(state="disabled")
52+
cgpa_label.configure(text="CGPA: ")
53+
54+
reset_button.configure(state="disabled")
55+
56+
57+
root = tk.Tk()
58+
root.title("SGPA to CGPA Converter")
59+
60+
sgpa_frame = tk.Frame(root)
61+
sgpa_frame.pack(pady=10)
62+
63+
num_semesters_label = tk.Label(sgpa_frame, text="Total Number of Semesters:")
64+
num_semesters_label.grid(row=0, column=0, padx=10, pady=5, sticky="E")
65+
66+
num_semesters_entry = tk.Entry(sgpa_frame)
67+
num_semesters_entry.grid(row=0, column=1, padx=10, pady=5, sticky="W")
68+
69+
sgpa_labels = []
70+
sgpa_entries = []
71+
72+
create_sgpa_buttons = tk.Button(sgpa_frame, text="Create SGPA Entries", command=create_sgpa_entries)
73+
create_sgpa_buttons.grid(row=1, column=0, columnspan=2, padx=10, pady=5)
74+
75+
cgpa_calc = tk.Button(sgpa_frame, text="Calculate CGPA", command=calculate_cgpa, state="disabled")
76+
77+
cgpa_label = tk.Label(root, text="CGPA: ")
78+
cgpa_label.pack()
79+
80+
reset_button = tk.Button(root, text="Reset", command=reset_entries, state="disabled")
81+
reset_button.pack()
82+
83+
root.mainloop()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /