briank282
New Coder
hi i need help the ;last part is not retunred and i have no idea... thank you
According to this xkcd cartoon you shouldn't date someone whose age is less than half your own age plus 7. Write a boolean-valued function can_date(age1, age2) that takes the ages of two people and return True if they can date, according to xkcd's rule.
Notes:
def can_date(age1, age2):
"""return"""
if age1 // 2 + 7 == age2:
return True
elif age2 // 2 + 7 == age1:
return True
elif age1 == age2:
return True
else:
return False
everthing returns except the all good
According to this xkcd cartoon you shouldn't date someone whose age is less than half your own age plus 7. Write a boolean-valued function can_date(age1, age2) that takes the ages of two people and return True if they can date, according to xkcd's rule.
Notes:
- The ages are not in any particular order - the bigger one may be either first or last.
- Assume integer division so that, for example, a 19-year-old can date a 16-year-old because we take half of 19 to be 9 not 9.5.
def can_date(age1, age2):
"""return"""
if age1 // 2 + 7 == age2:
return True
elif age2 // 2 + 7 == age1:
return True
elif age1 == age2:
return True
else:
return False
everthing returns except the all good
print(can_date(24, 19)) | True | True | ||
print(can_date(19, 24)) | True | True | ||
print(can_date(24, 18)) | False | False | ||
print(can_date(16, 16)) | True | True | ||
print(can_date(14, 16)) | False | False | ||
print(can_date(16, 15)) | True | True | ||
print(can_date(73, 43)) | True | True | ||
print(can_date(42, 73)) | False | False | ||
run_lots_of_tests() | All good | can_date(1, 1) returned True, should be False |