ChamplainTechJournals/python-csi160/week04/Week-4Practice-Problems/part5.py
2025-04-19 23:42:08 -04:00

16 lines
No EOL
636 B
Python

def one_positive(num1, num2):
"""Given two non-zero integers, returns True if exactly one of
them is positive and returns False otherwise.
:param num1: non-zero integer
:param num2: non-zero integer
:return: True / False
"""
# Complete this function
return (num1 > 0) ^ (num2 > 0)
# Leave this part for easily testing your function
print('(5, 7) It is', one_positive(5, 7), 'that only one of these numbers is positive')
print('(-5, -7) It is', one_positive(-5, -7), 'that only one of these numbers is positive')
print('(5, -7) It is', one_positive(5, -7), 'that only one of these numbers is positive')