HERE IS THE CODE
- pass_mark = 70
- # Input marks for each subject
- chemistry_mark = int(input("Chemistry: "))
- english_mark = int(input("English: "))
- biology_mark = int(input("Biology: "))
- math_mark = int(input("Math: "))
- it_mark = int(input("IT: "))
- # Calculate pass or fail status and percentage required to pass
- chemistry_status = "Pass" if chemistry_mark >= pass_mark else "Fail"
- chemistry_percent = max(0, pass_mark - chemistry_mark)
- english_status = "Pass" if english_mark >= pass_mark else "Fail"
- english_percent = max(0, pass_mark - english_mark)
- biology_status = "Pass" if biology_mark >= pass_mark else "Fail"
- biology_percent = max(0, pass_mark - biology_mark)
- math_status = "Pass" if math_mark >= pass_mark else "Fail"
- math_percent = max(0, pass_mark - math_mark)
- it_status = "Pass" if it_mark >= pass_mark else "Fail"
- it_percent = max(0, pass_mark - it_mark)
- # Output results
- print(f"Chemistry: {chemistry_mark} : {chemistry_status}: {chemistry_percent}% more required to pass")
- print(f"English: {english_mark} : {english_status}: {english_percent}% more required to pass")
- print(f"Biology: {biology_mark} : {biology_status}: {biology_percent}% more required to pass")
- print(f"Math: {math_mark} : {math_status}: {math_percent}% more required to pass")
- print(f"IT: {it_mark} : {it_status}: {it_percent}% more required to pass")
The program asks the user to enter their scores for each subject, determines if they passed or failed, and calculates how much more they need to score in order to pass. The percentage needed to pass is never negative thanks to the use of the max() method. The desired format for the results is printed using the f-string format.