migrate to git.charlotte.sh
This commit is contained in:
commit
fbd588721e
412 changed files with 13750 additions and 0 deletions
16
python-csi160/week04/Week-4Practice-Problems/part5.py
Normal file
16
python-csi160/week04/Week-4Practice-Problems/part5.py
Normal file
|
@ -0,0 +1,16 @@
|
|||
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')
|
Loading…
Add table
Add a link
Reference in a new issue