Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def students_credits(*args):
- dictionary = {}
- credits_collected = 0
- for course in args:
- course_split = course.split('-')
- course_name = course_split[0]
- max_course_credits = int(course_split[1])
- max_test_points = int(course_split[2])
- diyan_points = int(course_split[3])
- percentage_test_diyan = diyan_points/max_test_points
- current_diyan_credit = max_course_credits * percentage_test_diyan
- credits_collected += current_diyan_credit
- dictionary[course_name] = current_diyan_credit
- result = ''
- if credits_collected >= 240:
- result += f"Diyan gets a diploma with {credits_collected:.1f} credits.\n"
- else:
- diff = 240 - credits_collected
- result += f"Diyan needs {diff:.1f} credits more for a diploma.\n"
- sorted_dictionary = dict(sorted(dictionary.items(), key=lambda x: -x[1]))
- for el, score in sorted_dictionary.items():
- result += f'{el} - {score:.1f}\n'
- return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement