Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether every odd index contains odd numbers of a given list.

 Your code should pass these tests:

['assert odd_position([2,1,4,3,6,7,6,3]) == True', 'assert odd_position([4,1,2]) == True', 'assert odd_position([1,2,3]) == False']
[BEGIN]

Response:
def odd_position(nums):
	return all(nums[i]%2==i%2 for i in range(len(nums)))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count those characters which have vowels as their neighbors in the given string.

 Your code should pass these tests:

["assert count_vowels('bestinstareels') == 7", "assert count_vowels('partofthejourneyistheend') == 12", "assert count_vowels('amazonprime') == 5"]
[BEGIN]

Response:
def count_vowels(test_str):
  res = 0
  vow_list = ['a', 'e', 'i', 'o', 'u']
  for idx in range(1, len(test_str) - 1):
    if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):
      res += 1
  if test_str[0] not in vow_list and test_str[1] in vow_list:
    res += 1
  if test_str[-1] not in vow_list and test_str[-2] in vow_list:
    res += 1
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the sum of non-repeated elements in a given array.

 Your code should pass these tests:

['assert find_Sum([1,2,3,1,1,4,5,6],8) == 21', 'assert find_Sum([1,10,9,4,2,10,10,45,4],9) == 71', 'assert find_Sum([12,10,9,45,2,10,10,45,10],9) == 78']
[BEGIN]

Response:
def find_Sum(arr,n):
    arr.sort()
    sum = arr[0]
    for i in range(0,n-1):
        if (arr[i] != arr[i+1]):
            sum = sum + arr[i+1]
    return sum
[DONE]


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

 Your code should pass these tests:

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

Response:
from itertools import groupby
def pack_consecutive_duplicates(list1):
    return [list(group) for key, group in groupby(list1)]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count the 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([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 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 find the combinations of sums with tuples in the given tuple list.

 Your code should pass these tests:

['assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)]', 'assert find_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]', 'assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]']
[BEGIN]

Response:
from itertools import combinations
def find_combinations(test_list):
  res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the count of divisors is even or odd.

 Your code should pass these tests:

['assert count_Divisors(10) == "Even"', 'assert count_Divisors(100) == "Odd"', 'assert count_Divisors(125) == "Even"']
[BEGIN]

Response:
import math
def count_Divisors(n) :
    count = 0
    for i in range(1, (int)(math.sqrt(n)) + 2) :
        if (n % i == 0) :
            if( n // i == i) :
                count = count + 1
            else :
                count = count + 2
    if (count % 2 == 0) :
        return ("Even")
    else :
        return ("Odd")
[DONE]


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

 Your code should pass these tests:

['assert Odd_Length_Sum([1,2,4]) == 14', 'assert Odd_Length_Sum([1,2,1,2]) == 15', 'assert Odd_Length_Sum([1,7]) == 8']
[BEGIN]

Response:
def Odd_Length_Sum(arr):
    Sum = 0
    l = len(arr)
    for i in range(l):
        Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])
    return Sum
[DONE]


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

 Your code should pass these tests:

['assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0)', 'assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608)', 'assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.34883720930233, 84.31372549019608)']
[BEGIN]

Response:
def rgb_to_hsv(r, g, b):
    r, g, b = r/255.0, g/255.0, b/255.0
    mx = max(r, g, b)
    mn = min(r, g, b)
    df = mx-mn
    if mx == mn:
        h = 0
    elif mx == r:
        h = (60 * ((g-b)/df) + 360) % 360
    elif mx == g:
        h = (60 * ((b-r)/df) + 120) % 360
    elif mx == b:
        h = (60 * ((r-g)/df) + 240) % 360
    if mx == 0:
        s = 0
    else:
        s = (df/mx)*100
    v = mx*100
    return h, s, v
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the product of first even and odd number of a given list.

 Your code should pass these tests:

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

Response:
def mul_even_odd(list1):
    first_even = next((el for el in list1 if el%2==0),-1)
    first_odd = next((el for el in list1 if el%2!=0),-1)
    return (first_even*first_odd)
[DONE]


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

 Your code should pass these tests:

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

Response:
def tuple_str_int(test_str):
  res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))
  return (res)
[DONE]


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

 Your code should pass these tests:

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

Response:
import bisect
def right_insertion(a, x):
    i = bisect.bisect_right(a, x)
    return i
[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 three 'b'.

 Your code should pass these tests:

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

Response:
import re
def text_match_three(text):
        patterns = 'ab{3}?'
        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 create a new tuple from the given string and list.

 Your code should pass these tests:

['assert new_tuple(["WEB", "is"], "best") == (\'WEB\', \'is\', \'best\')', 'assert new_tuple(["We", "are"], "Developers") == (\'We\', \'are\', \'Developers\')', 'assert new_tuple(["Part", "is"], "Wrong") == (\'Part\', \'is\', \'Wrong\')']
[BEGIN]

Response:
def new_tuple(test_list, test_str):
  res = tuple(test_list + [test_str])
  return (res)
[DONE]


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

 Your code should pass these tests:

['assert perimeter_polygon(4,20)==80', 'assert perimeter_polygon(10,15)==150', 'assert perimeter_polygon(9,7)==63']
[BEGIN]

Response:
from math import tan, pi
def perimeter_polygon(s,l):
  perimeter = s*l
  return perimeter
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether every even index contains even numbers of a given list.

 Your code should pass these tests:

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

Response:
def even_position(nums):
	return all(nums[i]%2==i%2 for i in range(len(nums)))
[DONE]


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

 Your code should pass these tests:

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

Response:
def remove_nested(test_tup):
  res = tuple()
  for count, ele in enumerate(test_tup):
    if not isinstance(ele, tuple):
      res = res + (ele, )
  return (res)
[DONE]


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

 Your code should pass these tests:

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

Response:
def count_list(input_list):
    return len(input_list)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the last position of an element in a sorted array.

 Your code should pass these tests:

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

Response:
def last(arr,x,n):
    low = 0
    high = n - 1
    res = -1
    while (low <= high):
        mid = (low + high) // 2
        if arr[mid] > x:
            high = mid - 1
        elif arr[mid] < x:
            low = mid + 1
        else:
            res = mid
            low = mid + 1
    return res
[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 anything, ending in 'b'.

 Your code should pass these tests:

['assert text_starta_endb("aabbbb")==(\'Found a match!\')', 'assert text_starta_endb("aabAbbbc")==(\'Not matched!\')', 'assert text_starta_endb("accddbbjjj")==(\'Not matched!\')']
[BEGIN]

Response:
import re
def text_starta_endb(text):
        patterns = 'a.*?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 function to find the n - cheap price items from a given dataset using heap queue algorithm.

 Your code should pass these tests:

["assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price': 101.1}]", "assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2)==[{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]", "assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-4', 'price': 22.75}]"]
[BEGIN]

Response:
import heapq
def cheap_items(items,n):
  cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])
  return cheap_items
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write function to find the sum of all items in the given dictionary.

 Your code should pass these tests:

["assert return_sum({'a': 100, 'b':200, 'c':300}) == 600", "assert return_sum({'a': 25, 'b':18, 'c':45}) == 88", "assert return_sum({'a': 36, 'b':39, 'c':49}) == 124"]
[BEGIN]

Response:
def return_sum(dict):
  sum = 0
  for i in dict.values():
    sum = sum + i
  return sum
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the sum of all odd natural numbers within the range l and r.

 Your code should pass these tests:

['assert sum_in_Range(2,5) == 8', 'assert sum_in_Range(5,7) == 12', 'assert sum_in_Range(7,13) == 40']
[BEGIN]

Response:
def sum_Odd(n):
    terms = (n + 1)//2
    sum1 = terms * terms
    return sum1
def sum_in_Range(l,r):
    return sum_Odd(r) - sum_Odd(l - 1)
[DONE]


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

 Your code should pass these tests:

['assert _sum([1, 2, 3]) == 6', 'assert _sum([15, 12, 13, 10]) == 50', 'assert _sum([0, 1, 2]) == 3']
[BEGIN]

Response:
def _sum(arr):
    sum=0
    for i in arr:
        sum = sum + i
    return(sum)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to left rotate the bits of a given number.

 Your code should pass these tests:

['assert left_Rotate(16,2) == 64', 'assert left_Rotate(10,2) == 40', 'assert left_Rotate(99,3) == 792']
[BEGIN]

Response:
INT_BITS = 32
def left_Rotate(n,d):
    return (n << d)|(n >> (INT_BITS - d))
[DONE]


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

 Your code should pass these tests:

["assert remove_all_spaces('python  program')==('pythonprogram')", "assert remove_all_spaces('python   programming    language')==('pythonprogramminglanguage')", "assert remove_all_spaces('python                     program')==('pythonprogram')"]
[BEGIN]

Response:
import re
def remove_all_spaces(text):
 return (re.sub(r'\s+', '',text))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count the number of equal numbers from three given integers.

 Your code should pass these tests:

['assert test_three_equal(1,1,1) == 3', 'assert test_three_equal(-1,-2,-3) == 0', 'assert test_three_equal(1,2,2) == 2']
[BEGIN]

Response:
def test_three_equal(x,y,z):
  result= set([x,y,z])
  if len(result)==3:
    return 0
  else:
    return (4-len(result))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count the number of rotations required to generate a sorted array.

 Your code should pass these tests:

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

Response:
def count_Rotation(arr,n):
    for i in range (1,n):
        if (arr[i] < arr[i - 1]):
            return i
    return 0
[DONE]


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

 Your code should pass these tests:

['assert is_Perfect_Square(10) == False', 'assert is_Perfect_Square(36) == True', 'assert is_Perfect_Square(14) == False']
[BEGIN]

Response:
def is_Perfect_Square(n) :
    i = 1
    while (i * i<= n):
        if ((n % i == 0) and (n / i == i)):
            return True
        i = i + 1
    return False
[DONE]


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

 Your code should pass these tests:

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

Response:
def is_Product_Even(arr,n):
    for i in range(0,n):
        if ((arr[i] & 1) == 0):
            return True
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the list in a list of lists whose sum of elements is the highest.

 Your code should pass these tests:

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

Response:
def max_sum_list(lists):
 return max(lists, key=sum)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find maximum run of uppercase characters in the given string.

 Your code should pass these tests:

["assert max_run_uppercase('GeMKSForGERksISBESt') == 5", "assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6", "assert max_run_uppercase('GooGLEFluTTER') == 4"]
[BEGIN]

Response:
def max_run_uppercase(test_str):
  cnt = 0
  res = 0
  for idx in range(0, len(test_str)):
    if test_str[idx].isupper():
      cnt += 1
    else:
      res = cnt
      cnt = 0
  if test_str[len(test_str) - 1].isupper():
    res = cnt
  return (res)
[DONE]


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

 Your code should pass these tests:

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

Response:
def first_odd(nums):
  first_odd = next((el for el in nums if el%2!=0),-1)
  return first_odd
[DONE]


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

 Your code should pass these tests:

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

Response:
def check_K(test_tup, K):
  res = False
  for ele in test_tup:
    if ele == K:
      res = True
      break
  return (res)
[DONE]


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

 Your code should pass these tests:

['assert check_smaller((1, 2, 3), (2, 3, 4)) == False', 'assert check_smaller((4, 5, 6), (3, 4, 5)) == True', 'assert check_smaller((11, 12, 13), (10, 11, 12)) == True']
[BEGIN]

Response:
def check_smaller(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 iterate over elements repeating each as many times as its count.

 Your code should pass these tests:

["assert count_variable(4,2,0,-2)==['p', 'p', 'p', 'p', 'q', 'q'] ", "assert count_variable(0,1,2,3)==['q', 'r', 'r', 's', 's', 's'] ", "assert count_variable(11,15,12,23)==['p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'p', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'q', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 'r', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's', 's']"]
[BEGIN]

Response:
from collections import Counter
def count_variable(a,b,c,d):
  c = Counter(p=a, q=b, r=c, s=d)
  return list(c.elements())
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if two lists of tuples are identical or not.

 Your code should pass these tests:

['assert check_identical([(10, 4), (2, 5)], [(10, 4), (2, 5)]) == True', 'assert check_identical([(1, 2), (3, 7)], [(12, 14), (12, 45)]) == False', 'assert check_identical([(2, 14), (12, 25)], [(2, 14), (12, 25)]) == True']
[BEGIN]

Response:
def check_identical(test_list1, test_list2):
  res = test_list1 == test_list2
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to abbreviate 'road' as 'rd.' in a given string.

 Your code should pass these tests:

['assert road_rd("ravipadu Road")==(\'ravipadu Rd.\')', 'assert road_rd("palnadu Road")==(\'palnadu Rd.\')', 'assert road_rd("eshwar enclave Road")==(\'eshwar enclave Rd.\')']
[BEGIN]

Response:
import re
def road_rd(street):
  return (re.sub('Road$', 'Rd.', street))
[DONE]


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

 Your code should pass these tests:

["assert string_length('python')==6", "assert string_length('program')==7", "assert string_length('language')==8"]
[BEGIN]

Response:
def string_length(str1):
    count = 0
    for char in str1:
        count += 1
    return count
[DONE]


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

 Your code should pass these tests:

['assert rombus_area(10,20)==100', 'assert rombus_area(10,5)==25', 'assert rombus_area(4,2)==4']
[BEGIN]

Response:
def rombus_area(p,q):
  area=(p*q)/2
  return area
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.

 Your code should pass these tests:

['assert sort_by_dnf([1,2,0,1,0,1,2,1,1], 9) == [0, 0, 1, 1, 1, 1, 1, 2, 2]', 'assert sort_by_dnf([1,0,0,1,2,1,2,2,1,0], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]', 'assert sort_by_dnf([2,2,1,0,0,0,1,1,2,1], 10) == [0, 0, 0, 1, 1, 1, 1, 2, 2, 2]']
[BEGIN]

Response:
def sort_by_dnf(arr, n):
  low=0
  mid=0
  high=n-1
  while mid <= high:
    if arr[mid] == 0:
      arr[low], arr[mid] = arr[mid], arr[low]
      low = low + 1
      mid = mid + 1
    elif arr[mid] == 1:
      mid = mid + 1
    else:
      arr[mid], arr[high] = arr[high], arr[mid]
      high = high - 1
  return arr
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to clear the values of the given tuples.

 Your code should pass these tests:

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

Response:
def clear_tuple(test_tup):
  temp = list(test_tup)
  temp.clear()
  test_tup = tuple(temp)
  return (test_tup)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find numbers divisible by m or n from a list of numbers using lambda function.

 Your code should pass these tests:

['assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],19,13)==[19, 65, 57, 39, 152, 190]', 'assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[2, 5, 8, 10]', 'assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10, 15, 20]']
[BEGIN]

Response:
def div_of_nums(nums,m,n):
 result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums))
 return result
[DONE]


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

 Your code should pass these tests:

["assert lower_ctr('abc') == 3", "assert lower_ctr('string') == 6", "assert lower_ctr('Python') == 5"]
[BEGIN]

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


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.

 Your code should pass these tests:

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

Response:
def count_duplic(lists):
    element = []
    frequency = []
    if not lists:
        return element
    running_count = 1
    for i in range(len(lists)-1):
        if lists[i] == lists[i+1]:
            running_count += 1
        else:
            frequency.append(running_count)
            element.append(lists[i])
            running_count = 1
    frequency.append(running_count)
    element.append(lists[i+1])
    return element,frequency

[DONE]


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

 Your code should pass these tests:

['assert check_monthnum_number(2)==True', 'assert check_monthnum_number(1)==False', 'assert check_monthnum_number(3)==False']
[BEGIN]

Response:
def check_monthnum_number(monthnum1):
  if monthnum1 == 2:
    return True
  else:
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to merge two dictionaries into a single expression.

 Your code should pass these tests:

['assert merge_dictionaries({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" })=={\'B\': \'Black\', \'R\': \'Red\', \'P\': \'Pink\', \'G\': \'Green\', \'W\': \'White\'}', 'assert merge_dictionaries({ "R": "Red", "B": "Black", "P": "Pink" },{ "O": "Orange", "W": "White", "B": "Black" })=={\'O\': \'Orange\', \'P\': \'Pink\', \'B\': \'Black\', \'W\': \'White\', \'R\': \'Red\'}', 'assert merge_dictionaries({ "G": "Green", "W": "White" },{ "O": "Orange", "W": "White", "B": "Black" })=={\'W\': \'White\', \'O\': \'Orange\', \'G\': \'Green\', \'B\': \'Black\'}']
[BEGIN]

Response:
import collections as ct
def merge_dictionaries(dict1,dict2):
    merged_dict = dict(ct.ChainMap({}, dict1, dict2))
    return merged_dict
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to return true if the password is valid.

 Your code should pass these tests:

['assert pass_validity("password")==False', 'assert pass_validity("Password@10")==True', 'assert pass_validity("password@10")==False']
[BEGIN]

Response:
import re
def pass_validity(p):
 x = True
 while x:
    if (len(p)<6 or len(p)>12):
        break
    elif not re.search("[a-z]",p):
        break
    elif not re.search("[0-9]",p):
        break
    elif not re.search("[A-Z]",p):
        break
    elif not re.search("[$#@]",p):
        break
    elif re.search("\s",p):
        break
    else:
        return True
        x=False
        break

 if x:
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the given string starts with a substring using regex.

 Your code should pass these tests:

['assert check_substring("dreams for dreams makes life fun", "makes") == \'string doesnt start with the given substring\'', 'assert check_substring("Hi there how are you Hi alex", "Hi") == \'string starts with the given substring\'', 'assert check_substring("Its been a long day", "been") == \'string doesnt start with the given substring\'']
[BEGIN]

Response:
import re
def check_substring(string, sample) :
  if (sample in string):
      y = "\A" + sample
      x = re.search(y, string)
      if x :
          return ("string starts with the given substring")
      else :
          return ("string doesnt start with the given substring")
  else :
      return ("entered string isnt a substring")
[DONE]


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

 Your code should pass these tests:

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

Response:
def remove_even(l):
    for i in l:
        if i % 2 == 0:
            l.remove(i)
    return l
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to access multiple elements of specified index from a given list.

 Your code should pass these tests:

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

Response:
def access_elements(nums, list_index):
    result = [nums[i] for i in list_index]
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the type of triangle from the given sides.

 Your code should pass these tests:

['assert check_Type_Of_Triangle(1,2,3) == "Obtuse-angled Triangle"', 'assert check_Type_Of_Triangle(2,2,2) == "Acute-angled Triangle"', 'assert check_Type_Of_Triangle(1,0,1) == "Right-angled Triangle"']
[BEGIN]

Response:
def check_Type_Of_Triangle(a,b,c):
    sqa = pow(a,2)
    sqb = pow(b,2)
    sqc = pow(c,2)
    if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb):
        return ("Right-angled Triangle")
    elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb):
        return ("Obtuse-angled Triangle")
    else:
        return ("Acute-angled Triangle")
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sum a specific column of a list in a given list of lists.

 Your code should pass these tests:

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

Response:
def sum_column(list1, C):
    result = sum(row[C] for row in list1)
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count alphabets,digits and special charactes in a given string.

 Your code should pass these tests:

['assert count_alpha_dig_spl("abc!@#123")==(3,3,3)', 'assert count_alpha_dig_spl("dgsuy@#$%&1255")==(5,4,5)', 'assert count_alpha_dig_spl("fjdsif627348#%$^&")==(6,6,5)']
[BEGIN]

Response:
def count_alpha_dig_spl(string):
  alphabets=digits = special = 0
  for i in range(len(string)):
    if(string[i].isalpha()):
        alphabets = alphabets + 1
    elif(string[i].isdigit()):
        digits = digits + 1
    else:
        special = special + 1
  return (alphabets,digits,special)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find out the second most repeated (or frequent) string in the given sequence.

 Your code should pass these tests:

["assert second_frequent(['aaa','bbb','ccc','bbb','aaa','aaa']) == 'bbb'", "assert second_frequent(['abc','bcd','abc','bcd','bcd','bcd']) == 'abc'", "assert second_frequent(['cdma','gsm','hspa','gsm','cdma','cdma']) == 'gsm'"]
[BEGIN]

Response:
from collections import Counter

def second_frequent(input):
	dict = Counter(input)
	value = sorted(dict.values(), reverse=True)
	second_large = value[1]
	for (key, val) in dict.items():
		if val == second_large:
			return (key)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to round up a number to specific digits.

 Your code should pass these tests:

['assert round_up(123.01247,0)==124', 'assert round_up(123.01247,1)==123.1', 'assert round_up(123.01247,2)==123.02']
[BEGIN]

Response:
import math
def round_up(a, digits):
    n = 10**-digits
    return round(math.ceil(a / n) * n, digits)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to count equal element pairs from the given array.

 Your code should pass these tests:

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

Response:
def count_Pairs(arr,n):
    cnt = 0;
    for i in range(n):
        for j in range(i + 1,n):
            if (arr[i] == arr[j]):
                cnt += 1;
    return cnt;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to extract the maximum numeric value from a string by using regex.

 Your code should pass these tests:

["assert extract_max('100klh564abc365bg') == 564", "assert extract_max('hello300how546mer231') == 546", "assert extract_max('its233beenalong343journey234') == 343"]
[BEGIN]

Response:
import re
def extract_max(input):
	numbers = re.findall('\d+',input)
	numbers = map(int,numbers)
	return max(numbers)
[DONE]


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

 Your code should pass these tests:

["assert get_key({1:'python',2:'java'})==[1,2]", "assert get_key({10:'red',20:'blue',30:'black'})==[10,20,30]", "assert get_key({27:'language',39:'java',44:'little'})==[27,39,44]"]
[BEGIN]

Response:
def get_key(dict):
    list = []
    for key in dict.keys():
        list.append(key)
    return list
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.

 Your code should pass these tests:

['assert generate_matrix(3)==[[1, 2, 3], [8, 9, 4], [7, 6, 5]] ', 'assert generate_matrix(2)==[[1,2],[4,3]]', 'assert generate_matrix(7)==[[1, 2, 3, 4, 5, 6, 7], [24, 25, 26, 27, 28, 29, 8], [23, 40, 41, 42, 43, 30, 9], [22, 39, 48, 49, 44, 31, 10], [21, 38, 47, 46, 45, 32, 11], [20, 37, 36, 35, 34, 33, 12], [19, 18, 17, 16, 15, 14, 13]]']
[BEGIN]

Response:
def generate_matrix(n):
        if n<=0:
            return []
        matrix=[row[:] for row in [[0]*n]*n]
        row_st=0
        row_ed=n-1
        col_st=0
        col_ed=n-1
        current=1
        while (True):
            if current>n*n:
                break
            for c in range (col_st, col_ed+1):
                matrix[row_st][c]=current
                current+=1
            row_st+=1
            for r in range (row_st, row_ed+1):
                matrix[r][col_ed]=current
                current+=1
            col_ed-=1
            for c in range (col_ed, col_st-1, -1):
                matrix[row_ed][c]=current
                current+=1
            row_ed-=1
            for r in range (row_ed, row_st-1, -1):
                matrix[r][col_st]=current
                current+=1
            col_st+=1
        return matrix
[DONE]


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

 Your code should pass these tests:

['assert slope(4,2,2,5) == -1.5', 'assert slope(2,4,4,6) == 1', 'assert slope(1,2,4,2) == 0']
[BEGIN]

Response:
def slope(x1,y1,x2,y2):
    return (float)(y2-y1)/(x2-x1)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find length of the subarray having maximum sum.

 Your code should pass these tests:

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

Response:
from sys import maxsize
def max_sub_array_sum(a,size):
	max_so_far = -maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0,size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i+1
	return (end - start + 1)
[DONE]


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

 Your code should pass these tests:

['assert cube_Sum(2) == 28', 'assert cube_Sum(3) == 153', 'assert cube_Sum(4) == 496']
[BEGIN]

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


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find minimum number swaps required to make two binary strings equal.

 Your code should pass these tests:

['assert min_Swaps("0011","1111") == 1', 'assert min_Swaps("00011","01001") == 2', 'assert min_Swaps("111","111") == 0']
[BEGIN]

Response:
def min_Swaps(s1,s2) :
    c0 = 0; c1 = 0;
    for i in range(len(s1)) :
        if (s1[i] == '0' and s2[i] == '1') :
            c0 += 1;
        elif (s1[i] == '1' and s2[i] == '0') :
            c1 += 1;
    result = c0 // 2 + c1 // 2;
    if (c0 % 2 == 0 and c1 % 2 == 0) :
        return result;
    elif ((c0 + c1) % 2 == 0) :
        return result + 2;
    else :
        return -1;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort the tuples alphabetically by the first item of each tuple.

 Your code should pass these tests:

['assert sort_tuple([("Amana", 28), ("Zenat", 30), ("Abhishek", 29),("Nikhil", 21), ("B", "C")]) == [(\'Abhishek\', 29), (\'Amana\', 28), (\'B\', \'C\'), (\'Nikhil\', 21), (\'Zenat\', 30)]', 'assert sort_tuple([("aaaa", 28), ("aa", 30), ("bab", 29), ("bb", 21), ("csa", "C")]) == [(\'aa\', 30), (\'aaaa\', 28), (\'bab\', 29), (\'bb\', 21), (\'csa\', \'C\')]', 'assert sort_tuple([("Sarala", 28), ("Ayesha", 30), ("Suman", 29),("Sai", 21), ("G", "H")]) == [(\'Ayesha\', 30), (\'G\', \'H\'), (\'Sai\', 21), (\'Sarala\', 28), (\'Suman\', 29)]']
[BEGIN]

Response:
def sort_tuple(tup):
	n = len(tup)
	for i in range(n):
		for j in range(n-i-1):
			if tup[j][0] > tup[j + 1][0]:
				tup[j], tup[j + 1] = tup[j + 1], tup[j]
	return tup
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.

 Your code should pass these tests:

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

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


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

 Your code should pass these tests:

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

Response:
def get_inv_count(arr, n):
	inv_count = 0
	for i in range(n):
		for j in range(i + 1, n):
			if (arr[i] > arr[j]):
				inv_count += 1
	return inv_count
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the number which occurs for odd number of times in the given array.

 Your code should pass these tests:

['assert get_odd_occurence([2, 3, 5, 4, 5, 2, 4, 3, 5, 2, 4, 4, 2], 13) == 5', 'assert get_odd_occurence([1, 2, 3, 2, 3, 1, 3], 7) == 3', 'assert get_odd_occurence([5, 7, 2, 7, 5, 2, 5], 7) == 5']
[BEGIN]

Response:
def get_odd_occurence(arr, arr_size):
  for i in range(0, arr_size):
    count = 0
    for j in range(0, arr_size):
      if arr[i] == arr[j]:
        count += 1
    if (count % 2 != 0):
      return arr[i]
  return -1
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.

 Your code should pass these tests:

['assert nth_super_ugly_number(12,[2,7,13,19])==32', 'assert nth_super_ugly_number(10,[2,7,13,19])==26', 'assert nth_super_ugly_number(100,[2,7,13,19])==5408']
[BEGIN]

Response:
import heapq
def nth_super_ugly_number(n, primes):
    uglies = [1]
    def gen(prime):
        for ugly in uglies:
            yield ugly * prime
    merged = heapq.merge(*map(gen, primes))
    while len(uglies) < n:
        ugly = next(merged)
        if ugly != uglies[-1]:
            uglies.append(ugly)
    return uglies[-1]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the kth element in an array containing odd elements first and then even elements.

 Your code should pass these tests:

['assert get_Number(8,5) == 2', 'assert get_Number(7,2) == 3', 'assert get_Number(5,2) == 3']
[BEGIN]

Response:
def get_Number(n, k):
    arr = [0] * n;
    i = 0;
    odd = 1;
    while (odd <= n):
        arr[i] = odd;
        i += 1;
        odd += 2;
    even = 2;
    while (even <= n):
        arr[i] = even;
        i += 1;
        even += 2;
    return arr[k - 1];
[DONE]


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

 Your code should pass these tests:

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

Response:
import math
def find_Digits(n):
    if (n < 0):
        return 0;
    if (n <= 1):
        return 1;
    x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0));
    return math.floor(x) + 1;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the minimum number of platforms required for a railway/bus station.

 Your code should pass these tests:

['assert find_platform([900, 940, 950, 1100, 1500, 1800],[910, 1200, 1120, 1130, 1900, 2000],6)==3', 'assert find_platform([100,200,300,400],[700,800,900,1000],4)==4', 'assert find_platform([5,6,7,8],[4,3,2,1],4)==1']
[BEGIN]

Response:
def find_platform(arr, dep, n):
    arr.sort()
    dep.sort()
    plat_needed = 1
    result = 1
    i = 1
    j = 0
    while (i < n and j < n):
        if (arr[i] <= dep[j]):
            plat_needed+= 1
            i+= 1
        elif (arr[i] > dep[j]):
            plat_needed-= 1
            j+= 1
        if (plat_needed > result):
            result = plat_needed
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to copy a list from a singleton tuple.

 Your code should pass these tests:

['assert lcopy([1, 2, 3]) == [1, 2, 3]', 'assert lcopy([4, 8, 2, 10, 15, 18]) == [4, 8, 2, 10, 15, 18]', 'assert lcopy([4, 5, 6]) == [4, 5, 6]\n']
[BEGIN]

Response:
def lcopy(xs):
  return xs[:]

[DONE]


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

 Your code should pass these tests:

['assert area_trapezium(6,9,4)==30', 'assert area_trapezium(10,20,30)==450', 'assert area_trapezium(15,25,35)==700']
[BEGIN]

Response:
def area_trapezium(base1,base2,height):
 area = 0.5 * (base1 + base2) * height
 return area
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find sum of all prime divisors of a given number.

 Your code should pass these tests:

['assert Sum(60) == 10', 'assert Sum(39) == 16', 'assert Sum(40) == 7']
[BEGIN]

Response:
def Sum(N):
    SumOfPrimeDivisors = [0]*(N + 1)
    for i in range(2,N + 1) :
        if (SumOfPrimeDivisors[i] == 0) :
            for j in range(i,N + 1,i) :
                SumOfPrimeDivisors[j] += i
    return SumOfPrimeDivisors[N]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if a triangle of positive area is possible with the given angles.

 Your code should pass these tests:

['assert is_triangleexists(50,60,70)==True', 'assert is_triangleexists(90,45,45)==True', 'assert is_triangleexists(150,30,70)==False']
[BEGIN]

Response:
def is_triangleexists(a,b,c):
    if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180):
        if((a + b)>= c or (b + c)>= a or (a + c)>= b):
            return True
        else:
            return False
    else:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find sum of inverse of divisors.

 Your code should pass these tests:

['assert Sum_of_Inverse_Divisors(6,12) == 2', 'assert Sum_of_Inverse_Divisors(9,13) == 1.44', 'assert Sum_of_Inverse_Divisors(1,4) == 4']
[BEGIN]

Response:
def Sum_of_Inverse_Divisors(N,Sum):
    ans = float(Sum)*1.0 /float(N);
    return round(ans,2);
[DONE]


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

 Your code should pass these tests:

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

Response:
def remove_negs(num_list):
    for item in num_list:
        if item < 0:
           num_list.remove(item)
    return num_list
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find sum of odd factors of a number.

 Your code should pass these tests:

['assert sum_of_odd_Factors(30) == 24', 'assert sum_of_odd_Factors(18) == 13', 'assert sum_of_odd_Factors(2) == 1']
[BEGIN]

Response:
import math
def sum_of_odd_Factors(n):
    res = 1
    while n % 2 == 0:
        n = n // 2
    for i in range(3,int(math.sqrt(n) + 1)):
        count = 0
        curr_sum = 1
        curr_term = 1
        while n % i == 0:
            count+=1
            n = n // i
            curr_term *= i
            curr_sum += curr_term
        res *= curr_sum
    if n >= 2:
        res *= (1 + n)
    return res
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm.

 Your code should pass these tests:

['assert raw_heap([25, 44, 68, 21, 39, 23, 89])==[21, 25, 23, 44, 39, 68, 89]', 'assert raw_heap([25, 35, 22, 85, 14, 65, 75, 25, 58])== [14, 25, 22, 25, 35, 65, 75, 85, 58]', 'assert raw_heap([4, 5, 6, 2])==[2, 4, 6, 5]']
[BEGIN]

Response:
import heapq as hq
def raw_heap(rawheap):
  hq.heapify(rawheap)
  return rawheap
[DONE]


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

 Your code should pass these tests:

['assert check_Even_Parity(10) == True', 'assert check_Even_Parity(11) == False', 'assert check_Even_Parity(18) == True']
[BEGIN]

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


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find minimum adjacent swaps required to sort binary array.

 Your code should pass these tests:

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

Response:
def find_Min_Swaps(arr,n) :
    noOfZeroes = [0] * n
    count = 0
    noOfZeroes[n - 1] = 1 - arr[n - 1]
    for i in range(n-2,-1,-1) :
        noOfZeroes[i] = noOfZeroes[i + 1]
        if (arr[i] == 0) :
            noOfZeroes[i] = noOfZeroes[i] + 1
    for i in range(0,n) :
        if (arr[i] == 1) :
            count = count + noOfZeroes[i]
    return count
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to list out the list of given strings individually using map function.

 Your code should pass these tests:

["assert listify_list(['Red', 'Blue', 'Black', 'White', 'Pink'])==[['R', 'e', 'd'], ['B', 'l', 'u', 'e'], ['B', 'l', 'a', 'c', 'k'], ['W', 'h', 'i', 't', 'e'], ['P', 'i', 'n', 'k']]", "assert listify_list(['python'])==[['p', 'y', 't', 'h', 'o', 'n']]", "assert listify_list([' red ', 'green',' black', 'blue ',' orange', 'brown'])==[[' ', 'r', 'e', 'd', ' '], ['g', 'r', 'e', 'e', 'n'], [' ', 'b', 'l', 'a', 'c', 'k'], ['b', 'l', 'u', 'e', ' '], [' ', 'o', 'r', 'a', 'n', 'g', 'e'], ['b', 'r', 'o', 'w', 'n']]"]
[BEGIN]

Response:
def listify_list(list1):
  result = list(map(list,list1))
  return result
[DONE]


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

 Your code should pass these tests:

['assert count_list([[0], [1, 3], [5, 7], [9, 11], [13, 15, 17]])==25', 'assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]] )==16', 'assert count_list([[2, 4], [[6,8], [4,5,8]], [10, 12, 14]])==9']
[BEGIN]

Response:
def count_list(input_list):
    return (len(input_list))**2
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to generate all sublists of a given list.

 Your code should pass these tests:

['assert sub_lists([10, 20, 30, 40])==[[], [10], [20], [30], [40], [10, 20], [10, 30], [10, 40], [20, 30], [20, 40], [30, 40], [10, 20, 30], [10, 20, 40], [10, 30, 40], [20, 30, 40], [10, 20, 30, 40]]', "assert sub_lists(['X', 'Y', 'Z'])==[[], ['X'], ['Y'], ['Z'], ['X', 'Y'], ['X', 'Z'], ['Y', 'Z'], ['X', 'Y', 'Z']]", 'assert sub_lists([1,2,3])==[[],[1],[2],[3],[1,2],[1,3],[2,3],[1,2,3]]']
[BEGIN]

Response:
from itertools import combinations
def sub_lists(my_list):
	subs = []
	for i in range(0, len(my_list)+1):
	  temp = [list(x) for x in combinations(my_list, i)]
	  if len(temp)>0:
	    subs.extend(temp)
	return subs
[DONE]


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

 Your code should pass these tests:

['assert check_alphanumeric("dawood@") == \'Discard\'', 'assert check_alphanumeric("skdmsam326") == \'Accept\'', 'assert check_alphanumeric("cooltricks@") == \'Discard\'']
[BEGIN]

Response:
import re
regex = '[a-zA-z0-9]$'
def check_alphanumeric(string):
	if(re.search(regex, string)):
		return ("Accept")
	else:
		return ("Discard")
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find all anagrams of a string in a given list of strings using lambda function.

 Your code should pass these tests:

['assert anagram_lambda(["bcda", "abce", "cbda", "cbea", "adcb"],"abcd")==[\'bcda\', \'cbda\', \'adcb\']', 'assert anagram_lambda(["recitals"," python"], "articles" )==["recitals"]', 'assert anagram_lambda([" keep"," abcdef"," xyz"]," peek")==[" keep"]']
[BEGIN]

Response:
from collections import Counter
def anagram_lambda(texts,str):
  result = list(filter(lambda x: (Counter(str) == Counter(x)), texts))
  return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the occurrences of n most common words in a given text.

 Your code should pass these tests:

['assert n_common_words("python is a programming language",1)==[(\'python\', 1)]', 'assert n_common_words("python is a programming language",1)==[(\'python\', 1)]', 'assert n_common_words("python is a programming language",5)==[(\'python\', 1),(\'is\', 1), (\'a\', 1), (\'programming\', 1), (\'language\', 1)]']
[BEGIN]

Response:
from collections import Counter
import re
def n_common_words(text,n):
  words = re.findall('\w+',text)
  n_common_words= Counter(words).most_common(n)
  return list(n_common_words)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.

 Your code should pass these tests:

['assert find_longest_conseq_subseq([1, 2, 2, 3], 4) == 3', 'assert find_longest_conseq_subseq([1, 9, 3, 10, 4, 20, 2], 7) == 4', 'assert find_longest_conseq_subseq([36, 41, 56, 35, 44, 33, 34, 92, 43, 32, 42], 11) == 5']
[BEGIN]

Response:
def find_longest_conseq_subseq(arr, n):
	ans = 0
	count = 0
	arr.sort()
	v = []
	v.append(arr[0])
	for i in range(1, n):
		if (arr[i] != arr[i - 1]):
			v.append(arr[i])
	for i in range(len(v)):
		if (i > 0 and v[i] == v[i - 1] + 1):
			count += 1
		else:
			count = 1
		ans = max(ans, count)
	return ans
[DONE]


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

 Your code should pass these tests:

['assert palindrome_lambda(["php", "res", "Python", "abcd", "Java", "aaa"])==[\'php\', \'aaa\']', 'assert palindrome_lambda(["abcd", "Python", "abba", "aba"])==[\'abba\', \'aba\']', 'assert palindrome_lambda(["abcd", "abbccbba", "abba", "aba"])==[\'abbccbba\', \'abba\', \'aba\']']
[BEGIN]

Response:
def palindrome_lambda(texts):
  result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
  return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to print n-times a list using map function.

 Your code should pass these tests:

['assert ntimes_list([1, 2, 3, 4, 5, 6, 7],3)==[3, 6, 9, 12, 15, 18, 21]', 'assert ntimes_list([1, 2, 3, 4, 5, 6, 7],4)==[4, 8, 12, 16, 20, 24, 28]', 'assert ntimes_list([1, 2, 3, 4, 5, 6, 7],10)==[10, 20, 30, 40, 50, 60, 70]']
[BEGIN]

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


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

 Your code should pass these tests:

['assert check_monthnumb("February")==False', 'assert check_monthnumb("January")==True', 'assert check_monthnumb("March")==True']
[BEGIN]

Response:
def check_monthnumb(monthname2):
  if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"):
    return True
  else:
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to add a minimum number such that the sum of array becomes even.

 Your code should pass these tests:

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

Response:
def min_Num(arr,n):
    odd = 0
    for i in range(n):
        if (arr[i] % 2):
            odd += 1
    if (odd % 2):
        return 1
    return 2
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the length of the last word in a given string.

 Your code should pass these tests:

['assert length_Of_Last_Word("python language") == 8', 'assert length_Of_Last_Word("PHP") == 3', 'assert length_Of_Last_Word("") == 0']
[BEGIN]

Response:
def length_Of_Last_Word(a):
    l = 0
    x = a.strip()
    for i in range(len(x)):
        if x[i] == " ":
            l = 0
        else:
            l += 1
    return l
[DONE]


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

 Your code should pass these tests:

['assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],13,17)==[[13, 14, 15, 17]]', 'assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],1,3)==[[2], [1, 2, 3]]', 'assert remove_list_range([[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7], [9, 11], [13, 14, 15, 17]],0,7)==[[2], [0], [1, 2, 3], [0, 1, 2, 3, 6, 7]]']
[BEGIN]

Response:
def remove_list_range(list1, leftrange, rigthrange):
   result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]
   return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.

 Your code should pass these tests:

['assert sum_positivenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==48', 'assert sum_positivenum([10,15,-14,13,-18,12,-20])==50', 'assert sum_positivenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==522']
[BEGIN]

Response:
def sum_positivenum(nums):
  sum_positivenum = list(filter(lambda nums:nums>0,nums))
  return sum(sum_positivenum)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the given strings are rotations of each other or not.

 Your code should pass these tests:

['assert are_Rotations("abc","cba") == False', 'assert are_Rotations("abcd","cdba") == False', 'assert are_Rotations("abacd","cdaba") == True']
[BEGIN]

Response:
def are_Rotations(string1,string2):
    size1 = len(string1)
    size2 = len(string2)
    temp = ''
    if size1 != size2:
        return False
    temp = string1 + string1
    if (temp.count(string2)> 0):
        return True
    else:
        return False
[DONE]


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

 Your code should pass these tests:

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

Response:
def check_subset(list1,list2):
    return all(map(list1.__contains__,list2))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to solve the fibonacci sequence using recursion.

 Your code should pass these tests:

['assert fibonacci(7) == 13', 'assert fibonacci(8) == 21', 'assert fibonacci(9) == 34']
[BEGIN]

Response:
def fibonacci(n):
  if n == 1 or n == 2:
    return 1
  else:
    return (fibonacci(n - 1) + (fibonacci(n - 2)))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check if the string is a concatenation of another string.

 Your code should pass these tests:

['assert check_Concat("abcabcabc","abc") == True', 'assert check_Concat("abcab","abc") == False', 'assert check_Concat("aba","ab") == False']
[BEGIN]

Response:
def check_Concat(str1,str2):
    N = len(str1)
    M = len(str2)
    if (N % M != 0):
        return False
    for i in range(N):
        if (str1[i] != str2[i % M]):
            return False
    return True
[DONE]


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

 Your code should pass these tests:

['assert min_difference([(3, 5), (1, 7), (10, 3), (1, 2)]) == 1', 'assert min_difference([(4, 6), (12, 8), (11, 4), (2, 13)]) == 2', 'assert min_difference([(5, 17), (3, 9), (12, 5), (3, 24)]) == 6']
[BEGIN]

Response:
def min_difference(test_list):
  temp = [abs(b - a) for a, b in test_list]
  res = min(temp)
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find lcm of two positive integers.

 Your code should pass these tests:

['assert lcm(4,6) == 12', 'assert lcm(15,17) == 255', 'assert lcm(2,6) == 6']
[BEGIN]

Response:
def lcm(x, y):
   if x > y:
       z = x
   else:
       z = y
   while(True):
       if((z % x == 0) and (z % y == 0)):
           lcm = z
           break
       z += 1
   return lcm
[DONE]


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

 Your code should pass these tests:

['assert sort_String("cba") == "abc"', 'assert sort_String("data") == "aadt"', 'assert sort_String("zxy") == "xyz"']
[BEGIN]

Response:
def sort_String(str) :
    str = ''.join(sorted(str))
    return (str)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if the given tuple contains only k elements.

 Your code should pass these tests:

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

Response:
def check_tuples(test_tuple, K):
  res = all(ele in K for ele in test_tuple)
  return (res)
[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 anything, ending in 'b' by using regex.

 Your code should pass these tests:

['assert text_match("aabbbbd") == \'Not matched!\'', 'assert text_match("aabAbbbc") == \'Not matched!\'', 'assert text_match("accddbbjjjb") == \'Found a match!\'']
[BEGIN]

Response:
import re
def text_match(text):
  patterns = 'a.*?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 find number of solutions in quadratic equation.

 Your code should pass these tests:

['assert Check_Solution(2,5,2) == "2 solutions"', 'assert Check_Solution(1,1,1) == "No solutions"', 'assert Check_Solution(1,2,1) == "1 solution"']
[BEGIN]

Response:
def Check_Solution(a,b,c) :
    if ((b*b) - (4*a*c)) > 0 :
        return ("2 solutions")
    elif ((b*b) - (4*a*c)) == 0 :
        return ("1 solution")
    else :
        return ("No solutions")
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the sum of first even and odd number of a given list.

 Your code should pass these tests:

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

Response:
def sum_even_odd(list1):
    first_even = next((el for el in list1 if el%2==0),-1)
    first_odd = next((el for el in list1 if el%2!=0),-1)
    return (first_even+first_odd)
[DONE]


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

 Your code should pass these tests:

['assert parallelogram_perimeter(10,20)==400', 'assert parallelogram_perimeter(15,20)==600', 'assert parallelogram_perimeter(8,9)==144']
[BEGIN]

Response:
def parallelogram_perimeter(b,h):
  perimeter=2*(b*h)
  return perimeter
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find numbers divisible by m and n from a list of numbers using lambda function.

 Your code should pass these tests:

['assert div_of_nums([19, 65, 57, 39, 152, 639, 121, 44, 90, 190],2,4)==[ 152,44]', 'assert div_of_nums([1, 2, 3, 5, 7, 8, 10],2,5)==[10]', 'assert div_of_nums([10,15,14,13,18,12,20],10,5)==[10,20]']
[BEGIN]

Response:
def div_of_nums(nums,m,n):
 result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums))
 return result
[DONE]


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

 Your code should pass these tests:

['assert all_Bits_Set_In_The_Given_Range(10,2,1) == True ', 'assert all_Bits_Set_In_The_Given_Range(5,2,4) == False', 'assert all_Bits_Set_In_The_Given_Range(22,2,3) == True ']
[BEGIN]

Response:
def all_Bits_Set_In_The_Given_Range(n,l,r):
    num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1)
    new_num = n & num
    if (num == new_num):
        return True
    return False
[DONE]


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

 Your code should pass these tests:

['assert is_Isomorphic("paper","title") == True', 'assert is_Isomorphic("ab","ba") == True', 'assert is_Isomorphic("ab","aa") == False']
[BEGIN]

Response:
def is_Isomorphic(str1,str2):
    dict_str1 = {}
    dict_str2 = {}
    for i, value in enumerate(str1):
        dict_str1[value] = dict_str1.get(value,[]) + [i]
    for j, value in enumerate(str2):
        dict_str2[value] = dict_str2.get(value,[]) + [j]
    if sorted(dict_str1.values()) == sorted(dict_str2.values()):
        return True
    else:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to add all the numbers in a list and divide it with the length of the list.

 Your code should pass these tests:

['assert sum_num((8, 2, 3, 0, 7))==4.0', 'assert sum_num((-10,-20,-30))==-20.0', 'assert sum_num((19,15,18))==17.333333333333332']
[BEGIN]

Response:
def sum_num(numbers):
    total = 0
    for x in numbers:
        total += x
    return total/len(numbers)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the given number is odd or not using bitwise operator.

 Your code should pass these tests:

['assert is_odd(5) == True', 'assert is_odd(6) == False', 'assert is_odd(7) == True']
[BEGIN]

Response:
def is_odd(n) :
    if (n^1 == n-1) :
        return True;
    else :
        return False;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to substract the elements of the given nested tuples.

 Your code should pass these tests:

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

Response:
def substract_elements(test_tup1, test_tup2):
  res = tuple(tuple(a - b for a, b in zip(tup1, tup2))
   for tup1, tup2 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 reverse each list in a given list of lists.

 Your code should pass these tests:

['assert reverse_list_lists([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [13, 14, 15, 16]])==[[4, 3, 2, 1], [8, 7, 6, 5], [12, 11, 10, 9], [16, 15, 14, 13]]', 'assert reverse_list_lists([[1,2],[2,3],[3,4]])==[[2,1],[3,2],[4,3]]', 'assert reverse_list_lists([[10,20],[30,40]])==[[20,10],[40,30]]']
[BEGIN]

Response:
def reverse_list_lists(lists):
    for l in lists:
        l.sort(reverse = True)
    return lists
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to find the index of an extra element present in one sorted array.

 Your code should pass these tests:

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

Response:
def find_Extra(arr1,arr2,n) :
    for i in range(0, n) :
        if (arr1[i] != arr2[i]) :
            return i
    return n
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the given two numbers have same number of digits or not.

 Your code should pass these tests:

['assert same_Length(12,1) == False', 'assert same_Length(2,2) == True', 'assert same_Length(10,20) == True']
[BEGIN]

Response:
def same_Length(A,B):
    while (A > 0 and B > 0):
        A = A / 10;
        B = B / 10;
    if (A == 0 and B == 0):
        return True;
    return False;
[DONE]


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

 Your code should pass these tests:

["assert remove_spaces('python  program')==('python program')", "assert remove_spaces('python   programming    language')==('python programming language')", "assert remove_spaces('python                     program')==('python program')"]
[BEGIN]

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


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to get the last element of each sublist.

 Your code should pass these tests:

['assert Extract([[1, 2, 3], [4, 5], [6, 7, 8, 9]]) == [3, 5, 9]', "assert Extract([['x', 'y', 'z'], ['m'], ['a', 'b'], ['u', 'v']]) == ['z', 'm', 'b', 'v']", 'assert Extract([[1, 2, 3], [4, 5]]) == [3, 5]']
[BEGIN]

Response:
def Extract(lst):
    return [item[-1] for item in lst]
[DONE]


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

 Your code should pass these tests:

['assert float_to_tuple("1.2, 1.3, 2.3, 2.4, 6.5") == (1.2, 1.3, 2.3, 2.4, 6.5)', 'assert float_to_tuple("2.3, 2.4, 5.6, 5.4, 8.9") == (2.3, 2.4, 5.6, 5.4, 8.9)', 'assert float_to_tuple("0.3, 0.5, 7.8, 9.4") == (0.3, 0.5, 7.8, 9.4)']
[BEGIN]

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


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the maximum sum of subsequences of given array with no adjacent elements.

 Your code should pass these tests:

['assert max_sum_subseq([1, 2, 9, 4, 5, 0, 4, 11, 6]) == 26', 'assert max_sum_subseq([1, 2, 9, 5, 6, 0, 5, 12, 7]) == 28', 'assert max_sum_subseq([1, 3, 10, 5, 6, 0, 6, 14, 21]) == 44']
[BEGIN]

Response:
def max_sum_subseq(A):
    n = len(A)
    if n == 1:
        return A[0]
    look_up = [None] * n
    look_up[0] = A[0]
    look_up[1] = max(A[0], A[1])
    for i in range(2, n):
        look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i])
        look_up[i] = max(look_up[i], A[i])
    return look_up[n - 1]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort a list in increasing order by the last element in each tuple from a given list of non-empty tuples.

 Your code should pass these tests:

['assert sort_list_last([(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)])==[(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)] ', 'assert sort_list_last([(9,8), (4, 7), (3,5), (7,9), (1,2)])==[(1,2), (3,5), (4,7), (9,8), (7,9)] ', 'assert sort_list_last([(20,50), (10,20), (40,40)])==[(10,20),(40,40),(20,50)] ']
[BEGIN]

Response:
def last(n):
   return n[-1]
def sort_list_last(tuples):
  return sorted(tuples, key=last)
[DONE]


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

 Your code should pass these tests:

['assert is_Word_Present("machine learning","machine") == True', 'assert is_Word_Present("easy","fun") == False', 'assert is_Word_Present("python language","code") == False']
[BEGIN]

Response:
def is_Word_Present(sentence,word):
    s = sentence.split(" ")
    for i in s:
        if (i == word):
            return True
    return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to extract specified number of elements from a given list, which follow each other continuously.

 Your code should pass these tests:

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

Response:
from itertools import groupby
def extract_elements(numbers, n):
    result = [i for i, j in groupby(numbers) if len(list(j)) == n]
    return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether an array can be sorted or not by picking only the corner elements.

 Your code should pass these tests:

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

Response:
def check(arr,n):
    g = 0
    for i in range(1,n):
        if (arr[i] - arr[i - 1] > 0 and g == 1):
            return False
        if (arr[i] - arr[i] < 0):
            g = 1
    return True
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function where a string will start with a specific number.

 Your code should pass these tests:

["assert match_num('5-2345861')==True", "assert match_num('6-2345861')==False", "assert match_num('78910')==False"]
[BEGIN]

Response:
import re
def match_num(string):
    text = re.compile(r"^5")
    if text.match(string):
        return True
    else:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the smallest multiple of the first n numbers.

 Your code should pass these tests:

['assert smallest_multiple(13)==360360', 'assert smallest_multiple(2)==2', 'assert smallest_multiple(1)==1']
[BEGIN]

Response:
def smallest_multiple(n):
    if (n<=2):
      return n
    i = n * 2
    factors = [number  for number in range(n, 1, -1) if number * 2 > n]
    while True:
        for a in factors:
            if i % a != 0:
                i += n
                break
            if (a == factors[-1] and i % a == 0):
                return i
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to combine two dictionaries by adding values for common keys.

 Your code should pass these tests:

["assert add_dict({'a': 100, 'b': 200, 'c':300},{'a': 300, 'b': 200, 'd':400})==({'b': 400, 'd': 400, 'a': 400, 'c': 300}) ", "assert add_dict({'a': 500, 'b': 700, 'c':900},{'a': 500, 'b': 600, 'd':900})==({'b': 1300, 'd': 900, 'a': 1000, 'c': 900}) ", "assert add_dict({'a':900,'b':900,'d':900},{'a':900,'b':900,'d':900})==({'b': 1800, 'd': 1800, 'a': 1800})"]
[BEGIN]

Response:
from collections import Counter
def add_dict(d1,d2):
   add_dict = Counter(d1) + Counter(d2)
   return add_dict
[DONE]


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

 Your code should pass these tests:

['assert count_Unset_Bits(2) == 1', 'assert count_Unset_Bits(5) == 4', 'assert count_Unset_Bits(14) == 17']
[BEGIN]

Response:
def count_Unset_Bits(n) :
    cnt = 0;
    for i in range(1,n + 1) :
        temp = i;
        while (temp) :
            if (temp % 2 == 0) :
                cnt += 1;
            temp = temp // 2;
    return cnt;
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to return true if the given number is even else return false.

 Your code should pass these tests:

['assert even_num(13.5)==False', 'assert even_num(0)==True', 'assert even_num(-9)==False']
[BEGIN]

Response:
def even_num(x):
  if x%2==0:
     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 sum of squares of binomial co-efficients.

 Your code should pass these tests:

['assert sum_of_square(4) == 70', 'assert sum_of_square(5) == 252', 'assert sum_of_square(2) == 6']
[BEGIN]

Response:
def factorial(start,end):
    res = 1
    for i in range(start,end + 1):
        res *= i
    return res
def sum_of_square(n):
   return int(factorial(n + 1, 2 * n)  /factorial(1, n))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to extract year, month and date from a url by using regex.

 Your code should pass these tests:

['assert extract_date("https://www.washingtonpost.com/news/football-insider/wp/2016/09/02/odell-beckhams-fame-rests-on-one-stupid-little-ball-josh-norman-tells-author/") == [(\'2016\', \'09\', \'02\')]', 'assert extract_date("https://www.indiatoday.in/movies/celebrities/story/wp/2020/11/03/odeof-sushant-singh-rajput-s-death-his-brother-in-law-shares-advice-for-fans-1749646/") == [(\'2020\', \'11\', \'03\')]', 'assert extract_date("https://economictimes.indiatimes.com/news/economy/2020/12/29/finance/pension-assets-under-pfrda-touch-rs-5-32-lakh-crore/articleshow/79736619.cms") == [(\'2020\', \'12\', \'29\')]']
[BEGIN]

Response:
import re
def extract_date(url):
        return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to print the first n lucky numbers.

 Your code should pass these tests:

['assert lucky_num(10)==[1, 3, 7, 9, 13, 15, 21, 25, 31, 33] ', 'assert lucky_num(5)==[1, 3, 7, 9, 13]', 'assert lucky_num(8)==[1, 3, 7, 9, 13, 15, 21, 25]']
[BEGIN]

Response:
def lucky_num(n):
 List=range(-1,n*n+9,2)
 i=2
 while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1
 return List[1:n+1]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the fixed point in the given array.

 Your code should pass these tests:

['assert find_fixed_point([-10, -1, 0, 3, 10, 11, 30, 50, 100],9) == 3', 'assert find_fixed_point([1, 2, 3, 4, 5, 6, 7, 8],8) == -1', 'assert find_fixed_point([0, 2, 5, 8, 17],5) == 0']
[BEGIN]

Response:
def find_fixed_point(arr, n):
	for i in range(n):
		if arr[i] is i:
			return i
	return -1
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the previous palindrome of a specified number.

 Your code should pass these tests:

['assert previous_palindrome(99)==88', 'assert previous_palindrome(1221)==1111', 'assert previous_palindrome(120)==111']
[BEGIN]

Response:
def previous_palindrome(num):
    for x in range(num-1,0,-1):
        if str(x) == str(x)[::-1]:
            return x
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to validate a gregorian date.

 Your code should pass these tests:

['assert check_date(11,11,2002)==True', 'assert check_date(13,11,2002)==False', "assert check_date('11','11','2002')==True"]
[BEGIN]

Response:
import datetime
def check_date(m, d, y):
    try:
        m, d, y = map(int, (m, d, y))
        datetime.date(y, m, d)
        return True
    except ValueError:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.

 Your code should pass these tests:

['assert maximum_product( [12, 74, 9, 50, 61, 41])==225700', 'assert maximum_product([25, 35, 22, 85, 14, 65, 75, 25, 58])==414375', 'assert maximum_product([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1])==2520']
[BEGIN]

Response:
def maximum_product(nums):
    import heapq
    a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)
    return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])
[DONE]


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

 Your code should pass these tests:

['assert int(lobb_num(5, 3)) == 35', 'assert int(lobb_num(3, 2)) == 5', 'assert int(lobb_num(4, 2)) == 20']
[BEGIN]

Response:
def binomial_coeff(n, k):
	C = [[0 for j in range(k + 1)]
			for i in range(n + 1)]
	for i in range(0, n + 1):
		for j in range(0, min(i, k) + 1):
			if (j == 0 or j == i):
				C[i][j] = 1
			else:
				C[i][j] = (C[i - 1][j - 1]
							+ C[i - 1][j])
	return C[n][k]
def lobb_num(n, m):
	return (((2 * m + 1) *
		binomial_coeff(2 * n, m + n))
					/ (m + n + 1))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check for a number at the end of a string.

 Your code should pass these tests:

["assert end_num('abcdef')==False", "assert end_num('abcdef7')==True", "assert end_num('abc')==False"]
[BEGIN]

Response:
import re
def end_num(string):
    text = re.compile(r".*[0-9]$")
    if text.match(string):
        return True
    else:
        return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to check whether the given string is made up of two alternating characters or not.

 Your code should pass these tests:

['assert is_Two_Alter("abab") == True', 'assert is_Two_Alter("aaaa") == False', 'assert is_Two_Alter("xyz") == False']
[BEGIN]

Response:
def is_Two_Alter(s):
    for i in range (len( s) - 2) :
        if (s[i] != s[i + 2]) :
            return False
    if (s[0] == s[1]):
        return False
    return True
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to rearrange positive and negative numbers in a given array using lambda function.

 Your code should pass these tests:

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

Response:
def rearrange_numbs(array_nums):
  result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
  return result
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find if there is a triplet in the array whose sum is equal to a given value.

 Your code should pass these tests:

['assert find_triplet_array([1, 4, 45, 6, 10, 8], 6, 22) == (4, 10, 8)', 'assert find_triplet_array([12, 3, 5, 2, 6, 9], 6, 24) == (12, 3, 9)', 'assert find_triplet_array([1, 2, 3, 4, 5], 5, 9) == (1, 3, 5)']
[BEGIN]

Response:
def find_triplet_array(A, arr_size, sum):
	for i in range( 0, arr_size-2):
		for j in range(i + 1, arr_size-1):
			for k in range(j + 1, arr_size):
				if A[i] + A[j] + A[k] == sum:
					return  A[i],A[j],A[k]
					return True
	return False
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the sequences of one upper case letter followed by lower case letters.

 Your code should pass these tests:

['assert text_uppercase_lowercase("AaBbGg")==(\'Found a match!\')', 'assert text_uppercase_lowercase("aA")==(\'Not matched!\')', 'assert text_uppercase_lowercase("PYTHON")==(\'Not matched!\')']
[BEGIN]

Response:
import re
def text_uppercase_lowercase(text):
        patterns = '[A-Z]+[a-z]+$'
        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 coin change.

 Your code should pass these tests:

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

Response:
def coin_change(S, m, n):
    table = [[0 for x in range(m)] for x in range(n+1)]
    for i in range(m):
        table[0][i] = 1
    for i in range(1, n+1):
        for j in range(m):
            x = table[i - S[j]][j] if i-S[j] >= 0 else 0
            y = table[i][j-1] if j >= 1 else 0
            table[i][j] = x + y
    return table[n][m-1]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to multiply all items in the list.

 Your code should pass these tests:

['assert multiply_list([1,-2,3]) == -6', 'assert multiply_list([1,2,3,4]) == 24', 'assert multiply_list([3,1,2,3]) == 18']
[BEGIN]

Response:
def multiply_list(items):
    tot = 1
    for x in items:
        tot *= x
    return tot
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove all tuples with all none values in the given tuple list.

 Your code should pass these tests:

["assert remove_tuple([(None, 2), (None, None), (3, 4), (12, 3), (None, )] ) == '[(None, 2), (3, 4), (12, 3)]'", "assert remove_tuple([(None, None), (None, None), (3, 6), (17, 3), (None,1 )] ) == '[(3, 6), (17, 3), (None, 1)]'", "assert remove_tuple([(1, 2), (2, None), (3, None), (24, 3), (None, None )] ) == '[(1, 2), (2, None), (3, None), (24, 3)]'"]
[BEGIN]

Response:
def remove_tuple(test_list):
  res = [sub for sub in test_list if not all(ele == None for ele in sub)]
  return (str(res))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to perform chunking of tuples each of size n.

 Your code should pass these tests:

['assert chunk_tuples((10, 4, 5, 6, 7, 6, 8, 3, 4), 3) == [(10, 4, 5), (6, 7, 6), (8, 3, 4)]', 'assert chunk_tuples((1, 2, 3, 4, 5, 6, 7, 8, 9), 2) == [(1, 2), (3, 4), (5, 6), (7, 8), (9,)]', 'assert chunk_tuples((11, 14, 16, 17, 19, 21, 22, 25), 4) == [(11, 14, 16, 17), (19, 21, 22, 25)]']
[BEGIN]

Response:
def chunk_tuples(test_tup, N):
  res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find a pair with the highest product from a given array of integers.

 Your code should pass these tests:

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

Response:
def max_product(arr):
    arr_len = len(arr)
    if (arr_len < 2):
        return None
    x = arr[0]; y = arr[1]
    for i in range(0, arr_len):
        for j in range(i + 1, arr_len):
            if (arr[i] * arr[j] > x * y):
                x = arr[i]; y = arr[j]
    return x,y
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.

 Your code should pass these tests:

['assert super_seq("AGGTAB", "GXTXAYB", 6, 7) == 9', 'assert super_seq("feek", "eke", 4, 3) == 5', 'assert super_seq("PARRT", "RTA", 5, 3) == 6']
[BEGIN]

Response:
def super_seq(X, Y, m, n):
	if (not m):
		return n
	if (not n):
		return m
	if (X[m - 1] == Y[n - 1]):
		return 1 + super_seq(X, Y, m - 1, n - 1)
	return 1 + min(super_seq(X, Y, m - 1, n),	super_seq(X, Y, m, n - 1))
[DONE]


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

 Your code should pass these tests:

['assert max_of_two(10,20)==20', 'assert max_of_two(19,15)==19', 'assert max_of_two(-10,-20)==-10']
[BEGIN]

Response:
def max_of_two( x, y ):
    if x > y:
        return x
    return y
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a python function to calculate the product of all the numbers of a given tuple.

 Your code should pass these tests:

['assert mutiple_tuple((4, 3, 2, 2, -1, 18)) == -864', 'assert mutiple_tuple((1,2,3)) == 6', 'assert mutiple_tuple((-2,-4,-6)) == -48']
[BEGIN]

Response:
def mutiple_tuple(nums):
    temp = list(nums)
    product = 1
    for x in temp:
        product *= x
    return product
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find n-th rencontres number.

 Your code should pass these tests:

['assert rencontres_number(7, 2) == 924', 'assert rencontres_number(3, 0) == 2', 'assert rencontres_number(3, 1) == 3']
[BEGIN]

Response:
def binomial_coeffi(n, k):
	if (k == 0 or k == n):
		return 1
	return (binomial_coeffi(n - 1, k - 1)
		+ binomial_coeffi(n - 1, k))
def rencontres_number(n, m):
	if (n == 0 and m == 0):
		return 1
	if (n == 1 and m == 0):
		return 0
	if (m == 0):
		return ((n - 1) * (rencontres_number(n - 1, 0)+ rencontres_number(n - 2, 0)))
	return (binomial_coeffi(n, m) * rencontres_number(n - m, 0))
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate the height of the given binary tree.

 Your test setup code:
root = Node(1)
root.left = Node(2)
root.right = Node(3)
root.left.left = Node(4)
root.left.right = Node(5)
root1 = Node(1);
root1.left = Node(2);
root1.right = Node(3);
root1.left.left = Node(4);
root1.right.left = Node(5);
root1.right.right = Node(6);
root1.right.right.right= Node(7);
root1.right.right.right.right = Node(8)
root2 = Node(1)
root2.left = Node(2)
root2.right = Node(3)
root2.left.left = Node(4)
root2.left.right = Node(5)
root2.left.left.left = Node(6)
root2.left.left.right = Node(7)

 Your code should pass these tests:

['assert (max_height(root)) == 3', 'assert (max_height(root1)) == 5 ', 'assert (max_height(root2)) == 4']
[BEGIN]

Response:
class Node:
	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None
def max_height(node):
	if node is None:
		return 0 ;
	else :
		left_height = max_height(node.left)
		right_height = max_height(node.right)
		if (left_height > right_height):
			return left_height+1
		else:
			return right_height+1
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.

 Your code should pass these tests:

["assert change_date_format('2026-01-02')=='02-01-2026'", "assert change_date_format('2021-01-04')=='04-01-2021'", "assert change_date_format('2030-06-06')=='06-06-2030'"]
[BEGIN]

Response:
import re
def change_date_format(dt):
        return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt)
        return change_date_format(dt)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count repeated items of a tuple.

 Your code should pass these tests:

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

Response:
def count_tuplex(tuplex,value):
  count = tuplex.count(value)
  return count
[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 by using regex.

 Your code should pass these tests:

['assert text_match("msb") == \'Not matched!\'', 'assert text_match("a0c") == \'Found a match!\'', 'assert text_match("abbc") == \'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 calculate the sum of series 1³+2³+3³+….+n³.

 Your code should pass these tests:

['assert sum_series(7)==784', 'assert sum_series(5)==225', 'assert sum_series(15)==14400']
[BEGIN]

Response:
import math
def sum_series(number):
 total = 0
 total = math.pow((number * (number + 1)) /2, 2)
 return total
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to remove duplicate words from a given list of strings.

 Your code should pass these tests:

['assert remove_duplic_list(["Python", "Exercises", "Practice", "Solution", "Exercises"])==[\'Python\', \'Exercises\', \'Practice\', \'Solution\']', 'assert remove_duplic_list(["Python", "Exercises", "Practice", "Solution", "Exercises","Java"])==[\'Python\', \'Exercises\', \'Practice\', \'Solution\', \'Java\']', 'assert remove_duplic_list(["Python", "Exercises", "Practice", "Solution", "Exercises","C++","C","C++"])==[\'Python\', \'Exercises\', \'Practice\', \'Solution\',\'C++\',\'C\']']
[BEGIN]

Response:
def remove_duplic_list(l):
    temp = []
    for x in l:
        if x not in temp:
            temp.append(x)
    return temp
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to convert camel case string to snake case string by using regex.

 Your code should pass these tests:

["assert camel_to_snake('GoogleAssistant') == 'google_assistant'", "assert camel_to_snake('ChromeCast') == 'chrome_cast'", "assert camel_to_snake('QuadCore') == 'quad_core'"]
[BEGIN]

Response:
import re
def camel_to_snake(text):
  str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
  return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()
[DONE]


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

 Your code should pass these tests:

['assert dealnnoy_num(3, 4) == 129', 'assert dealnnoy_num(3, 3) == 63', 'assert dealnnoy_num(4, 5) == 681']
[BEGIN]

Response:
def dealnnoy_num(n, m):
	if (m == 0 or n == 0) :
		return 1
	return dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to calculate the sum of series 1²+2²+3²+….+n².

 Your code should pass these tests:

['assert series_sum(6)==91', 'assert series_sum(7)==140', 'assert series_sum(12)==650']
[BEGIN]

Response:
def series_sum(number):
 total = 0
 total = (number * (number + 1) * (2 * number + 1)) / 6
 return total
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to re-arrange the given tuples based on the given ordered list.

 Your code should pass these tests:

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

Response:
def re_arrange_tuples(test_list, ord_list):
  temp = dict(test_list)
  res = [(key, temp[key]) for key in ord_list]
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count the most common character in a given string.

 Your code should pass these tests:

['assert max_char("hello world")==(\'l\')', 'assert max_char("hello ")==(\'l\')', 'assert max_char("python pr")==(\'p\')']
[BEGIN]

Response:
from collections import Counter
def max_char(str1):
    temp = Counter(str1)
    max_char = max(temp, key = temp.get)
    return max_char
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to find three closest elements from three sorted arrays.

 Your code should pass these tests:

['assert find_closet([1, 4, 10],[2, 15, 20],[10, 12],3,3,2) == (10, 15, 10)', 'assert find_closet([20, 24, 100],[2, 19, 22, 79, 800],[10, 12, 23, 24, 119],3,5,5) == (24, 22, 23)', 'assert find_closet([2, 5, 11],[3, 16, 21],[11, 13],3,3,2) == (11, 16, 11)']
[BEGIN]

Response:
import sys

def find_closet(A, B, C, p, q, r):
	diff = sys.maxsize
	res_i = 0
	res_j = 0
	res_k = 0
	i = 0
	j = 0
	k = 0
	while(i < p and j < q and k < r):
		minimum = min(A[i], min(B[j], C[k]))
		maximum = max(A[i], max(B[j], C[k]));
		if maximum-minimum < diff:
			res_i = i
			res_j = j
			res_k = k
			diff = maximum - minimum;
		if diff == 0:
			break
		if A[i] == minimum:
			i = i+1
		elif B[j] == minimum:
			j = j+1
		else:
			k = k+1
	return A[res_i],B[res_j],C[res_k]
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort a list of dictionaries using lambda function.

 Your code should pass these tests:

["assert sorted_models([{'make':'Nokia', 'model':216, 'color':'Black'}, {'make':'Mi Max', 'model':2, 'color':'Gold'}, {'make':'Samsung', 'model': 7, 'color':'Blue'}])==[{'make': 'Nokia', 'model': 216, 'color': 'Black'}, {'make': 'Samsung', 'model': 7, 'color': 'Blue'}, {'make': 'Mi Max', 'model': 2, 'color': 'Gold'}]", "assert sorted_models([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])==([{'make':'Vivo', 'model':20,'color':'Blue'},{'make': 'oppo','model':17,'color':'Gold'},{'make':'Apple','model':11,'color':'red'}])", "assert sorted_models([{'make':'micromax','model':40,'color':'grey'},{'make':'poco','model':60,'color':'blue'}])==([{'make':'poco','model':60,'color':'blue'},{'make':'micromax','model':40,'color':'grey'}])"]
[BEGIN]

Response:
def sorted_models(models):
 sorted_models = sorted(models, key = lambda x: x['color'])
 return sorted_models
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to sort the given array by using heap sort.

 Your code should pass these tests:

['assert heap_sort([12, 2, 4, 5, 2, 3]) == [2, 2, 3, 4, 5, 12]', 'assert heap_sort([32, 14, 5, 6, 7, 19]) == [5, 6, 7, 14, 19, 32]', 'assert heap_sort([21, 15, 29, 78, 65]) == [15, 21, 29, 65, 78]']
[BEGIN]

Response:
def heap_sort(arr):
    heapify(arr)
    end = len(arr) - 1
    while end > 0:
        arr[end], arr[0] = arr[0], arr[end]
        shift_down(arr, 0, end - 1)
        end -= 1
    return arr

def heapify(arr):
    start = len(arr) // 2
    while start >= 0:
        shift_down(arr, start, len(arr) - 1)
        start -= 1
def shift_down(arr, start, end):
    root = start
    while root * 2 + 1 <= end:
        child = root * 2 + 1
        if child + 1 <= end and arr[child] < arr[child + 1]:
            child += 1
        if child <= end and arr[root] < arr[child]:
            arr[root], arr[child] = arr[child], arr[root]
            root = child
        else:
            return

[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to count the elements in a list until an element is a tuple.

 Your code should pass these tests:

['assert count_elim([10,20,30,(10,20),40])==3', 'assert count_elim([10,(20,30),(10,20),40])==1', 'assert count_elim([(10,(20,30,(10,20),40))])==0']
[BEGIN]

Response:
def count_elim(num):
  count_elim = 0
  for n in num:
    if isinstance(n, tuple):
        break
    count_elim += 1
  return count_elim
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to check if any list element is present in the given list.

 Your code should pass these tests:

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

Response:
def check_element(test_tup, check_list):
  res = False
  for ele in check_list:
    if ele in test_tup:
      res = True
      break
  return (res)
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to combine two given sorted lists using heapq module.

 Your code should pass these tests:

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

Response:
from heapq import merge
def combine_lists(num1,num2):
  combine_lists=list(merge(num1, num2))
  return combine_lists
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to separate and print the numbers and their position of a given string.

 Your code should pass these tests:

['assert num_position("there are 70 flats in this apartment")==10', 'assert num_position("every adult have 32 teeth")==17', 'assert num_position("isha has 79 chocolates in her bag")==9']
[BEGIN]

Response:
import re
def num_position(text):
 for m in re.finditer("\d+", text):
    return m.start()
[DONE]


Prompt:
You are an expert Python programmer, and here is your task:
Write a function to convert the given tuples into set.

 Your code should pass these tests:

["assert tuple_to_set(('x', 'y', 'z') ) == {'y', 'x', 'z'}", "assert tuple_to_set(('a', 'b', 'c') ) == {'c', 'a', 'b'}", "assert tuple_to_set(('z', 'd', 'e') ) == {'d', 'e', 'z'}"]
[BEGIN]

Response:
def tuple_to_set(t):
  s = set(t)
  return (s)
[DONE]