Computer Science, asked by prishabh6431, 11 months ago

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. Note: Assume that if 7 is one of the positive integer values, then it will occur only once. Refer the sample I/O given below.

Answers

Answered by qwtiger
8

Answer:

python program to find and display the product of three positive integer

Explanation:

def multiplyList(myList) :  

     

   # Multiply elements one by one  

   result = 1

   for x in myList:  

        result = result * x  

   return result  

     

# Driver code  

list1 = [1, 2, 3]  

list2 = [3, 2, 4]  

print(multiplyList(list1))  

print(multiplyList(list2))

Answered by thanugowda53
26

Answer:

def find_product(num1,num2,num3):

   product=0

   if (num1==7):

       product=num2*num3

   elif(num2==7):

       product=num3

   elif(num1!=7 and num2!=7 and num3!=7):

       product=num1*num2*num3

   else:

       product=-1

   return product

#Provide different values for num1, num2, num3 and test your program

product=find_product(7,6,2)

print(product)

Similar questions