Python if Statement: Pass/Fail Based on Average
This Snippet is coded by a user inOnline python Compiler. You can see and run this code too.
زبان: python
This code is a simple Python program that takes the student's average as input and uses an if statement to check whether the average is greater than 10. If the condition is true, it prints the message "You have passed".
Here's how the code works:
- The user is prompted to enter their average using
input(). - The input string is converted to an integer with
int(). - The average is compared with 10 using the
>operator. - If
avg > 10is true, the message is printed.
This example demonstrates the use of a basic conditional statement and the importance of proper indentation in Python.