Created
November 26, 2020 18:10
-
-
Save cobanov/59f77ced777de13e2a9ef734bdb7d7b0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def validation(user_input): | |
colons = user_input.count(":") | |
semicolons = user_input.count(";") | |
if user_input[-1:] == ":": | |
print("Invalid input, please try again!") | |
return False | |
if colons != (semicolons + 1): | |
print("Invalid input, please try again!") | |
return False | |
else: | |
return True | |
def previous_courses_func(previous_courses): | |
student_previous = dict() | |
previous_courses = previous_courses.split(";") | |
for item in previous_courses: | |
course, grade = item.split(":") | |
student_previous[course] = grade.upper() | |
return student_previous | |
def current_courses_func(current_courses): | |
student_current = dict() | |
current_courses = current_courses.split(";") | |
for item in current_courses: | |
course, grade = item.split(":") | |
student_current[course] = grade.upper() | |
return student_current | |
def show_grades(student_current, student_previous): | |
for course, grade in student_current.items(): | |
if grade != "F": | |
print(f"You can choose between S and {grade} for {course}.") | |
student_current[course] = "S" | |
elif course not in student_previous.keys(): | |
print(f"Your grade for {course} is U.") | |
student_current[course] = "U" | |
elif course in student_previous.keys(): | |
if student_previous[course] == "U": | |
print(f"Your grade for {course} is U.") | |
student_current[course] = "U" | |
else: | |
print(f"Your grade for {course} is F.") | |
student_current[course] = "F" | |
def main(): | |
status = True | |
while status: | |
# Previous | |
previous_courses = input( | |
"Please enter the courses you have taken previously with letter grades:") | |
status = validation(previous_courses) | |
student_previous = previous_courses_func(previous_courses) | |
print("Previous Courses and Grades: ", student_previous) | |
print("\n") | |
# Current | |
current_courses = input( | |
"Please enter the courses you have taken this semester with letter grades:") | |
status = validation(current_courses) | |
student_current = current_courses_func(current_courses) | |
print("Current Courses and Grades: ", student_current) | |
print("\n") | |
# wanted | |
wanted_course = input("Please enter the course you want to check: ") | |
if(wanted_course not in student_current.keys()): | |
print(f"You didn't take {wanted_course} this semester\n") | |
show_grades(student_current, student_previous) | |
check_try = input("Try again? y | n \n") | |
if check_try == "y": | |
continue | |
else: | |
break | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment