- 1 year ago
program to verify a number by two requirements
Comment
1 / 1
To verify a number based on two requirements, you can write a program in Python. Here's an example:
pythondef verify_number(number):
# Check if the number is positive
if number > 0:
# Check if the number is even
if number % 2 == 0:
return "Number meets both requirements."
else:
return "Number is positive but not even."
else:
return "Number is not positive."
# Test the program
num = int(input("Enter a number: "))
result = verify_number(num)
print(result)
In this program, the verify_number()
function takes an input number and checks two requirements:
- Positive Number: It checks if the number is greater than zero.
- Even Number: It checks if the number is divisible by 2 without any remainder.
Based on these requirements, the program returns a corresponding message indicating whether the number meets both requirements, is positive but not even, or is not positive.
You can run the program, enter a number, and it will display the result based on the requirements. Feel free to modify the requirements or add additional checks as per your specific needs.