Notes
![]() ![]() Notes - notes.io |
class Student:
def __init__(self, name):
self.name = name
self.math_grade = 0
self.science_grade = 0
self.language_grade = 0
self.drama_grade = 0
self.music_grade = 0
self.biology_grade = 0
def input_grades(self, math_grade, science_grade, language_grade, drama_grade, music_grade, biology_grade):
self.math_grade = float(math_grade)
self.science_grade = float(science_grade)
self.language_grade = float(language_grade)
self.drama_grade = float(drama_grade)
self.music_grade = float(music_grade)
self.biology_grade = float(biology_grade)
def calculate_gpa(self):
total_marks = self.math_grade * 4 + self.science_grade * 5 + self.language_grade * 4 + self.drama_grade * 3 + self.music_grade * 2 + self.biology_grade * 4
total_credit_hours = 4 + 5 + 4 + 3 + 2 + 4
return total_marks / total_credit_hours
class GUI:
def __init__(self, master):
self.master = master
self.master.title("Humber College Admission System")
# Welcome Message Label
self.welcome_label = Label(master, text="Welcome to Humber College", font=("Helvetica", 16))
self.welcome_label.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
# Password Entry
self.password_label = Label(master, text="Enter password:")
self.password_label.grid(row=1, column=0)
self.password_entry = Entry(master, show="*")
self.password_entry.grid(row=1, column=1)
# Login Button
self.login_button = Button(master, text="Login", command=self.login)
self.login_button.grid(row=1, column=2)
self.password_attempts = 3
def login(self):
password = self.password_entry.get()
if self.validate_password(password):
print("Password accepted. You are logged in.")
self.show_num_students_entry()
else:
self.password_attempts -= 1
if self.password_attempts == 0:
print("You've exceeded the maximum number of attempts. Exiting...")
self.master.destroy()
else:
print(f"Invalid password. You have {self.password_attempts} attempts left.")
def validate_password(self, password):
if len(password) < 10:
return False
if not any(char.isupper() for char in password):
return False
if sum(char.isdigit() for char in password) not in (2, 3):
return False
if not any(char in '!@#$%^&*()_+{}|:"<>?' for char in password):
return False
return True
def show_num_students_entry(self):
self.num_students_label = Label(self.master, text="Enter the number of students (1-50):")
self.num_students_label.grid(row=2, column=0)
self.num_students_entry = Entry(self.master)
self.num_students_entry.grid(row=2, column=1)
self.num_students_attempts = 3
self.submit_num_students_button = Button(self.master, text="Submit", command=self.submit_num_students)
self.submit_num_students_button.grid(row=2, column=2)
def submit_num_students(self):
num_students = self.num_students_entry.get()
if num_students.isdigit() and 1 <= int(num_students) <= 50:
self.show_student_names_entry(int(num_students))
else:
self.num_students_attempts -= 1
if self.num_students_attempts == 0:
print("You've exceeded the maximum number of attempts. Exiting...")
self.master.destroy()
else:
print("Invalid input. Please enter a number between 1 and 50.")
print(f"You have {self.num_students_attempts} attempts left.")
def show_student_names_entry(self, num_students):
self.student_name_labels = []
self.student_name_entries = []
for i in range(num_students):
label = Label(self.master, text=f"Enter the name of student {i + 1}:")
label.grid(row=i + 3, column=0)
self.student_name_labels.append(label)
entry = Entry(self.master)
entry.grid(row=i + 3, column=1)
self.student_name_entries.append(entry)
self.submit_student_names_button = Button(self.master, text="Submit", command=self.submit_student_names)
self.submit_student_names_button.grid(row=num_students + 3, column=0, columnspan=2)
def submit_student_names(self):
self.show_grades_entry()
def show_grades_entry(self):
self.grade_labels = ['Math', 'Science', 'Language', 'Drama', 'Music', 'Biology']
self.grade_entries = []
row_counter = len(self.student_name_entries) + 4
for i in range(len(self.student_name_entries)):
student_name = self.student_name_entries[i].get()
label_student = Label(self.master, text=f"{student_name}'s grades:")
label_student.grid(row=row_counter, column=0, columnspan=2)
row_counter += 1
grade_entries_row = []
for j in range(len(self.grade_labels)):
label = Label(self.master, text=f"{self.grade_labels[j]} grade:")
label.grid(row=row_counter, column=j * 2)
entry = Entry(self.master)
entry.grid(row=row_counter, column=j * 2 + 1)
grade_entries_row.append(entry)
row_counter += 1
self.grade_entries.append(grade_entries_row)
self.submit_grades_button = Button(self.master, text="Submit", command=self.submit_grades)
self.submit_grades_button.grid(row=row_counter, column=0, columnspan=len(self.grade_labels) * 2)
def submit_grades(self):
students = []
for i in range(len(self.student_name_entries)):
student_name = self.student_name_entries[i].get()
grades = [entry.get() for entry in self.grade_entries[i]]
student = Student(student_name)
student.input_grades(*grades)
students.append(student)
self.generate_reports(students)
def generate_reports(self, students):
accepted_students = {'School of Engineering': [], 'School of Business': [], 'Law School': [], 'Not accepted': []}
for student in students:
gpa = student.calculate_gpa()
school = self.assign_school(gpa)
accepted_students[school].append(student.name)
print("nReport 1: Student Name, School Name")
for school, students_list in accepted_students.items():
for student in students_list:
print(student + ": " + school)
print("nReport 2: Number of accepted students in Humber College showing students distribution per each school")
for school, students_list in accepted_students.items():
print(school + ": " + str(len(students_list)))
print("nReport 3: Number of students that were not accepted")
print("Not accepted:", len(accepted_students['Not accepted']))
def assign_school(self, gpa):
if 90 <= gpa <= 100:
return "School of Engineering"
elif 80 <= gpa < 90:
return "School of Business"
elif 70 <= gpa < 80:
return "Law School"
else:
return "Not accepted"
def main():
root = Tk()
gui = GUI(root)
root.mainloop()
main()
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team