Write a python program to check given value is PASS
or FAIL
by using IF ELSE
Statement
Description
This Python code determines whether a student has passed or failed an exam based on user-entered exam marks. It uses a conditional if-else statement to check if the marks are greater than or equal to 35 and displays "PASS" or "FAIL" accordingly.
Code
program3b.py
marks=int(input("Enter your marks"))
if marks>=35:
print("PASS")
else:
print("FAIL")
Explanation of above code
- The Python code is created to determine whether a student has passed or failed an exam, based on the marks entered by the user.
- It commences by using the input function to collect user input, representing the student's examination marks.
- A conditional statement, specifically an if statement, is used to evaluate whether the marks are greater than or equal to 35.
- If the condition is met, indicating that the student's marks are 35 or higher, the program displays 'PASS.'
- Conversely, if the condition is not satisfied, the else block is executed, resulting in the message 'FAIL' being printed.
- Essentially, the code delivers immediate feedback to the user, informing them whether they have passed or failed the examination based on their input.
- For example, if a user enters 42 as their marks, the code will respond with 'PASS,' confirming the student's success. This code serves as a fundamental illustration of decision-making in Python and is commonly used to handle pass-fail criteria in various educational contexts.