Question: I keep getting this error, can anyone please fix it? This is the base code # Python program that returns true if there is #
I keep getting this error, can anyone please fix it?
This is the base code
# Python program that returns true if there is # a Pythagorean Triplet in a given array. # Returns true if there is Pythagorean # triplet in ar[0..n-1] def isTriplet(ar, n): # Square all the elemennts for i in range(n): ar[i] = ar[i] * ar[i] # sort array elements ar.sort() # fix one element # and find other two # i goes from n - 1 to 2 for i in range(n-1, 1, -1): # start two index variables from # two corners of the array and # move them toward each other j = 0 k = i - 1 while (j

60 import unittest 7 from geeksforgeeks.algorithm import isTriplet test _main__ 018 90 class isTriplet(unittest. TestCase): A100 def test (self): 11 012 arr1 = (3,1,4,6,5] 13 arr2 = (3,4,5) 114 arr3 = (10,4,6,12,5] 15 016 self-assertEqual(isTriplet (arri, 5), True) 617 self assertEqual(isTriplet (arri, 4), False) self.assertEqual(isTriplet(arr2, 5), False) 19 self.assertEqual(isTriplet (arr3, 2), False) 20 21 22 23 24 25 26 27 if _name == "_main": 28 unittest.main() A 29 e Console X Ru PyUnit
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
