Logic Building
# Take number
num = int(input("Enter a number: "))
# Check conditions
is_multiple = num % 7 == 0
ends_with_7 = num % 10 == 7
if is_multiple or ends_with_7:
print("Number is multiple of 7 or ends with 7")
else:
print("Number is neither multiple of 7 nor ends with 7")Output
Enter a number: 14 Number is multiple of 7 or ends with 7 Enter a number: 17 Number is multiple of 7 or ends with 7 Enter a number: 15 Number is neither multiple of 7 nor ends with 7
Use OR operator to check either condition.
Key Concepts:
- Multiple of 7: num % 7 == 0
- Ends with 7: num % 10 == 7
- Use 'or' to check if either is true