Skip to content

Instantly share code, notes, and snippets.

@jatinsharrma
Last active May 16, 2023 09:16
Show Gist options
  • Save jatinsharrma/d1d9b956a91c90e5eca23149629bd568 to your computer and use it in GitHub Desktop.
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
#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)
@Aki-cobrakai
Copy link

Aki-cobrakai commented Apr 25, 2022

n1 = int(input("Enter first number: "))
n2 = int(input("Enter second number: "))
n3 = int(input("Enter third number: "))


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


final_product = find_product(n1, n2, n3)
print(final_product)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment