Answer to Question #264621 in Python for swsq

Question #264621

An e-commerce application wants to give discounts to its customers. The discount is calculated as the product of the sum of even numbers and the sum of odd numbers present in the bill. Print the discount that a customer can get.

  1. Input: 2345, Output: 48 

Explanation: even_sum = 2+4 = 6.

Odd_sum = 3+5 = 8.

Product = 6*8 = 48.


1
Expert's answer
2021-11-19T17:20:39-0500
def dis_app(numbers):
    r = 0
    s = 0
    for i in numbers:
        if i % 2 == 0:
            r = r + i
        else:
            s = s + i
    return r * s
dis_app([4,5,6,7])

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS