Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the longest chain which can be formed from the given set of pairs.

 Your code should pass these tests:

['assert max_chain_length([Pair(5, 24), Pair(15, 25),Pair(27, 40), Pair(50, 60)], 4) == 3', 'assert max_chain_length([Pair(1, 2), Pair(3, 4),Pair(5, 6), Pair(7, 8)], 4) == 4', 'assert max_chain_length([Pair(19, 10), Pair(11, 12),Pair(13, 14), Pair(15, 16), Pair(31, 54)], 5) == 5']
[BEGIN]

Response:
class Pair(object):
	def __init__(self, a, b):
		self.a = a
		self.b = b
def max_chain_length(arr, n):
	max = 0
	mcl = [1 for i in range(n)]
	for i in range(1, n):
		for j in range(0, i):
			if (arr[i].a > arr[j].b and
				mcl[i] < mcl[j] + 1):
				mcl[i] = mcl[j] + 1
	for i in range(n):
		if (max < mcl[i]):
			max = mcl[i]
	return max
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the first repeated character in a given string.

 Your code should pass these tests:

['assert first_repeated_char("abcabc") == "a"', 'assert first_repeated_char("abc") == "None"', 'assert first_repeated_char("123123") == "1"']
[BEGIN]

Response:
def first_repeated_char(str1):
  for index,c in enumerate(str1):
    if str1[:index+1].count(c) > 1:
      return c
  return "None"
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to get a lucid number smaller than or equal to n.

 Your code should pass these tests:

['assert get_ludic(10) == [1, 2, 3, 5, 7]', 'assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25]', 'assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]']
[BEGIN]

Response:
def get_ludic(n):
	ludics = []
	for i in range(1, n + 1):
		ludics.append(i)
	index = 1
	while(index != len(ludics)):
		first_ludic = ludics[index]
		remove_index = index + first_ludic
		while(remove_index < len(ludics)):
			ludics.remove(ludics[remove_index])
			remove_index = remove_index + first_ludic - 1
		index += 1
	return ludics
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to reverse words in a given string.

 Your code should pass these tests:

['assert reverse_words("python program")==("program python")', 'assert reverse_words("java language")==("language java")', 'assert reverse_words("indian man")==("man indian")']
[BEGIN]

Response:
def reverse_words(s):
        return ' '.join(reversed(s.split()))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the given integer is a prime number.

 Your code should pass these tests:

['assert prime_num(13)==True', 'assert prime_num(7)==True', 'assert prime_num(-1010)==False']
[BEGIN]

Response:
def prime_num(num):
  if num >=1:
   for i in range(2, num//2):
     if (num % i) == 0:
                return False
     else:
                return True
  else:
          return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to convert degrees to radians.

 Your code should pass these tests:

['assert radian_degree(90)==1.5707963267948966', 'assert radian_degree(60)==1.0471975511965976', 'assert radian_degree(120)==2.0943951023931953']
[BEGIN]

Response:
import math
def radian_degree(degree):
 radian = degree*(math.pi/180)
 return radian
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs by using regex.

 Your code should pass these tests:

["assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19)", "assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21)", "assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)"]
[BEGIN]

Response:
import re
pattern = 'fox'
text = 'The quick brown fox jumps over the lazy dog.'
def find_literals(text, pattern):
  match = re.search(pattern, text)
  s = match.start()
  e = match.end()
  return (match.re.pattern, s, e)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find nth bell number.

 Your code should pass these tests:

['assert bell_Number(2) == 2', 'assert bell_Number(3) == 5', 'assert bell_Number(4) == 15']
[BEGIN]

Response:
def bell_Number(n):
    bell = [[0 for i in range(n+1)] for j in range(n+1)]
    bell[0][0] = 1
    for i in range(1, n+1):
        bell[i][0] = bell[i-1][i-1]
        for j in range(1, i+1):
            bell[i][j] = bell[i-1][j-1] + bell[i][j-1]
    return bell[n][0]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find minimum possible value for the given periodic function.

 Your code should pass these tests:

['assert floor_Min(10,20,30) == 15', 'assert floor_Min(1,2,1) == 0', 'assert floor_Min(11,10,9) == 9']
[BEGIN]

Response:
def floor_Min(A,B,N):
    x = max(B - 1,N)
    return (A*x) // B
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to remove the k'th element from a given list.

 Your code should pass these tests:

['assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1]', 'assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4]', 'assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 17, 18, 10]']
[BEGIN]

Response:
def remove_kth_element(list1, L):
    return  list1[:L-1] + list1[L:]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the maximum of nth column from the given tuple list.

 Your code should pass these tests:

['assert max_of_nth([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 19', 'assert max_of_nth([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 10', 'assert max_of_nth([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 1) == 11']
[BEGIN]

Response:
def max_of_nth(test_list, N):
  res = max([sub[N] for sub in test_list])
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to merge the first and last elements separately in a list of lists.

 Your code should pass these tests:

["assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']]", 'assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]]', "assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]"]
[BEGIN]

Response:
def merge(lst):
    return [list(ele) for ele in list(zip(*lst))]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the maximum value in record list as tuple attribute in the given tuple list.

 Your code should pass these tests:

["assert maximum_value([('key1', [3, 4, 5]), ('key2', [1, 4, 2]), ('key3', [9, 3])]) == [('key1', 5), ('key2', 4), ('key3', 9)]", "assert maximum_value([('key1', [4, 5, 6]), ('key2', [2, 5, 3]), ('key3', [10, 4])]) == [('key1', 6), ('key2', 5), ('key3', 10)]", "assert maximum_value([('key1', [5, 6, 7]), ('key2', [3, 6, 4]), ('key3', [11, 5])]) == [('key1', 7), ('key2', 6), ('key3', 11)]"]
[BEGIN]

Response:
def maximum_value(test_list):
  res = [(key, max(lst)) for key, lst in test_list]
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the cumulative sum of all the values that are present in the given tuple list.

 Your code should pass these tests:

['assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30', 'assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37', 'assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44']
[BEGIN]

Response:
def cummulative_sum(test_list):
  res = sum(map(sum, test_list))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find average value of the numbers in a given tuple of tuples.

 Your code should pass these tests:

['assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25]', 'assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75]', 'assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]']
[BEGIN]

Response:
def average_tuple(nums):
    result = [sum(x) / len(x) for x in zip(*nums)]
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to perfom the modulo of tuple elements in the given two tuples.

 Your code should pass these tests:

['assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1)', 'assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1)', 'assert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)']
[BEGIN]

Response:
def tuple_modulo(test_tup1, test_tup2):
  res = tuple(ele1 % ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.

 Your code should pass these tests:

['assert min_Jumps(3,4,11)==3.5', 'assert min_Jumps(3,4,0)==0', 'assert min_Jumps(11,14,11)==1']
[BEGIN]

Response:
def min_Jumps(a, b, d):
    temp = a
    a = min(a, b)
    b = max(temp, b)
    if (d >= b):
        return (d + b - 1) / b
    if (d == 0):
        return 0
    if (d == a):
        return 1
    else:
        return 2
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to divide two lists using map and lambda function.

 Your code should pass these tests:

['assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0]', 'assert div_list([3,2],[1,4])==[3.0, 0.5]', 'assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]']
[BEGIN]

Response:
def div_list(nums1,nums2):
  result = map(lambda x, y: x / y, nums1, nums2)
  return list(result)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to move all the numbers in it to the given string.

 Your code should pass these tests:

["assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000'", "assert move_num('Avengers124Assemble') == 'AvengersAssemble124'", "assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'"]
[BEGIN]

Response:
def move_num(test_str):
  res = ''
  dig = ''
  for ele in test_str:
    if ele.isdigit():
      dig += ele
    else:
      res += ele
  res += dig
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the largest subset where each pair is divisible.

 Your code should pass these tests:

['assert largest_subset([ 1, 3, 6, 13, 17, 18 ], 6) == 4', 'assert largest_subset([10, 5, 3, 15, 20], 5) == 3', 'assert largest_subset([18, 1, 3, 6, 13, 17], 6) == 4']
[BEGIN]

Response:
def largest_subset(a, n):
	dp = [0 for i in range(n)]
	dp[n - 1] = 1;
	for i in range(n - 2, -1, -1):
		mxm = 0;
		for j in range(i + 1, n):
			if a[j] % a[i] == 0 or a[i] % a[j] == 0:
				mxm = max(mxm, dp[j])
		dp[i] = 1 + mxm
	return max(dp)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to increment the numeric values in the given strings by k.

 Your code should pass these tests:

['assert increment_numerics(["MSM", "234", "is", "98", "123", "best", "4"] , 6) == [\'MSM\', \'240\', \'is\', \'104\', \'129\', \'best\', \'10\']', 'assert increment_numerics(["Dart", "356", "is", "88", "169", "Super", "6"] , 12) == [\'Dart\', \'368\', \'is\', \'100\', \'181\', \'Super\', \'18\']', 'assert increment_numerics(["Flutter", "451", "is", "44", "96", "Magnificent", "12"] , 33) == [\'Flutter\', \'484\', \'is\', \'77\', \'129\', \'Magnificent\', \'45\']']
[BEGIN]

Response:
def increment_numerics(test_list, K):
  res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]
  return res
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the median of two sorted arrays of same size.

 Your code should pass these tests:

['assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0', 'assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5', 'assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0']
[BEGIN]

Response:
def get_median(arr1, arr2, n):
  i = 0
  j = 0
  m1 = -1
  m2 = -1
  count = 0
  while count < n + 1:
    count += 1
    if i == n:
      m1 = m2
      m2 = arr2[0]
      break
    elif j == n:
      m1 = m2
      m2 = arr1[0]
      break
    if arr1[i] <= arr2[j]:
      m1 = m2
      m2 = arr1[i]
      i += 1
    else:
      m1 = m2
      m2 = arr2[j]
      j += 1
  return (m1 + m2)/2
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the n-th power of individual elements in a list using lambda function.

 Your code should pass these tests:

['assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100]', 'assert nth_nums([10,20,30],3)==([1000, 8000, 27000])', 'assert nth_nums([12,15],5)==([248832, 759375])']
[BEGIN]

Response:
def nth_nums(nums,n):
 nth_nums = list(map(lambda x: x ** n, nums))
 return nth_nums
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to convert the given string to upper case.

 Your code should pass these tests:

['assert is_upper("person") =="PERSON"', 'assert is_upper("final") == "FINAL"', 'assert is_upper("Valid") == "VALID"']
[BEGIN]

Response:
def is_upper(string):
  return (string.upper())
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to interchange first and last elements in a given list.

 Your code should pass these tests:

['assert swap_List([1,2,3]) == [3,2,1]', 'assert swap_List([1,2,3,4,4]) == [4,2,3,4,1]', 'assert swap_List([4,5,6]) == [6,5,4]']
[BEGIN]

Response:
def swap_List(newList):
    size = len(newList)
    temp = newList[0]
    newList[0] = newList[size - 1]
    newList[size - 1] = temp
    return newList
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the largest triangle that can be inscribed in the semicircle.

 Your code should pass these tests:

['assert triangle_area(0) == 0', 'assert triangle_area(-1) == -1', 'assert triangle_area(2) == 4']
[BEGIN]

Response:
def triangle_area(r) :
    if r < 0 :
        return -1
    return r * r
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the smallest missing number from the given array.

 Your code should pass these tests:

['assert find_First_Missing([0,1,2,3],0,3) == 4', 'assert find_First_Missing([0,1,2,6,9],0,4) == 3', 'assert find_First_Missing([2,3,5,8,9],0,4) == 0']
[BEGIN]

Response:
def find_First_Missing(array,start,end):
    if (start > end):
        return end + 1
    if (start != array[start]):
        return start;
    mid = int((start + end) / 2)
    if (array[mid] == mid):
        return find_First_Missing(array,mid+1,end)
    return find_First_Missing(array,start,mid)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'.

 Your code should pass these tests:

['assert replace_spaces("My Name is Dawood") == \'My%20Name%20is%20Dawood\'', 'assert replace_spaces("I am a Programmer") == \'I%20am%20a%20Programmer\'', 'assert replace_spaces("I love Coding") == \'I%20love%20Coding\'']
[BEGIN]

Response:
MAX=1000;
def replace_spaces(string):
  string=string.strip()
  i=len(string)
  space_count=string.count(' ')
  new_length = i + space_count*2
  if new_length > MAX:
    return -1
  index = new_length-1
  string=list(string)
  for f in range(i-2, new_length-2):
    string.append('0')
  for j in range(i-1, 0, -1):
    if string[j] == ' ':
      string[index] = '0'
      string[index-1] = '2'
      string[index-2] = '%'
      index=index-3
    else:
      string[index] = string[j]
      index -= 1
  return ''.join(string)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find even numbers from a mixed list.

 Your code should pass these tests:

['assert Split([1,2,3,4,5]) == [2,4]', 'assert Split([4,5,6,7,8,0,1]) == [4,6,8,0]', 'assert Split ([8,12,15,19]) == [8,12]']
[BEGIN]

Response:
def Split(list):
    ev_li = []
    for i in list:
        if (i % 2 == 0):
            ev_li.append(i)
    return ev_li
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to extract all the adjacent coordinates of the given coordinate tuple.

 Your code should pass these tests:

['assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]]', 'assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]]', 'assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]']
[BEGIN]

Response:
def adjac(ele, sub = []):
  if not ele:
     yield sub
  else:
     yield from [idx for j in range(ele[0] - 1, ele[0] + 2)
                for idx in adjac(ele[1:], sub + [j])]
def get_coordinates(test_tup):
  res = list(adjac(test_tup))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.

 Your code should pass these tests:

["assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle'", "assert replace_spaces('The Avengers') == 'The_Avengers'", "assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'"]
[BEGIN]

Response:
import re
text = 'Python Exercises'
def replace_spaces(text):
  text =text.replace (" ", "_")
  return (text)
  text =text.replace ("_", " ")
  return (text)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to move all zeroes to the end of the given list.

 Your code should pass these tests:

['assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0]', 'assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0]', 'assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]']
[BEGIN]

Response:
def move_zero(num_list):
    a = [0 for i in range(num_list.count(0))]
    x = [ i for i in num_list if i != 0]
    x.extend(a)
    return (x)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the sum of xor of all pairs of numbers in the given array.

 Your code should pass these tests:

['assert pair_OR_Sum([5,9,7,6],4) == 47', 'assert pair_OR_Sum([7,3,5],3) == 12', 'assert pair_OR_Sum([7,3],2) == 4']
[BEGIN]

Response:
def pair_OR_Sum(arr,n) :
    ans = 0
    for i in range(0,n) :
        for j in range(i + 1,n) :
            ans = ans + (arr[i] ^ arr[j])
    return ans
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the sum of fourth power of first n even natural numbers.

 Your code should pass these tests:

['assert even_Power_Sum(2) == 272', 'assert even_Power_Sum(3) == 1568', 'assert even_Power_Sum(4) == 5664']
[BEGIN]

Response:
def even_Power_Sum(n):
    sum = 0;
    for i in range(1,n + 1):
        j = 2*i;
        sum = sum + (j*j*j*j);
    return sum;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to push all values into a heap and then pop off the smallest values one at a time.

 Your code should pass these tests:

['assert heap_sort([1, 3, 5, 7, 9, 2, 4, 6, 8, 0])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]', 'assert heap_sort([25, 35, 22, 85, 14, 65, 75, 25, 58])==[14, 22, 25, 25, 35, 58, 65, 75, 85]', 'assert heap_sort( [7, 1, 9, 5])==[1,5,7,9]']
[BEGIN]

Response:
import heapq as hq
def heap_sort(iterable):
    h = []
    for value in iterable:
        hq.heappush(h, value)
    return [hq.heappop(h) for i in range(len(h))]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.

 Your code should pass these tests:

['assert Check_Solution(2,0,2) == "Yes"', 'assert Check_Solution(2,-5,2) == "Yes"', 'assert Check_Solution(1,2,3) == "No"']
[BEGIN]

Response:
def Check_Solution(a,b,c):
    if (a == c):
        return ("Yes");
    else:
        return ("No");
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check whether the given amount has no profit and no loss

 Your code should pass these tests:

['assert noprofit_noloss(1500,1200)==False', 'assert noprofit_noloss(100,100)==True', 'assert noprofit_noloss(2000,5000)==False']
[BEGIN]

Response:
def noprofit_noloss(actual_cost,sale_amount):
  if(sale_amount == actual_cost):
    return True
  else:
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate wind chill index.

 Your code should pass these tests:

['assert wind_chill(120,35)==40', 'assert wind_chill(40,70)==86', 'assert wind_chill(10,100)==116']
[BEGIN]

Response:
import math
def wind_chill(v,t):
 windchill = 13.12 + 0.6215*t -  11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)
 return int(round(windchill, 0))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.

 Your code should pass these tests:

["assert sample_nam(['sally', 'Dylan', 'rebecca', 'Diana', 'Joanne', 'keith'])==16", 'assert sample_nam(["php", "res", "Python", "abcd", "Java", "aaa"])==10', 'assert sample_nam(["abcd", "Python", "abba", "aba"])==6']
[BEGIN]

Response:
def sample_nam(sample_names):
  sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))
  return len(''.join(sample_names))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove the parenthesis area in a string.

 Your code should pass these tests:

['assert remove_parenthesis(["python (chrome)"])==("python")', 'assert remove_parenthesis(["string(.abc)"])==("string")', 'assert remove_parenthesis(["alpha(num)"])==("alpha")']
[BEGIN]

Response:
import re
def remove_parenthesis(items):
 for item in items:
    return (re.sub(r" ?\([^)]+\)", "", item))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the nth nonagonal number.

 Your code should pass these tests:

['assert is_nonagonal(10) == 325', 'assert is_nonagonal(15) == 750', 'assert is_nonagonal(18) == 1089']
[BEGIN]

Response:
def is_nonagonal(n):
	return int(n * (7 * n - 5) / 2)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove similar rows from the given tuple matrix.

 Your code should pass these tests:

['assert remove_similar_row([[(4, 5), (3, 2)], [(2, 2), (4, 6)], [(3, 2), (4, 5)]] ) == {((2, 2), (4, 6)), ((3, 2), (4, 5))}', 'assert remove_similar_row([[(5, 6), (4, 3)], [(3, 3), (5, 7)], [(4, 3), (5, 6)]] ) == {((4, 3), (5, 6)), ((3, 3), (5, 7))}', 'assert remove_similar_row([[(6, 7), (5, 4)], [(4, 4), (6, 8)], [(5, 4), (6, 7)]] ) =={((4, 4), (6, 8)), ((5, 4), (6, 7))}']
[BEGIN]

Response:
def remove_similar_row(test_list):
  res = set(sorted([tuple(sorted(set(sub))) for sub in test_list]))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function that matches a word containing 'z', not at the start or end of the word.

 Your code should pass these tests:

['assert text_match_wordz_middle("pythonzabc.")==(\'Found a match!\')', 'assert text_match_wordz_middle("xyzabc.")==(\'Found a match!\')', 'assert text_match_wordz_middle("  lang  .")==(\'Not matched!\')']
[BEGIN]

Response:
import re
def text_match_wordz_middle(text):
        patterns = '\Bz\B'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return('Not matched!')
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to reverse an array upto a given position.

 Your code should pass these tests:

['assert reverse_Array_Upto_K([1, 2, 3, 4, 5, 6],4) == [4, 3, 2, 1, 5, 6]', 'assert reverse_Array_Upto_K([4, 5, 6, 7], 2) == [5, 4, 6, 7]', 'assert reverse_Array_Upto_K([9, 8, 7, 6, 5],3) == [7, 8, 9, 6, 5]']
[BEGIN]

Response:
def reverse_Array_Upto_K(input, k):
  return (input[k-1::-1] + input[k:])
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the product of it’s kth index in the given tuples.

 Your code should pass these tests:

['assert find_k_product([(5, 6, 7), (1, 3, 5), (8, 9, 19)], 2) == 665', 'assert find_k_product([(6, 7, 8), (2, 4, 6), (9, 10, 20)], 1) == 280', 'assert find_k_product([(7, 8, 9), (3, 5, 7), (10, 11, 21)], 0) == 210']
[BEGIN]

Response:
def get_product(val) :
	res = 1
	for ele in val:
		res *= ele
	return res
def find_k_product(test_list, K):
  res = get_product([sub[K] for sub in test_list])
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count number of cubes of size k in a cube of size n.

 Your code should pass these tests:

['assert No_of_cubes(2,1) == 8', 'assert No_of_cubes(5,2) == 64', 'assert No_of_cubes(1,1) == 1']
[BEGIN]

Response:
def No_of_cubes(N,K):
    No = 0
    No = (N - K + 1)
    No = pow(No, 3)
    return No
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to split a string at uppercase letters.

 Your code should pass these tests:

['assert split_upperstring("PythonProgramLanguage")==[\'Python\',\'Program\',\'Language\']', 'assert split_upperstring("PythonProgram")==[\'Python\',\'Program\']', 'assert split_upperstring("ProgrammingLanguage")==[\'Programming\',\'Language\']']
[BEGIN]

Response:
import re
def split_upperstring(text):
 return (re.findall('[A-Z][^A-Z]*', text))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list.

 Your code should pass these tests:

['assert exchange_elements([0,1,2,3,4,5])==[1, 0, 3, 2, 5, 4] ', 'assert exchange_elements([5,6,7,8,9,10])==[6,5,8,7,10,9] ', 'assert exchange_elements([25,35,45,55,75,95])==[35,25,55,45,95,75] ']
[BEGIN]

Response:
from itertools import zip_longest, chain, tee
def exchange_elements(lst):
    lst1, lst2 = tee(iter(lst), 2)
    return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to calculate the sum of the numbers in a list between the indices of a specified range.

 Your code should pass these tests:

['assert sum_Range_list([2, 1, 5, 6, 8, 3, 4, 9, 10, 11, 8, 12],8,10) == 29', 'assert sum_Range_list([1,2,3,4,5],1,2) == 5', 'assert sum_Range_list([1,0,1,2,5,6],4,5) == 11']
[BEGIN]

Response:
def sum_Range_list(nums, m, n):
    sum_range = 0
    for i in range(m, n+1, 1):
        sum_range += nums[i]
    return sum_range
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the given two arrays are equal or not.

 Your code should pass these tests:

['assert are_Equal([1,2,3],[3,2,1],3,3) == True', 'assert are_Equal([1,1,1],[2,2,2],3,3) == False', 'assert are_Equal([8,9],[4,5,6],2,3) == False']
[BEGIN]

Response:
def are_Equal(arr1,arr2,n,m):
    if (n != m):
        return False
    arr1.sort()
    arr2.sort()
    for i in range(0,n - 1):
        if (arr1[i] != arr2[i]):
            return False
    return True
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if one tuple is a subset of another tuple.

 Your code should pass these tests:

['assert check_subset((10, 4, 5, 6), (5, 10)) == True', 'assert check_subset((1, 2, 3, 4), (5, 6)) == False', 'assert check_subset((7, 8, 9, 10), (10, 8)) == True']
[BEGIN]

Response:
def check_subset(test_tup1, test_tup2):
  res = set(test_tup2).issubset(test_tup1)
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.

 Your code should pass these tests:

["assert matrix_to_list([[(4, 5), (7, 8)], [(10, 13), (18, 17)], [(0, 4), (10, 1)]]) == '[(4, 7, 10, 18, 0, 10), (5, 8, 13, 17, 4, 1)]'", "assert matrix_to_list([[(5, 6), (8, 9)], [(11, 14), (19, 18)], [(1, 5), (11, 2)]]) == '[(5, 8, 11, 19, 1, 11), (6, 9, 14, 18, 5, 2)]'", "assert matrix_to_list([[(6, 7), (9, 10)], [(12, 15), (20, 21)], [(23, 7), (15, 8)]]) == '[(6, 9, 12, 20, 23, 15), (7, 10, 15, 21, 7, 8)]'"]
[BEGIN]

Response:
def matrix_to_list(test_list):
  temp = [ele for sub in test_list for ele in sub]
  res = list(zip(*temp))
  return (str(res))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to group a sequence of key-value pairs into a dictionary of lists using collections module.

 Your code should pass these tests:

["assert grouping_dictionary([('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)])== ({'yellow': [1, 3], 'blue': [2, 4], 'red': [1]})", "assert grouping_dictionary([('yellow', 10), ('blue', 20), ('yellow', 30), ('blue', 40), ('red', 10)])== ({'yellow': [10, 30], 'blue': [20, 40], 'red': [10]})", "assert grouping_dictionary([('yellow', 15), ('blue', 25), ('yellow', 35), ('blue', 45), ('red', 15)])== ({'yellow': [15, 35], 'blue': [25, 45], 'red': [15]})"]
[BEGIN]

Response:
from collections import defaultdict
def grouping_dictionary(l):
    d = defaultdict(list)
    for k, v in l:
        d[k].append(v)
    return d
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the perimeter of a rectangle.

 Your code should pass these tests:

['assert rectangle_perimeter(10,20)==60', 'assert rectangle_perimeter(10,5)==30', 'assert rectangle_perimeter(4,2)==12']
[BEGIN]

Response:
def rectangle_perimeter(l,b):
  perimeter=2*(l+b)
  return perimeter
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the sum of fifth power of n natural numbers.

 Your code should pass these tests:

['assert fifth_Power_Sum(2) == 33', 'assert fifth_Power_Sum(4) == 1300', 'assert fifth_Power_Sum(3) == 276']
[BEGIN]

Response:
def fifth_Power_Sum(n) :
    sm = 0
    for i in range(1,n+1) :
        sm = sm + (i*i*i*i*i)
    return sm
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the minimum sum of absolute differences of two arrays.

 Your code should pass these tests:

['assert find_Min_Sum([3,2,1],[2,1,3],3) == 0', 'assert find_Min_Sum([1,2,3],[4,5,6],3) == 9', 'assert find_Min_Sum([4,1,8,7],[2,3,6,5],4) == 6']
[BEGIN]

Response:
def find_Min_Sum(a,b,n):
    a.sort()
    b.sort()
    sum = 0
    for i in range(n):
        sum = sum + abs(a[i] - b[i])
    return sum
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the first digit in factorial of a given number.

 Your code should pass these tests:

['assert first_Digit(5) == 1', 'assert first_Digit(10) == 3', 'assert first_Digit(7) == 5']
[BEGIN]

Response:
import math
def first_Digit(n) :
    fact = 1
    for i in range(2,n + 1) :
        fact = fact * i
        while (fact % 10 == 0) :
            fact = int(fact / 10)
    while (fact >= 10) :
        fact = int(fact / 10)
    return math.floor(fact)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the item with maximum occurrences in a given list.

 Your code should pass these tests:

['assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,4,6,9,1,2])==2', 'assert max_occurrences([1, 3,5, 7,1, 3,13, 15, 17,5, 7,9,1, 11])==1', 'assert max_occurrences([1, 2, 3,2, 4, 5,1, 1, 1])==1']
[BEGIN]

Response:
def max_occurrences(list1):
    max_val = 0
    result = list1[0]
    for i in list1:
        occu = list1.count(i)
        if occu > max_val:
            max_val = occu
            result = i
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to print duplicants from a list of integers.

 Your code should pass these tests:

['assert Repeat([10, 20, 30, 20, 20, 30, 40, 50, -20, 60, 60, -20, -20]) == [20, 30, -20, 60]', 'assert Repeat([-1, 1, -1, 8]) == [-1]', 'assert Repeat([1, 2, 3, 1, 2,]) == [1, 2]']
[BEGIN]

Response:
def Repeat(x):
    _size = len(x)
    repeated = []
    for i in range(_size):
        k = i + 1
        for j in range(k, _size):
            if x[i] == x[j] and x[i] not in repeated:
                repeated.append(x[i])
    return repeated
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to choose points from two ranges such that no point lies in both the ranges.

 Your code should pass these tests:

['assert find_Points(5,10,1,5) == (1,10)', 'assert find_Points(3,5,7,9) == (3,9)', 'assert find_Points(1,5,2,8) == (1,8)']
[BEGIN]

Response:
def find_Points(l1,r1,l2,r2):
    x = min(l1,l2) if (l1 != l2) else -1
    y = max(r1,r2) if (r1 != r2) else -1
    return (x,y)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the maximum sum that can be formed which has no three consecutive elements present.

 Your code should pass these tests:

['assert max_sum_of_three_consecutive([100, 1000, 100, 1000, 1], 5) == 2101', 'assert max_sum_of_three_consecutive([3000, 2000, 1000, 3, 10], 5) == 5013', 'assert max_sum_of_three_consecutive([1, 2, 3, 4, 5, 6, 7, 8], 8) == 27']
[BEGIN]

Response:
def max_sum_of_three_consecutive(arr, n):
	sum = [0 for k in range(n)]
	if n >= 1:
		sum[0] = arr[0]
	if n >= 2:
		sum[1] = arr[0] + arr[1]
	if n > 2:
		sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2]))
	for i in range(3, n):
		sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3])
	return sum[n-1]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort a list in a dictionary.

 Your code should pass these tests:

["assert sorted_dict({'n1': [2, 3, 1], 'n2': [5, 1, 2], 'n3': [3, 2, 4]})=={'n1': [1, 2, 3], 'n2': [1, 2, 5], 'n3': [2, 3, 4]}", "assert sorted_dict({'n1': [25,37,41], 'n2': [41,54,63], 'n3': [29,38,93]})=={'n1': [25, 37, 41], 'n2': [41, 54, 63], 'n3': [29, 38, 93]}", "assert sorted_dict({'n1': [58,44,56], 'n2': [91,34,58], 'n3': [100,200,300]})=={'n1': [44, 56, 58], 'n2': [34, 58, 91], 'n3': [100, 200, 300]}"]
[BEGIN]

Response:
def sorted_dict(dict1):
  sorted_dict = {x: sorted(y) for x, y in dict1.items()}
  return sorted_dict
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the largest possible value of k such that k modulo x is y.

 Your code should pass these tests:

['assert find_max_val(15, 10, 5) == 15', 'assert find_max_val(187, 10, 5) == 185', 'assert find_max_val(16, 11, 1) == 12']
[BEGIN]

Response:
import sys
def find_max_val(n, x, y):
	ans = -sys.maxsize
	for k in range(n + 1):
		if (k % x == y):
			ans = max(ans, k)
	return (ans if (ans >= 0 and
					ans <= n) else -1)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the average of even numbers till a given even number.

 Your code should pass these tests:

['assert average_Even(2) == 2', 'assert average_Even(4) == 3', 'assert average_Even(100) == 51']
[BEGIN]

Response:
def average_Even(n) :
    if (n% 2!= 0) :
        return ("Invalid Input")
        return -1
    sm = 0
    count = 0
    while (n>= 2) :
        count = count+1
        sm = sm+n
        n = n-2
    return sm // count
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to shift first element to the end of given list.

 Your code should pass these tests:

['assert move_last([1,2,3,4]) == [2,3,4,1]', 'assert move_last([2,3,4,1,5,0]) == [3,4,1,5,0,2]', 'assert move_last([5,4,3,2,1]) == [4,3,2,1,5]']
[BEGIN]

Response:
def move_last(num_list):
    a = [num_list[0] for i in range(num_list.count(num_list[0]))]
    x = [ i for i in num_list if i != num_list[0]]
    x.extend(a)
    return (x)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count occurrence of a character in a string.

 Your code should pass these tests:

['assert count_char("Python",\'o\')==1', 'assert count_char("little",\'t\')==2', 'assert count_char("assert",\'s\')==2']
[BEGIN]

Response:
def count_char(string,char):
 count = 0
 for i in range(len(string)):
    if(string[i] == char):
        count = count + 1
 return count
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count number of vowels in the string.

 Your code should pass these tests:

["assert Check_Vow('corner','AaEeIiOoUu') == 2", "assert Check_Vow('valid','AaEeIiOoUu') == 2", "assert Check_Vow('true','AaEeIiOoUu') ==2"]
[BEGIN]

Response:
def Check_Vow(string, vowels):
    final = [each for each in string if each in vowels]
    return(len(final))

[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to replace multiple occurence of character by single.

 Your code should pass these tests:

["assert replace('peep','e') == 'pep'", "assert replace('Greek','e') == 'Grek'", "assert replace('Moon','o') == 'Mon'"]
[BEGIN]

Response:
import re
def replace(string, char):
    pattern = char + '{2,}'
    string = re.sub(pattern, char, string)
    return string
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check whether the given ip address is valid or not using regex.

 Your code should pass these tests:

['assert check_IP("192.168.0.1") == \'Valid IP address\'', 'assert check_IP("110.234.52.124") == \'Valid IP address\'', 'assert check_IP("366.1.2.2") == \'Invalid IP address\'']
[BEGIN]

Response:
import re
regex = '''^(25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(
			25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(
			25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)\.(
			25[0-5]|2[0-4][0-9]|[0-1]?[0-9][0-9]?)$'''
def check_IP(Ip):
	if(re.search(regex, Ip)):
		return ("Valid IP address")
	else:
		return ("Invalid IP address")
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether a sequence of numbers has a decreasing trend or not.

 Your code should pass these tests:

['assert decreasing_trend([-4,-3,-2,-1]) == True', 'assert decreasing_trend([1,2,3]) == True', 'assert decreasing_trend([3,2,1]) == False']
[BEGIN]

Response:
def decreasing_trend(nums):
    if (sorted(nums)== nums):
        return True
    else:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to set the right most unset bit.

 Your code should pass these tests:

['assert set_Right_most_Unset_Bit(21) == 23', 'assert set_Right_most_Unset_Bit(11) == 15', 'assert set_Right_most_Unset_Bit(15) == 15']
[BEGIN]

Response:
import math
def get_Pos_Of_Right_most_Set_Bit(n):
    return int(math.log2(n&-n)+1)
def set_Right_most_Unset_Bit(n):
    if (n == 0):
        return 1
    if ((n & (n + 1)) == 0):
        return n
    pos = get_Pos_Of_Right_most_Set_Bit(~n)
    return ((1 << (pos - 1)) | n)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find maximum of three numbers.

 Your code should pass these tests:

['assert max_of_three(10,20,30)==30', 'assert max_of_three(55,47,39)==55', 'assert max_of_three(10,49,30)==49']
[BEGIN]

Response:
def max_of_three(num1,num2,num3):
    if (num1 >= num2) and (num1 >= num3):
       lnum = num1
    elif (num2 >= num1) and (num2 >= num3):
       lnum = num2
    else:
       lnum = num3
    return lnum
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to convert a list of multiple integers into a single integer.

 Your code should pass these tests:

['assert convert([1,2,3]) == 123', 'assert convert([4,5,6]) == 456', 'assert convert([7,8,9]) == 789']
[BEGIN]

Response:
def convert(list):
    s = [str(i) for i in list]
    res = int("".join(s))
    return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove duplicate words from a given string using collections module.

 Your code should pass these tests:

['assert remove_duplicate("Python Exercises Practice Solution Exercises")==("Python Exercises Practice Solution")', 'assert remove_duplicate("Python Exercises Practice Solution Python")==("Python Exercises Practice Solution")', 'assert remove_duplicate("Python Exercises Practice Solution Practice")==("Python Exercises Practice Solution")']
[BEGIN]

Response:
from collections import OrderedDict
def remove_duplicate(string):
  result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())
  return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to add two integers. however, if the sum is between the given range it will return 20.

 Your code should pass these tests:

['assert sum_nums(2,10,11,20)==20', 'assert sum_nums(15,17,1,10)==32', 'assert sum_nums(10,15,5,30)==20']
[BEGIN]

Response:
def sum_nums(x, y,m,n):
    sum_nums= x + y
    if sum_nums in range(m, n):
        return 20
    else:
        return sum_nums
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove everything except alphanumeric characters from the given string by using regex.

 Your code should pass these tests:

["assert remove_extra_char('**//Google Android// - 12. ') == 'GoogleAndroid12'", "assert remove_extra_char('****//Google Flutter//*** - 36. ') == 'GoogleFlutter36'", "assert remove_extra_char('**//Google Firebase// - 478. ') == 'GoogleFirebase478'"]
[BEGIN]

Response:
import re
def remove_extra_char(text1):
  pattern = re.compile('[\W_]+')
  return (pattern.sub('', text1))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the triangle is valid or not.

 Your code should pass these tests:

['assert validity_triangle(60,50,90)==False', 'assert validity_triangle(45,75,60)==True', 'assert validity_triangle(30,50,100)==True']
[BEGIN]

Response:
def validity_triangle(a,b,c):
 total = a + b + c
 if total == 180:
    return True
 else:
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to remove spaces from a given string.

 Your code should pass these tests:

['assert remove_spaces("a b c") == "abc"', 'assert remove_spaces("1 2 3") == "123"', 'assert remove_spaces(" b c") == "bc"']
[BEGIN]

Response:
def remove_spaces(str1):
  str1 = str1.replace(' ','')
  return str1
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to access dictionary key’s element by index.

 Your code should pass these tests:

["assert access_key({'physics': 80, 'math': 90, 'chemistry': 86},0)== 'physics'", "assert access_key({'python':10, 'java': 20, 'C++':30},2)== 'C++'", "assert access_key({'program':15,'computer':45},1)== 'computer'"]
[BEGIN]

Response:
def access_key(ditionary,key):
  return list(ditionary)[key]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether a sequence of numbers has an increasing trend or not.

 Your code should pass these tests:

['assert increasing_trend([1,2,3,4]) == True', 'assert increasing_trend([4,3,2,1]) == False', 'assert increasing_trend([0,1,4,9]) == True']
[BEGIN]

Response:
def increasing_trend(nums):
    if (sorted(nums)== nums):
        return True
    else:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the smallest prime divisor of a number.

 Your code should pass these tests:

['assert smallest_Divisor(10) == 2', 'assert smallest_Divisor(25) == 5', 'assert smallest_Divisor(31) == 31']
[BEGIN]

Response:
def smallest_Divisor(n):
    if (n % 2 == 0):
        return 2;
    i = 3;
    while (i*i <= n):
        if (n % i == 0):
            return i;
        i += 2;
    return n;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to multiply two lists using map and lambda function.

 Your code should pass these tests:

['assert mul_list([1, 2, 3],[4,5,6])==[4,10,18]', 'assert mul_list([1,2],[3,4])==[3,8]', 'assert mul_list([90,120],[50,70])==[4500,8400]']
[BEGIN]

Response:
def mul_list(nums1,nums2):
  result = map(lambda x, y: x * y, nums1, nums2)
  return list(result)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the given number can be represented by sum of two squares or not.

 Your code should pass these tests:

['assert sum_Square(25) == True', 'assert sum_Square(24) == False', 'assert sum_Square(17) == True']
[BEGIN]

Response:
def sum_Square(n) :
    i = 1
    while i*i <= n :
        j = 1
        while (j*j <= n) :
            if (i*i+j*j == n) :
                return True
            j = j+1
        i = i+1
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count occurences of a character in a repeated string.

 Your code should pass these tests:

['assert count_Char("abcac",\'a\') == 4', 'assert count_Char("abca",\'c\') == 2', 'assert count_Char("aba",\'a\') == 7']
[BEGIN]

Response:
def count_Char(str,x):
    count = 0
    for i in range(len(str)):
        if (str[i] == x) :
            count += 1
    n = 10
    repititions = n // len(str)
    count = count * repititions
    l = n % len(str)
    for i in range(l):
        if (str[i] == x):
            count += 1
    return count
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find sum of prime numbers between 1 to n.

 Your code should pass these tests:

['assert sum_Of_Primes(10) == 17', 'assert sum_Of_Primes(20) == 77', 'assert sum_Of_Primes(5) == 10']
[BEGIN]

Response:
def sum_Of_Primes(n):
    prime = [True] * (n + 1)
    p = 2
    while p * p <= n:
        if prime[p] == True:
            i = p * 2
            while i <= n:
                prime[i] = False
                i += p
        p += 1
    sum = 0
    for i in range (2,n + 1):
        if(prime[i]):
            sum += i
    return sum
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the frequency of each element in the given list.

 Your code should pass these tests:

["assert freq_element((4, 5, 4, 5, 6, 6, 5, 5, 4) ) == '{4: 3, 5: 4, 6: 2}'", "assert freq_element((7, 8, 8, 9, 4, 7, 6, 5, 4) ) == '{7: 2, 8: 2, 9: 1, 4: 2, 6: 1, 5: 1}'", "assert freq_element((1, 4, 3, 1, 4, 5, 2, 6, 2, 7) ) == '{1: 2, 4: 2, 3: 1, 5: 1, 2: 2, 6: 1, 7: 1}'"]
[BEGIN]

Response:
from collections import defaultdict
def freq_element(test_tup):
  res = defaultdict(int)
  for ele in test_tup:
    res[ele] += 1
  return (str(dict(res)))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the greatest common divisor (gcd) of two integers by using recursion.

 Your code should pass these tests:

['assert recur_gcd(12,14) == 2', 'assert recur_gcd(13,17) == 1', 'assert recur_gcd(9, 3) == 3']
[BEGIN]

Response:
def recur_gcd(a, b):
	low = min(a, b)
	high = max(a, b)
	if low == 0:
		return high
	elif low == 1:
		return 1
	else:
		return recur_gcd(low, high%low)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to get the length of a complex number.

 Your code should pass these tests:

['assert len_complex(3,4)==5.0', 'assert len_complex(9,10)==13.45362404707371', 'assert len_complex(7,9)==11.40175425099138']
[BEGIN]

Response:
import cmath
def len_complex(a,b):
  cn=complex(a,b)
  length=abs(cn)
  return length
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block

 Your code should pass these tests:

['assert min_jumps([1, 3, 6, 1, 0, 9], 6) == 3', 'assert min_jumps([1, 3, 5, 8, 9, 2, 6, 7, 6, 8, 9], 11) == 3', 'assert min_jumps([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1], 11) == 10']
[BEGIN]

Response:
def min_jumps(arr, n):
	jumps = [0 for i in range(n)]
	if (n == 0) or (arr[0] == 0):
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if (i <= j + arr[j]) and (jumps[j] != float('inf')):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n-1]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to multiply consecutive numbers of a given list.

 Your code should pass these tests:

['assert mul_consecutive_nums([1, 1, 3, 4, 4, 5, 6, 7])==[1, 3, 12, 16, 20, 30, 42]', 'assert mul_consecutive_nums([4, 5, 8, 9, 6, 10])==[20, 40, 72, 54, 60]', 'assert mul_consecutive_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[2, 6, 12, 20, 30, 42, 56, 72, 90]']
[BEGIN]

Response:
def mul_consecutive_nums(nums):
    result = [b*a for a, b in zip(nums[:-1], nums[1:])]
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to group the 1st elements on the basis of 2nd elements in the given tuple list.

 Your code should pass these tests:

['assert group_element([(6, 5), (2, 7), (2, 5), (8, 7), (9, 8), (3, 7)]) == {5: [6, 2], 7: [2, 8, 3], 8: [9]}', 'assert group_element([(7, 6), (3, 8), (3, 6), (9, 8), (10, 9), (4, 8)]) == {6: [7, 3], 8: [3, 9, 4], 9: [10]}', 'assert group_element([(8, 7), (4, 9), (4, 7), (10, 9), (11, 10), (5, 9)]) == {7: [8, 4], 9: [4, 10, 5], 10: [11]}']
[BEGIN]

Response:
from itertools import groupby
def group_element(test_list):
  res = dict()
  for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):
    res[key] = [ele[0] for ele in val]
  return (res)

[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the last two digits in factorial of a given number.

 Your code should pass these tests:

['assert last_Two_Digits(7) == 40', 'assert last_Two_Digits(5) == 20', 'assert last_Two_Digits(2) == 2']
[BEGIN]

Response:
def last_Two_Digits(N):
    if (N >= 10):
        return
    fac = 1
    for i in range(1,N + 1):
        fac = (fac * i) % 100
    return (fac)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove multiple spaces in a string by using regex.

 Your code should pass these tests:

["assert remove_multiple_spaces('Google      Assistant') == 'Google Assistant'", "assert remove_multiple_spaces('Quad      Core') == 'Quad Core'", "assert remove_multiple_spaces('ChromeCast      Built-in') == 'ChromeCast Built-in'"]
[BEGIN]

Response:
import re
def remove_multiple_spaces(text1):
  return (re.sub(' +',' ',text1))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to extract unique values from the given dictionary values.

 Your code should pass these tests:

["assert extract_unique({'msm' : [5, 6, 7, 8],'is' : [10, 11, 7, 5],'best' : [6, 12, 10, 8],'for' : [1, 2, 5]} ) == [1, 2, 5, 6, 7, 8, 10, 11, 12]", "assert extract_unique({'Built' : [7, 1, 9, 4],'for' : [11, 21, 36, 14, 9],'ISP' : [4, 1, 21, 39, 47],'TV' : [1, 32, 38]} ) == [1, 4, 7, 9, 11, 14, 21, 32, 36, 38, 39, 47]", "assert extract_unique({'F' : [11, 13, 14, 17],'A' : [12, 11, 15, 18],'N' : [19, 21, 15, 36],'G' : [37, 36, 35]}) == [11, 12, 13, 14, 15, 17, 18, 19, 21, 35, 36, 37]"]
[BEGIN]

Response:
def extract_unique(test_dict):
  res = list(sorted({ele for val in test_dict.values() for ele in val}))
  return res
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if each element of the second tuple is greater than its corresponding index in the first tuple.

 Your code should pass these tests:

['assert check_greater((10, 4, 5), (13, 5, 18)) == True', 'assert check_greater((1, 2, 3), (2, 1, 4)) == False', 'assert check_greater((4, 5, 6), (5, 6, 7)) == True']
[BEGIN]

Response:
def check_greater(test_tup1, test_tup2):
  res = all(x < y for x, y in zip(test_tup1, test_tup2))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to zip two given lists of lists.

 Your code should pass these tests:

['assert zip_list([[1, 3], [5, 7], [9, 11]] ,[[2, 4], [6, 8], [10, 12, 14]] )==[[1, 3, 2, 4], [5, 7, 6, 8], [9, 11, 10, 12, 14]]', 'assert zip_list([[1, 2], [3, 4], [5, 6]] ,[[7, 8], [9, 10], [11, 12]] )==[[1, 2, 7, 8], [3, 4, 9, 10], [5, 6, 11, 12]]', "assert zip_list([['a','b'],['c','d']] , [['e','f'],['g','h']] )==[['a','b','e','f'],['c','d','g','h']]"]
[BEGIN]

Response:
def zip_list(list1,list2):
 result = list(map(list.__add__, list1, list2))
 return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find number of even elements in the given list using lambda function.

 Your code should pass these tests:

['assert count_even([1, 2, 3, 5, 7, 8, 9, 10])==3', 'assert count_even([10,15,14,13,-18,12,-20])==5', 'assert count_even([1, 2, 4, 8, 9])==3']
[BEGIN]

Response:
def count_even(array_nums):
   count_even = len(list(filter(lambda x: (x%2 == 0) , array_nums)))
   return count_even
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort dictionary items by tuple product of keys for the given dictionary with tuple keys.

 Your code should pass these tests:

['assert sort_dict_item({(5, 6) : 3, (2, 3) : 9, (8, 4): 10, (6, 4): 12} ) == {(2, 3): 9, (6, 4): 12, (5, 6): 3, (8, 4): 10}', 'assert sort_dict_item({(6, 7) : 4, (3, 4) : 10, (9, 5): 11, (7, 5): 13} ) == {(3, 4): 10, (7, 5): 13, (6, 7): 4, (9, 5): 11}', 'assert sort_dict_item({(7, 8) : 5, (4, 5) : 11, (10, 6): 12, (8, 6): 14} ) == {(4, 5): 11, (8, 6): 14, (7, 8): 5, (10, 6): 12}']
[BEGIN]

Response:
def sort_dict_item(test_dict):
  res = {key: test_dict[key] for key in sorted(test_dict.keys(), key = lambda ele: ele[1] * ele[0])}
  return  (res)

[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the minimum number of swaps required to convert one binary string to another.

 Your code should pass these tests:

['assert min_Swaps("1101","1110") == 1', 'assert min_Swaps("1111","0100") == "Not Possible"', 'assert min_Swaps("1110000","0001101") == 3']
[BEGIN]

Response:
def min_Swaps(str1,str2) :
    count = 0
    for i in range(len(str1)) :
        if str1[i] != str2[i] :
            count += 1
    if count % 2 == 0 :
        return (count // 2)
    else :
        return ("Not Possible")
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count the number of elements in a list which are within a specific range.

 Your code should pass these tests:

['assert count_range_in_list([10,20,30,40,40,40,70,80,99],40,100)==6', "assert count_range_in_list(['a','b','c','d','e','f'],'a','e')==5", 'assert count_range_in_list([7,8,9,15,17,19,45],15,20)==3']
[BEGIN]

Response:
def count_range_in_list(li, min, max):
	ctr = 0
	for x in li:
		if min <= x <= max:
			ctr += 1
	return ctr
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the equilibrium index of the given array.

 Your code should pass these tests:

['assert equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3', 'assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3', 'assert equilibrium_index([1, 2, 3]) == -1']
[BEGIN]

Response:
def equilibrium_index(arr):
  total_sum = sum(arr)
  left_sum=0
  for i, num in enumerate(arr):
    total_sum -= num
    if left_sum == total_sum:
      return i
    left_sum += num
  return -1
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.

 Your code should pass these tests:

['assert removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5', 'assert removals([1, 5, 6, 2, 8], 5, 2) == 3', 'assert removals([1, 2, 3 ,4, 5, 6], 6, 3) == 2']
[BEGIN]

Response:
def find_ind(key, i, n,
			k, arr):
	ind = -1
	start = i + 1
	end = n - 1;
	while (start < end):
		mid = int(start +
				(end - start) / 2)
		if (arr[mid] - key <= k):
			ind = mid
			start = mid + 1
		else:
			end = mid
	return ind
def removals(arr, n, k):
	ans = n - 1
	arr.sort()
	for i in range(0, n):
		j = find_ind(arr[i], i,
					n, k, arr)
		if (j != -1):
			ans = min(ans, n -
						(j - i + 1))
	return ans
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check whether the given key is present in the dictionary or not.

 Your code should pass these tests:

['assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True', 'assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},6)==True', 'assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},10)==False']
[BEGIN]

Response:
def is_key_present(d,x):
  if x in d:
    return True
  else:
     return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate the harmonic sum of n-1.

 Your code should pass these tests:

['assert harmonic_sum(10)==2.9289682539682538', 'assert harmonic_sum(4)==2.083333333333333', 'assert harmonic_sum(7)==2.5928571428571425 ']
[BEGIN]

Response:
def harmonic_sum(n):
  if n < 2:
    return 1
  else:
    return 1 / n + (harmonic_sum(n - 1))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort a list of lists by length and value.

 Your code should pass these tests:

['assert sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])==[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]]', 'assert sort_sublists([[1], [2, 3], [4, 5, 6], [7], [10, 11]])==[[1], [7], [2, 3], [10, 11], [4, 5, 6]]', 'assert sort_sublists([["python"],["java","C","C++"],["DBMS"],["SQL","HTML"]])==[[\'DBMS\'], [\'python\'], [\'SQL\', \'HTML\'], [\'java\', \'C\', \'C++\']]']
[BEGIN]

Response:
def sort_sublists(list1):
      list1.sort()
      list1.sort(key=len)
      return  list1
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find whether an array is subset of another array.

 Your code should pass these tests:

['assert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True', 'assert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True', 'assert is_subset([10, 5, 2, 23, 19], 5, [19, 5, 3], 3) == False']
[BEGIN]

Response:
def is_subset(arr1, m, arr2, n):
	hashset = set()
	for i in range(0, m):
		hashset.add(arr1[i])
	for i in range(0, n):
		if arr2[i] in hashset:
			continue
		else:
			return False
	return True
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count the total set bits from 1 to n.

 Your code should pass these tests:

['assert count_Set_Bits(16) == 33', 'assert count_Set_Bits(2) == 2', 'assert count_Set_Bits(14) == 28']
[BEGIN]

Response:
def count_Set_Bits(n) :
    n += 1;
    powerOf2 = 2;
    cnt = n // 2;
    while (powerOf2 <= n) :
        totalPairs = n // powerOf2;
        cnt += (totalPairs // 2) * powerOf2;
        if (totalPairs & 1) :
            cnt += (n % powerOf2)
        else :
            cnt += 0
        powerOf2 <<= 1;
    return cnt;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to convert a string to a list.

 Your code should pass these tests:

["assert Convert('python program') == ['python','program']", "assert Convert('Data Analysis') ==['Data','Analysis']", "assert Convert('Hadoop Training') == ['Hadoop','Training']"]
[BEGIN]

Response:
def Convert(string):
    li = list(string.split(" "))
    return li
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count unique keys for each value present in the tuple.

 Your code should pass these tests:

["assert get_unique([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)] ) == '{4: 4, 2: 3, 1: 2}'", "assert get_unique([(4, 5), (2, 3), (3, 5), (9, 3), (8, 3), (9, 2), (10, 2), (9, 5), (11, 5)] ) == '{5: 4, 3: 3, 2: 2}'", "assert get_unique([(6, 5), (3, 4), (2, 6), (11, 1), (8, 22), (8, 11), (4, 3), (14, 3), (11, 6)] ) == '{5: 1, 4: 1, 6: 2, 1: 1, 22: 1, 11: 1, 3: 2}'"]
[BEGIN]

Response:
from collections import defaultdict
def get_unique(test_list):
  res = defaultdict(list)
  for sub in test_list:
    res[sub[1]].append(sub[0])
  res = dict(res)
  res_dict = dict()
  for key in res:
    res_dict[key] = len(list(set(res[key])))
  return (str(res_dict))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to access the initial and last data of the given tuple record.

 Your code should pass these tests:

['assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7)', 'assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5)', 'assert front_and_rear((6, 7, 8, 9, 10)) == (6, 10)']
[BEGIN]

Response:
def front_and_rear(test_tup):
  res = (test_tup[0], test_tup[-1])
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the product of digits of a number at even and odd places is equal or not.

 Your code should pass these tests:

['assert product_Equal(2841) == True', 'assert product_Equal(1234) == False', 'assert product_Equal(1212) == False']
[BEGIN]

Response:
def product_Equal(n):
    if n < 10:
        return False
    prodOdd = 1; prodEven = 1
    while n > 0:
        digit = n % 10
        prodOdd *= digit
        n = n//10
        if n == 0:
            break;
        digit = n % 10
        prodEven *= digit
        n = n//10
    if prodOdd == prodEven:
        return True
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove duplicates from a list of lists.

 Your code should pass these tests:

['assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] ', 'assert remove_duplicate(["a", "b", "a", "c", "c"] )==["a", "b", "c"]', 'assert remove_duplicate([1, 3, 5, 6, 3, 5, 6, 1] )==[1, 3, 5, 6]']
[BEGIN]

Response:
import itertools
def remove_duplicate(list1):
 list.sort(list1)
 remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1))
 return remove_duplicate
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the given tuple contains all valid values or not.

 Your code should pass these tests:

['assert check_valid((True, True, True, True) ) == True', 'assert check_valid((True, False, True, True) ) == False', 'assert check_valid((True, True, True, True) ) == True']
[BEGIN]

Response:
def check_valid(test_tup):
  res = not any(map(lambda ele: not ele, test_tup))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count the number of distinct power of prime factor of given number.

 Your code should pass these tests:

['assert count_Fac(24) == 3', 'assert count_Fac(12) == 2', 'assert count_Fac(4) == 1']
[BEGIN]

Response:
def count_Fac(n):
    m = n
    count = 0
    i = 2
    while((i * i) <= m):
        total = 0
        while (n % i == 0):
            n /= i
            total += 1
        temp = 0
        j = 1
        while((temp + j) <= total):
            temp += j
            count += 1
            j += 1
        i += 1
    if (n != 1):
        count += 1
    return count
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to convert the given string of integers into a tuple.

 Your code should pass these tests:

['assert str_to_tuple("1, -5, 4, 6, 7") == (1, -5, 4, 6, 7)', 'assert str_to_tuple("1, 2, 3, 4, 5") == (1, 2, 3, 4, 5)', 'assert str_to_tuple("4, 6, 9, 11, 13, 14") == (4, 6, 9, 11, 13, 14)']
[BEGIN]

Response:
def str_to_tuple(test_str):
  res = tuple(map(int, test_str.split(', ')))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the perimeter of a rombus.

 Your code should pass these tests:

['assert rombus_perimeter(10)==40', 'assert rombus_perimeter(5)==20', 'assert rombus_perimeter(4)==16']
[BEGIN]

Response:
def rombus_perimeter(a):
  perimeter=4*a
  return perimeter
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate the standard deviation.

 Your code should pass these tests:

['assert sd_calc([4, 2, 5, 8, 6])== 2.23606797749979', 'assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287', 'assert sd_calc([5,9,10,15,6,4])==4.070217029430577']
[BEGIN]

Response:
import math
import sys
def sd_calc(data):
    n = len(data)
    if n <= 1:
        return 0.0
    mean, sd = avg_calc(data), 0.0
    for el in data:
        sd += (float(el) - mean)**2
    sd = math.sqrt(sd / float(n-1))
    return sd
def avg_calc(ls):
    n, mean = len(ls), 0.0
    if n <= 1:
        return ls[0]
    for el in ls:
        mean = mean + float(el)
    mean = mean / float(n)
    return mean
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to create a list taking alternate elements from another given list.

 Your code should pass these tests:

['assert alternate_elements(["red", "black", "white", "green", "orange"])==[\'red\', \'white\', \'orange\']', 'assert alternate_elements([2, 0, 3, 4, 0, 2, 8, 3, 4, 2])==[2, 3, 0, 8, 4]', 'assert alternate_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])==[1,3,5,7,9]']
[BEGIN]

Response:
def alternate_elements(list1):
    result=[]
    for item in list1[::2]:
        result.append(item)
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function that matches a string that has an a followed by zero or more b's.

 Your code should pass these tests:

['assert text_match("ac")==(\'Found a match!\')', 'assert text_match("dc")==(\'Not matched!\')', 'assert text_match("abba")==(\'Found a match!\')']
[BEGIN]

Response:
import re
def text_match(text):
        patterns = 'ab*?'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return('Not matched!')
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to add a dictionary to the tuple.

 Your code should pass these tests:

['assert add_dict_to_tuple((4, 5, 6), {"MSAM" : 1, "is" : 2, "best" : 3} ) == (4, 5, 6, {\'MSAM\': 1, \'is\': 2, \'best\': 3})', 'assert add_dict_to_tuple((1, 2, 3), {"UTS" : 2, "is" : 3, "Worst" : 4} ) == (1, 2, 3, {\'UTS\': 2, \'is\': 3, \'Worst\': 4})', 'assert add_dict_to_tuple((8, 9, 10), {"POS" : 3, "is" : 4, "Okay" : 5} ) == (8, 9, 10, {\'POS\': 3, \'is\': 4, \'Okay\': 5})']
[BEGIN]

Response:
def add_dict_to_tuple(test_tup, test_dict):
  test_tup = list(test_tup)
  test_tup.append(test_dict)
  test_tup = tuple(test_tup)
  return (test_tup)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.

 Your code should pass these tests:

['assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3) == 5.2', 'assert maxAverageOfPath([[2, 3, 4], [7, 6, 5], [8, 4, 10]], 3) == 6.2', 'assert maxAverageOfPath([[3, 4, 5], [8, 7, 6], [9, 5, 11]], 3) == 7.2 ']
[BEGIN]

Response:
M = 100
def maxAverageOfPath(cost, N):
	dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
	dp[0][0] = cost[0][0]
	for i in range(1, N):
		dp[i][0] = dp[i - 1][0] + cost[i][0]
	for j in range(1, N):
		dp[0][j] = dp[0][j - 1] + cost[0][j]
	for i in range(1, N):
		for j in range(1, N):
			dp[i][j] = max(dp[i - 1][j],
						dp[i][j - 1]) + cost[i][j]
	return dp[N - 1][N - 1] / (2 * N - 1)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to filter the height and width of students which are stored in a dictionary.

 Your code should pass these tests:

["assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6.0,70)=={'Cierra Vega': (6.2, 70)}", "assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.9,67)=={'Cierra Vega': (6.2, 70),'Kierra Gentry': (6.0, 68)}", "assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},5.7,64)=={'Cierra Vega': (6.2, 70),'Alden Cantrell': (5.9, 65),'Kierra Gentry': (6.0, 68),'Pierre Cox': (5.8, 66)}"]
[BEGIN]

Response:
def filter_data(students,h,w):
    result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count the same pair in two given lists using map function.

 Your code should pass these tests:

['assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4', 'assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==11', 'assert count_same_pair([2, 4, -6, -9, 11, -12, 14, -5, 17],[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8])==1']
[BEGIN]

Response:
from operator import eq
def count_same_pair(nums1, nums2):
    result = sum(map(eq, nums1, nums2))
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate the sum of all digits of the base to the specified power.

 Your code should pass these tests:

['assert power_base_sum(2,100)==115', 'assert power_base_sum(8,10)==37', 'assert power_base_sum(8,15)==62']
[BEGIN]

Response:
def power_base_sum(base, power):
    return sum([int(i) for i in str(pow(base, power))])
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to extract values between quotation marks of the given string by using regex.

 Your code should pass these tests:

['assert extract_quotation(\'Cortex "A53" Based "multi" tasking "Processor"\') == [\'A53\', \'multi\', \'Processor\']', 'assert extract_quotation(\'Cast your "favorite" entertainment "apps"\') == [\'favorite\', \'apps\']', 'assert extract_quotation(\'Watch content "4k Ultra HD" resolution with "HDR 10" Support\') == [\'4k Ultra HD\', \'HDR 10\']']
[BEGIN]

Response:
import re
def extract_quotation(text1):
  return (re.findall(r'"(.*?)"', text1))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to multiply the adjacent elements of the given tuple.

 Your code should pass these tests:

['assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80)', 'assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42)', 'assert multiply_elements((12, 13, 14, 9, 15)) == (156, 182, 126, 135)']
[BEGIN]

Response:
def multiply_elements(test_tup):
  res = tuple(i * j for i, j in zip(test_tup, test_tup[1:]))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove all characters except letters and numbers using regex

 Your code should pass these tests:

['assert remove_char("123abcjw:, .@! eiw") == \'123abcjweiw\'', 'assert remove_char("Hello1234:, ! Howare33u") == \'Hello1234Howare33u\'', 'assert remove_char("Cool543Triks@:, Make@987Trips") == \'Cool543TriksMake987Trips\' ']
[BEGIN]

Response:
import re
def remove_char(S):
  result = re.sub('[\W_]+', '', S)
  return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sum elements in two lists.

 Your code should pass these tests:

['assert sum_list([10,20,30],[15,25,35])==[25,45,65]', 'assert sum_list([1,2,3],[5,6,7])==[6,8,10]', 'assert sum_list([15,20,30],[15,45,75])==[30,65,105]']
[BEGIN]

Response:
def sum_list(lst1,lst2):
  res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
  return res_list
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to add two lists using map and lambda function.

 Your code should pass these tests:

['assert add_list([1, 2, 3],[4,5,6])==[5, 7, 9]', 'assert add_list([1,2],[3,4])==[4,6]', 'assert add_list([10,20],[50,70])==[60,90]']
[BEGIN]

Response:
def add_list(nums1,nums2):
  result = map(lambda x, y: x + y, nums1, nums2)
  return list(result)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove consecutive duplicates of a given list.

 Your code should pass these tests:

['assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4]', 'assert consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[10, 15, 19, 18, 17, 26, 17, 18, 10]', "assert consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==['a', 'b', 'c', 'd']"]
[BEGIN]

Response:
from itertools import groupby
def consecutive_duplicates(nums):
    return [key for key, group in groupby(nums)]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the lateral surface area of a cone.

 Your code should pass these tests:

['assert lateralsurface_cone(5,12)==204.20352248333654', 'assert lateralsurface_cone(10,15)==566.3586699569488', 'assert lateralsurface_cone(19,17)==1521.8090132193388']
[BEGIN]

Response:
import math
def lateralsurface_cone(r,h):
  l = math.sqrt(r * r + h * h)
  LSA = math.pi * r  * l
  return LSA
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to replace all occurrences of spaces, commas, or dots with a colon.

 Your code should pass these tests:

["assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:')", "assert replace_specialchar('a b c,d e f')==('a:b:c:d:e:f')", "assert replace_specialchar('ram reshma,ram rahim')==('ram:reshma:ram:rahim')"]
[BEGIN]

Response:
import re
def replace_specialchar(text):
 return (re.sub("[ ,.]", ":", text))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the index of the first occurrence of a given number in a sorted array.

 Your code should pass these tests:

['assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1', 'assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 2', 'assert find_first_occurrence([2, 4, 1, 5, 6, 6, 8, 9, 9, 9], 6) == 4']
[BEGIN]

Response:
def find_first_occurrence(A, x):
    (left, right) = (0, len(A) - 1)
    result = -1
    while left <= right:
        mid = (left + right) // 2
        if x == A[mid]:
            result = mid
            right = mid - 1
        elif x < A[mid]:
            right = mid - 1
        else:
            left = mid + 1
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find sum of products of all possible subarrays.

 Your code should pass these tests:

['assert sum_Of_Subarray_Prod([1,2,3],3) == 20', 'assert sum_Of_Subarray_Prod([1,2],2) == 5', 'assert sum_Of_Subarray_Prod([1,2,3,4],4) == 84']
[BEGIN]

Response:
def sum_Of_Subarray_Prod(arr,n):
    ans = 0
    res = 0
    i = n - 1
    while (i >= 0):
        incr = arr[i]*(1 + res)
        ans += incr
        res = incr
        i -= 1
    return (ans)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to toggle bits of the number except the first and the last bit.

 Your code should pass these tests:

['assert toggle_middle_bits(9) == 15', 'assert toggle_middle_bits(10) == 12', 'assert toggle_middle_bits(11) == 13']
[BEGIN]

Response:
def set_middle_bits(n):
    n |= n >> 1;
    n |= n >> 2;
    n |= n >> 4;
    n |= n >> 8;
    n |= n >> 16;
    return (n >> 1) ^ 1
def toggle_middle_bits(n):
    if (n == 1):
        return 1
    return n ^ set_middle_bits(n)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to locate the left insertion point for a specified value in sorted order.

 Your code should pass these tests:

['assert left_insertion([1,2,4,5],6)==4', 'assert left_insertion([1,2,4,5],3)==2', 'assert left_insertion([1,2,4,5],7)==4']
[BEGIN]

Response:
import bisect
def left_insertion(a, x):
    i = bisect.bisect_left(a, x)
    return i
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check whether the given string is starting with a vowel or not using regex.

 Your code should pass these tests:

['assert check_str("annie") == \'Valid\'', 'assert check_str("dawood") == \'Invalid\'', 'assert check_str("Else") == \'Valid\'']
[BEGIN]

Response:
import re
regex = '^[aeiouAEIOU][A-Za-z0-9_]*'
def check_str(string):
	if(re.search(regex, string)):
		return ("Valid")
	else:
		return ("Invalid")
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate the geometric sum of n-1.

 Your code should pass these tests:

['assert geometric_sum(7) == 1.9921875', 'assert geometric_sum(4) == 1.9375', 'assert geometric_sum(8) == 1.99609375']
[BEGIN]

Response:
def geometric_sum(n):
  if n < 0:
    return 0
  else:
    return 1 / (pow(2, n)) + geometric_sum(n - 1)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the index of smallest triangular number with n digits.

 Your code should pass these tests:

['assert find_Index(2) == 4', 'assert find_Index(3) == 14', 'assert find_Index(4) == 45']
[BEGIN]

Response:
import math
def find_Index(n):
    x = math.sqrt(2 * math.pow(10,(n - 1)));
    return round(x);
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to convert the given tuple to a key-value dictionary using adjacent elements.

 Your code should pass these tests:

['assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5}', 'assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}', 'assert tuple_to_dict((7, 8, 9, 10, 11, 12)) == {7: 8, 9: 10, 11: 12}']
[BEGIN]

Response:
def tuple_to_dict(test_tup):
  res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether all the characters are same or not.

 Your code should pass these tests:

['assert all_Characters_Same("python") == False', 'assert all_Characters_Same("aaa") == True', 'assert all_Characters_Same("data") == False']
[BEGIN]

Response:
def all_Characters_Same(s) :
    n = len(s)
    for i in range(1,n) :
        if s[i] != s[0] :
            return False
    return True
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to caluclate the area of a tetrahedron.

 Your code should pass these tests:

['assert area_tetrahedron(3)==15.588457268119894', 'assert area_tetrahedron(20)==692.8203230275509', 'assert area_tetrahedron(10)==173.20508075688772']
[BEGIN]

Response:
import math
def area_tetrahedron(side):
  area = math.sqrt(3)*(side*side)
  return area
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to rotate a given list by specified number of items to the right direction.

 Your code should pass these tests:

['assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[8, 9, 10, 1, 2, 3, 4, 5, 6]', 'assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2,2)==[9, 10, 1, 2, 3, 4, 5, 6, 7, 8]', 'assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],5,2)==[6, 7, 8, 9, 10, 1, 2, 3, 4, 5, 6, 7, 8]']
[BEGIN]

Response:
def rotate_right(list1,m,n):
  result =  list1[-(m):]+list1[:-(n)]
  return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the given tuple has any none value or not.

 Your code should pass these tests:

['assert check_none((10, 4, 5, 6, None)) == True', 'assert check_none((7, 8, 9, 11, 14)) == False', 'assert check_none((1, 2, 3, 4, None)) == True']
[BEGIN]

Response:
def check_none(test_tup):
  res = any(map(lambda ele: ele is None, test_tup))
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find numbers within a given range where every number is divisible by every digit it contains.

 Your code should pass these tests:

['assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22]', 'assert divisible_by_digits(1,15)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15]', 'assert divisible_by_digits(20,25)==[22, 24]']
[BEGIN]

Response:
def divisible_by_digits(startnum, endnum):
    return [n for n in range(startnum, endnum+1) \
                if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find area of a sector.

 Your code should pass these tests:

['assert sector_area(4,45)==6.285714285714286', 'assert sector_area(9,45)==31.82142857142857', 'assert sector_area(9,360)==None']
[BEGIN]

Response:
def sector_area(r,a):
    pi=22/7
    if a >= 360:
        return None
    sectorarea = (pi*r**2) * (a/360)
    return sectorarea
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the longest common subsequence for the given three string sequence.

 Your code should pass these tests:

["assert lcs_of_three('AGGT12', '12TXAYB', '12XBA', 6, 7, 5) == 2", "assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13) == 5 ", "assert lcs_of_three('abcd1e2', 'bc12ea', 'bd1ea', 7, 6, 5) == 3"]
[BEGIN]

Response:
def lcs_of_three(X, Y, Z, m, n, o):
	L = [[[0 for i in range(o+1)] for j in range(n+1)]
		for k in range(m+1)]
	for i in range(m+1):
		for j in range(n+1):
			for k in range(o+1):
				if (i == 0 or j == 0 or k == 0):
					L[i][j][k] = 0
				elif (X[i-1] == Y[j-1] and
					X[i-1] == Z[k-1]):
					L[i][j][k] = L[i-1][j-1][k-1] + 1
				else:
					L[i][j][k] = max(max(L[i-1][j][k],
					L[i][j-1][k]),
									L[i][j][k-1])
	return L[m][n][o]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to put spaces between words starting with capital letters in a given string by using regex.

 Your code should pass these tests:

['assert capital_words_spaces("Python") == \'Python\'', 'assert capital_words_spaces("PythonProgrammingExamples") == \'Python Programming Examples\'', 'assert capital_words_spaces("GetReadyToBeCodingFreak") == \'Get Ready To Be Coding Freak\'']
[BEGIN]

Response:
import re
def capital_words_spaces(str1):
  return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort a given list of strings of numbers numerically.

 Your code should pass these tests:

["assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200]", "assert sort_numeric_strings(['2','3','8','4','7','9','8','2','6','5','1','6','1','2','3','4','6','9','1','2'])==[1, 1, 1, 2, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 6, 7, 8, 8, 9, 9]", "assert sort_numeric_strings(['1','3','5','7','1', '3','13', '15', '17','5', '7 ','9','1', '11'])==[1, 1, 1, 3, 3, 5, 5, 7, 7, 9, 11, 13, 15, 17]"]
[BEGIN]

Response:
def sort_numeric_strings(nums_str):
    result = [int(x) for x in nums_str]
    result.sort()
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to add the given tuple to the given list.

 Your code should pass these tests:

['assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10]', 'assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11]', 'assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9, 11, 12]']
[BEGIN]

Response:
def add_tuple(test_list, test_tup):
  test_list += test_tup
  return (test_list)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the given array represents min heap or not.

 Your code should pass these tests:

['assert check_min_heap([1, 2, 3, 4, 5, 6], 0) == True', 'assert check_min_heap([2, 3, 4, 5, 10, 15], 0) == True', 'assert check_min_heap([2, 10, 4, 5, 3, 15], 0) == False']
[BEGIN]

Response:
def check_min_heap(arr, i):
    if 2 * i + 2 > len(arr):
        return True
    left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)
    right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2]
                                      and check_min_heap(arr, 2 * i + 2))
    return left_child and right_child
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the nth jacobsthal number.

 Your code should pass these tests:

['assert jacobsthal_num(5) == 11', 'assert jacobsthal_num(2) == 1', 'assert jacobsthal_num(4) == 5']
[BEGIN]

Response:
def jacobsthal_num(n):
	dp = [0] * (n + 1)
	dp[0] = 0
	dp[1] = 1
	for i in range(2, n+1):
		dp[i] = dp[i - 1] + 2 * dp[i - 2]
	return dp[n]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find minimum k records from tuple list.

 Your code should pass these tests:

["assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)]", "assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash', 3), ('Nepin', 9)], 3) == [('Akash', 3), ('Angat', 5), ('Nepin', 9)]", "assert min_k([('tanmay', 14), ('Amer', 11), ('Ayesha', 9), ('SKD', 16)], 1) == [('Ayesha', 9)]"]
[BEGIN]

Response:
def min_k(test_list, K):
  res = sorted(test_list, key = lambda x: x[1])[:K]
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find common index elements from three lists.

 Your code should pass these tests:

['assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7]', 'assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 6, 5],[0, 1, 2, 3, 4, 6, 7])==[1, 6]', 'assert extract_index_list([1, 1, 3, 4, 6, 5, 6],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 5]']
[BEGIN]

Response:
def extract_index_list(l1, l2, l3):
    result = []
    for m, n, o in zip(l1, l2, l3):
        if (m == n == o):
            result.append(m)
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the second smallest number in a list.

 Your code should pass these tests:

['assert second_smallest([1, 2, -8, -2, 0, -2])==-2', 'assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5', 'assert second_smallest([2,2])==None']
[BEGIN]

Response:
def second_smallest(numbers):
  if (len(numbers)<2):
    return
  if ((len(numbers)==2)  and (numbers[0] == numbers[1]) ):
    return
  dup_items = set()
  uniq_items = []
  for x in numbers:
    if x not in dup_items:
      uniq_items.append(x)
      dup_items.add(x)
  uniq_items.sort()
  return  uniq_items[1]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function that matches a string that has an a followed by zero or one 'b'.

 Your code should pass these tests:

['assert text_match_zero_one("ac")==(\'Found a match!\')', 'assert text_match_zero_one("dc")==(\'Not matched!\')', 'assert text_match_zero_one("abbbba")==(\'Found a match!\')']
[BEGIN]

Response:
import re
def text_match_zero_one(text):
        patterns = 'ab?'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return('Not matched!')
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count the pairs of reverse strings in the given string list.

 Your code should pass these tests:

['assert count_reverse_pairs(["julia", "best", "tseb", "for", "ailuj"])== \'2\'', 'assert count_reverse_pairs(["geeks", "best", "for", "skeeg"]) == \'1\'', 'assert count_reverse_pairs(["makes", "best", "sekam", "for", "rof"]) == \'2\' ']
[BEGIN]

Response:
def count_reverse_pairs(test_list):
  res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len(
	test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))])
  return str(res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count number of unique lists within a list.

 Your code should pass these tests:

['assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1}', "assert unique_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}", 'assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}']
[BEGIN]

Response:
def unique_sublists(list1):
    result ={}
    for l in  list1:
        result.setdefault(tuple(l), list()).append(1)
    for a, b in result.items():
        result[a] = sum(b)
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check a decimal with a precision of 2.

 Your code should pass these tests:

["assert is_decimal('123.11')==True", "assert is_decimal('e666.86')==False", "assert is_decimal('3.124587')==False"]
[BEGIN]

Response:
def is_decimal(num):
    import re
    dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""")
    result = dnumre.search(num)
    return bool(result)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether an array contains only one distinct element or not.

 Your code should pass these tests:

["assert unique_Element([1,1,1],3) == 'YES'", "assert unique_Element([1,2,1,2],4) == 'NO'", "assert unique_Element([1,2,3,4,5],5) == 'NO'"]
[BEGIN]

Response:
def unique_Element(arr,n):
    s = set(arr)
    if (len(s) == 1):
        return ('YES')
    else:
        return ('NO')
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to caluclate arc length of an angle.

 Your code should pass these tests:

['assert arc_length(9,45)==3.5357142857142856', 'assert arc_length(9,480)==None', 'assert arc_length(5,270)==11.785714285714285']
[BEGIN]

Response:
def arc_length(d,a):
    pi=22/7
    if a >= 360:
        return None
    arclength = (pi*d) * (a/360)
    return arclength
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check whether the given month number contains 30 days or not.

 Your code should pass these tests:

['assert check_monthnumber_number(6)==True', 'assert check_monthnumber_number(2)==False', 'assert check_monthnumber_number(12)==False']
[BEGIN]

Response:
def check_monthnumber_number(monthnum3):
  if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11):
    return True
  else:
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the minimum difference between any two elements in a given array.

 Your code should pass these tests:

['assert find_Min_Diff((1,5,3,19,18,25),6) == 1', 'assert find_Min_Diff((4,3,2,6),4) == 1', 'assert find_Min_Diff((30,5,20,9),4) == 4']
[BEGIN]

Response:
def find_Min_Diff(arr,n):
    arr = sorted(arr)
    diff = 10**20
    for i in range(n-1):
        if arr[i+1] - arr[i] < diff:
            diff = arr[i+1] - arr[i]
    return diff
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count numeric values in a given string.

 Your code should pass these tests:

["assert number_ctr('program2bedone') == 1", "assert number_ctr('3wonders') ==1", "assert number_ctr('123') == 3"]
[BEGIN]

Response:
def number_ctr(str):
      number_ctr= 0
      for i in range(len(str)):
          if str[i] >= '0' and str[i] <= '9': number_ctr += 1
      return  number_ctr
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find nth polite number.

 Your code should pass these tests:

['assert is_polite(7) == 11', 'assert is_polite(4) == 7', 'assert is_polite(9) == 13']
[BEGIN]

Response:
import math
def is_polite(n):
	n = n + 1
	return (int)(n+(math.log((n + math.log(n, 2)), 2)))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to iterate over all pairs of consecutive items in a given list.

 Your code should pass these tests:

['assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)]', 'assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), (7, 9), (9, 10)]', 'assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]']
[BEGIN]

Response:
def pair_wise(l1):
    temp = []
    for i in range(len(l1) - 1):
        current_element, next_element = l1[i], l1[i + 1]
        x = (current_element, next_element)
        temp.append(x)
    return temp
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count the number of pairs whose sum is equal to ‘sum’.

 Your code should pass these tests:

['assert get_Pairs_Count([1,1,1,1],4,2) == 6', 'assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3', 'assert get_Pairs_Count([1,-2,3],3,1) == 1']
[BEGIN]

Response:
def get_Pairs_Count(arr,n,sum):
    count = 0
    for i in range(0,n):
        for j in range(i + 1,n):
            if arr[i] + arr[j] == sum:
                count += 1
    return count
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check for odd parity of a given number.

 Your code should pass these tests:

['assert check_Odd_Parity(13) == True', 'assert check_Odd_Parity(21) == True', 'assert check_Odd_Parity(18) == False']
[BEGIN]

Response:
def check_Odd_Parity(x):
    parity = 0
    while (x != 0):
        x = x & (x - 1)
        parity += 1
    if (parity % 2 == 1):
        return True
    else:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to get the difference between two lists.

 Your code should pass these tests:

['assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15]', 'assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7]', 'assert (Diff([1,2,3], [6,7,1])) == [2,3,6,7]']
[BEGIN]

Response:
def Diff(li1,li2):
    return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))

[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the sum of fourth power of first n odd natural numbers.

 Your code should pass these tests:

['assert odd_Num_Sum(2) == 82', 'assert odd_Num_Sum(3) == 707', 'assert odd_Num_Sum(4) == 3108']
[BEGIN]

Response:
def odd_Num_Sum(n) :
    j = 0
    sm = 0
    for i in range(1,n + 1) :
        j = (2*i-1)
        sm = sm + (j*j*j*j)
    return sm
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the given expression is balanced or not.

 Your code should pass these tests:

['assert check_expression("{()}[{}]") == True', 'assert check_expression("{()}[{]") == False', 'assert check_expression("{()}[{}][]({})") == True']
[BEGIN]

Response:
from collections import deque
def check_expression(exp):
    if len(exp) & 1:
        return False
    stack = deque()
    for ch in exp:
        if ch == '(' or ch == '{' or ch == '[':
            stack.append(ch)
        if ch == ')' or ch == '}' or ch == ']':
            if not stack:
                return False
            top = stack.pop()
            if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):
                return False
    return not stack
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove all the words with k length in the given string.

 Your code should pass these tests:

["assert remove_length('The person is most value tet', 3) == 'person is most value'", "assert remove_length('If you told me about this ok', 4) == 'If you me about ok'", "assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'"]
[BEGIN]

Response:
def remove_length(test_str, K):
  temp = test_str.split()
  res = [ele for ele in temp if len(ele) != K]
  res = ' '.join(res)
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the occurrence and position of the substrings within a string.

 Your code should pass these tests:

["assert occurance_substring('python programming, python language','python')==('python', 0, 6)", "assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)", "assert occurance_substring('python programming,programming language','language')==('language', 31, 39)"]
[BEGIN]

Response:
import re
def occurance_substring(text,pattern):
 for match in re.finditer(pattern, text):
    s = match.start()
    e = match.end()
    return (text[s:e], s, e)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the string is a valid email address or not using regex.

 Your code should pass these tests:

['assert check_email("ankitrai326@gmail.com") == \'Valid Email\'', 'assert check_email("my.ownsite@ourearth.org") == \'Valid Email\'', 'assert check_email("ankitaoie326.com") == \'Invalid Email\'']
[BEGIN]

Response:
import re
regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$'
def check_email(email):
	if(re.search(regex,email)):
		return ("Valid Email")
	else:
		return ("Invalid Email")
[DONE]