Challenge: Pass or Fail
est yourself and implement what you have learned so far in this chapter.
We'll cover the following
Problem statement
Given the final percentage a student has gotten at the end of a semester, you need to write a program that decides if the student has passed or failed the semester.
If the percentage is higher than or equal to 60, the student has passed the semester. If the percentage is lower than 60, the student has failed the semester.
However, the percentage is not the only thing that determines if a student has passed or failed. A student does not pass if their score is 5 points below the class average.
For instance, if the average class score is 70, the student must have a minimum score of 65 to pass.
If the average class score is 50, the student still needs a score of 60 to pass based on our first condition.
average
has already been declared for you.
Input
The input will be the variable percentage
which stores the final percentage the student received.
percentage
has already been declared for you.
Output
The output should be pass
if the student has a percentage higher than or equal to 60 while also being 5 within the average class score, otherwise it would be fail
.
The result should be displayed as output.
Sample input
81
Sample output
pass
Test yourself
Write your code in the given area. Try the exercise by yourself first, but if you get stuck, the solution has been provided. Good luck!
Create a free account to access the full course.
By signing up, you agree to Educative's Terms of Service and Privacy Policy