Solution Review: Pass or Fail

In the following lesson, we will go over the solution of the challenge: Pass or Fail

We'll cover the following

Task

In this challenge, you were provided the final percentage a student had at the end of the semester. You had to write a program which would determine if the student passed or failed. If the percentage was greater than or equal to 60, the student passed, and if it was less than 60, the student failed.

Solution

Let’s go over the solution step-by-step.

  • The first thing you had to figure out is that this problem has conditions and would require an if-else expression.

  • Next, you had to figure out what the conditions were. The first condition is that the student gets a percentage which is greater than or equal to 60. In which case you would print pass.

if (percentage >= 60)
  print("pass")
  • Finally, the last step required you to figure out the default condition, which was that the student gets a percentage which is less than 60. In this case, you would print fail.
else
  print("fail")

You can find the complete solution below:

You were required to write the code from line 3 to line 6.

Create a free account to access the full course.

By signing up, you agree to Educative's Terms of Service and Privacy Policy