Last active
May 16, 2023 09:16
-
-
Save jatinsharrma/d1d9b956a91c90e5eca23149629bd568 to your computer and use it in GitHub Desktop.
rite a python program to find and display the product of three positive integer values based on rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Write a python program to find and display the product of three positive integer values based on the rule mentioned below: | |
#It should display the product of the three values except when one of the integer value is 7. In that case, 7 should not be included in the product and the values to its left also should not be included. | |
#If there is only one value to be considered, display that value itself. If no values can be included in the product, display -1. | |
def find_product(num1,num2,num3): | |
product=0 | |
if (num1 != 7 and num2 != 7 and num3 != 7): | |
product = num1 * num2 * num3 | |
elif (num1 == 7): | |
product = num2 * num3 | |
elif(num2 == 7): | |
product = num3 | |
elif(num3 == 7): | |
product = -1 | |
return product | |
product=find_product(2,5,7) | |
print(product) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.