Write a function named `pairs(a,b,c,d)` that takes four integers as its input and checks whether the sum of any two of t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a function named `pairs(a,b,c,d)` that takes four integers as its input and checks whether the sum of any two of t

Post by answerhappygod »

Write a function named `pairs(a,b,c,d)` that takes four
integers as its input and checks whether the sum of any
two of these integers is equal to the sum of the other two.
If so, the function RETURNs this sum. Otherwise, it RETURNs -1.
For example, `pairs(1,2,3,4)` should return 5,
because 1 + 4 = 2 + 3 = 5.
Another example, `pairs(11,22,13,20)` should return 33,
because 11 + 22 = 13 + 20 = 33.
Another example, `pairs(1,2,3,5)` should return -1,
because no such two pairs exist among these numbers.
"""
def pairs(a,b,c,d):
# remove the following line to solve this question
return
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply