Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

multiplication or sum of two numbers

Given two integer numbers, return their product only
if the product is equal to or lower than 1000, else return their sum.

Def multiplication_or_sum(num1, num2):
    product = num1 * num2
    if product < = 1000:
        return product
    else:
        return num1 + num2

result = multiplication_or_sum(20,30)
print("The result is = ", result)


result = multiplication_or_sum(50,10)
print("The result is = ", result)

my output

The result is =  600
The result is =  500

expected output

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The result is =  600
The result is =  60

but Can’t figure out the error

>Solution :

if the product is equal to or lower than 1000, else return their sum.

if x*y <= 1000:
   return x*y
else:
   return x+y 

20 * 30 = 600
600 < 1000
return 600

50 * 10 = 500
500 < 1000
return 500

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading