Professional Documents
Culture Documents
P 2
P 2
The code enters an outer infinite loop, which will continue until the user decides
to exit and showcase the results.
Inside the loop, the get_credits function is called three times to get the credits
for Pass, Defer, and Fail. The entered credits are stored in variables p_credits,
d_credits, and f_credits respectively.
The total credits are calculated by summing up the Pass, Defer, and Fail credits.
If the total credits do not equal 120, the code prints "Total incorrect" and
continues to the next iteration of the loop.
If the Pass credits equal 120, it means the student has passed all modules and the
outcome is "Progress". The progress_count variable is incremented and the outcome
is printed using the print_outcome function.
If the Pass credits equal 100, it means the student is in the "module trailer"
category. The module_trailer_count variable is incremented and the outcome is
printed.
If the Fail credits are greater than or equal to 80, the student is in the
"exclude" category. The exclude_count variable is incremented and the outcome is
printed.
If none of the above conditions are met, the student is in the "module retriever"
category. The module_retriever_count variable is incremented and the outcome is
printed.
After determining the outcome, the code asks the user if they want to continue
entering data or exit and showcase the results. The user's input is stored in the
exit_or_continue variable.
If the user chooses to continue (by entering 'Y'), the code continues to the next
iteration of the loop.
If the user chooses to exit and showcase the results (by entering 'Q'), the code
prints "Collecting Data..." and breaks out of the outer loop.
After the outer loop is exited, the code calculates the total number of outcomes by
summing up the count variables.
The code prints a line of underscores to separate the histogram from other output.
The code then prints a histogram of the outcomes using asterisks (*) to represent
the count of each outcome category. The count and histogram for each category are
displayed.
The code iterates through the List and prints each element (assumed to be a string)
on a new line.