task_name
stringclasses 1
value | src_lang
stringclasses 1
value | tgt_lang
stringclasses 1
value | data_id
stringlengths 10
12
| demos
listlengths 0
0
| compare_func
listlengths 0
0
| dataset_name
stringclasses 1
value | suffix
stringlengths 0
672
| test_cases
listlengths 0
5
| entry_func
stringlengths 3
31
| import_str
listlengths 0
1
| doc_string
stringlengths 39
252
| prefix
stringlengths 80
786
| solution
stringlengths 11
142
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
code_infilling
|
python
|
python
|
MBPP/428/L8
|
[] |
[] |
MBPP_Infilling
|
my_list[j] = current_item
gap //= 2
return my_list
|
[
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] |
shell_sort
|
[] |
Write a function to sort the given array by using shell sort.
|
def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
|
j -= gap
|
code_infilling
|
python
|
python
|
MBPP/428/L9
|
[] |
[] |
MBPP_Infilling
|
gap //= 2
return my_list
|
[
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] |
shell_sort
|
[] |
Write a function to sort the given array by using shell sort.
|
def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
|
my_list[j] = current_item
|
code_infilling
|
python
|
python
|
MBPP/428/L10
|
[] |
[] |
MBPP_Infilling
|
return my_list
|
[
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] |
shell_sort
|
[] |
Write a function to sort the given array by using shell sort.
|
def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
|
gap //= 2
|
code_infilling
|
python
|
python
|
MBPP/428/L11
|
[] |
[] |
MBPP_Infilling
|
[
[
"[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]",
"[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]"
],
[
"[24, 22, 39, 34, 87, 73, 68]",
"[22, 24, 34, 39, 68, 73, 87]"
],
[
"[32, 30, 16, 96, 82, 83, 74]",
"[16, 30, 32, 74, 82, 83, 96]"
]
] |
shell_sort
|
[] |
Write a function to sort the given array by using shell sort.
|
def shell_sort(my_list):
"""Write a function to sort the given array by using shell sort. """
gap = len(my_list) // 2
while gap > 0:
for i in range(gap, len(my_list)):
current_item = my_list[i]
j = i
while j >= gap and my_list[j - gap] > current_item:
my_list[j] = my_list[j - gap]
j -= gap
my_list[j] = current_item
gap //= 2
|
return my_list
|
|
code_infilling
|
python
|
python
|
MBPP/429/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"(10, 4, 6, 9), (5, 2, 3, 3)",
"(0, 0, 2, 1)"
],
[
"(1, 2, 3, 4), (5, 6, 7, 8)",
"(1, 2, 3, 0)"
],
[
"(8, 9, 11, 12), (7, 13, 14, 17)",
"(0, 9, 10, 0)"
]
] |
and_tuples
|
[] |
Write a function to extract the elementwise and tuples from the given two tuples.
|
def and_tuples(test_tup1, test_tup2):
"""Write a function to extract the elementwise and tuples from the given two tuples. """
|
res = tuple((ele1 & ele2 for (ele1, ele2) in zip(test_tup1, test_tup2)))
|
code_infilling
|
python
|
python
|
MBPP/429/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"(10, 4, 6, 9), (5, 2, 3, 3)",
"(0, 0, 2, 1)"
],
[
"(1, 2, 3, 4), (5, 6, 7, 8)",
"(1, 2, 3, 0)"
],
[
"(8, 9, 11, 12), (7, 13, 14, 17)",
"(0, 9, 10, 0)"
]
] |
and_tuples
|
[] |
Write a function to extract the elementwise and tuples from the given two tuples.
|
def and_tuples(test_tup1, test_tup2):
"""Write a function to extract the elementwise and tuples from the given two tuples. """
res = tuple((ele1 & ele2 for (ele1, ele2) in zip(test_tup1, test_tup2)))
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/430/L1
|
[] |
[] |
MBPP_Infilling
|
return directrix
|
[
[
"5,3,2",
"-198"
],
[
"9,8,4",
"-2336"
],
[
"2,4,6",
"-130"
]
] |
parabola_directrix
|
[] |
Write a function to find the directrix of a parabola.
|
def parabola_directrix(a, b, c):
"""Write a function to find the directrix of a parabola. """
|
directrix = int(c - (b * b + 1) * 4 * a)
|
code_infilling
|
python
|
python
|
MBPP/430/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"5,3,2",
"-198"
],
[
"9,8,4",
"-2336"
],
[
"2,4,6",
"-130"
]
] |
parabola_directrix
|
[] |
Write a function to find the directrix of a parabola.
|
def parabola_directrix(a, b, c):
"""Write a function to find the directrix of a parabola. """
directrix = int(c - (b * b + 1) * 4 * a)
|
return directrix
|
|
code_infilling
|
python
|
python
|
MBPP/431/L1
|
[] |
[] |
MBPP_Infilling
|
for x in list1:
for y in list2:
if x == y:
result = True
return result
|
[
[
"[1,2,3,4,5], [5,6,7,8,9]",
"True"
],
[
"[1,2,3,4,5], [6,7,8,9]",
null
],
[
"['a','b','c'], ['d','b','e']",
"True"
]
] |
common_element
|
[] |
Write a function that takes two lists and returns true if they have at least one common element.
|
def common_element(list1, list2):
"""Write a function that takes two lists and returns true if they have at least one common element. """
|
result = False
|
code_infilling
|
python
|
python
|
MBPP/431/L2
|
[] |
[] |
MBPP_Infilling
|
for y in list2:
if x == y:
result = True
return result
|
[
[
"[1,2,3,4,5], [5,6,7,8,9]",
"True"
],
[
"[1,2,3,4,5], [6,7,8,9]",
null
],
[
"['a','b','c'], ['d','b','e']",
"True"
]
] |
common_element
|
[] |
Write a function that takes two lists and returns true if they have at least one common element.
|
def common_element(list1, list2):
"""Write a function that takes two lists and returns true if they have at least one common element. """
result = False
|
for x in list1:
|
code_infilling
|
python
|
python
|
MBPP/431/L3
|
[] |
[] |
MBPP_Infilling
|
if x == y:
result = True
return result
|
[
[
"[1,2,3,4,5], [5,6,7,8,9]",
"True"
],
[
"[1,2,3,4,5], [6,7,8,9]",
null
],
[
"['a','b','c'], ['d','b','e']",
"True"
]
] |
common_element
|
[] |
Write a function that takes two lists and returns true if they have at least one common element.
|
def common_element(list1, list2):
"""Write a function that takes two lists and returns true if they have at least one common element. """
result = False
for x in list1:
|
for y in list2:
|
code_infilling
|
python
|
python
|
MBPP/431/L4
|
[] |
[] |
MBPP_Infilling
|
result = True
return result
|
[
[
"[1,2,3,4,5], [5,6,7,8,9]",
"True"
],
[
"[1,2,3,4,5], [6,7,8,9]",
null
],
[
"['a','b','c'], ['d','b','e']",
"True"
]
] |
common_element
|
[] |
Write a function that takes two lists and returns true if they have at least one common element.
|
def common_element(list1, list2):
"""Write a function that takes two lists and returns true if they have at least one common element. """
result = False
for x in list1:
for y in list2:
|
if x == y:
|
code_infilling
|
python
|
python
|
MBPP/431/L5
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"[1,2,3,4,5], [5,6,7,8,9]",
"True"
],
[
"[1,2,3,4,5], [6,7,8,9]",
null
],
[
"['a','b','c'], ['d','b','e']",
"True"
]
] |
common_element
|
[] |
Write a function that takes two lists and returns true if they have at least one common element.
|
def common_element(list1, list2):
"""Write a function that takes two lists and returns true if they have at least one common element. """
result = False
for x in list1:
for y in list2:
if x == y:
|
result = True
|
code_infilling
|
python
|
python
|
MBPP/431/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,2,3,4,5], [5,6,7,8,9]",
"True"
],
[
"[1,2,3,4,5], [6,7,8,9]",
null
],
[
"['a','b','c'], ['d','b','e']",
"True"
]
] |
common_element
|
[] |
Write a function that takes two lists and returns true if they have at least one common element.
|
def common_element(list1, list2):
"""Write a function that takes two lists and returns true if they have at least one common element. """
result = False
for x in list1:
for y in list2:
if x == y:
result = True
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/432/L1
|
[] |
[] |
MBPP_Infilling
|
return median
|
[
[
"15,25,35",
"20"
],
[
"10,20,30",
"15"
],
[
"6,9,4",
"7.5"
]
] |
median_trapezium
|
[] |
Write a function to find the median length of a trapezium.
|
def median_trapezium(base1, base2, height):
"""Write a function to find the median length of a trapezium. """
|
median = 0.5 * (base1 + base2)
|
code_infilling
|
python
|
python
|
MBPP/432/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"15,25,35",
"20"
],
[
"10,20,30",
"15"
],
[
"6,9,4",
"7.5"
]
] |
median_trapezium
|
[] |
Write a function to find the median length of a trapezium.
|
def median_trapezium(base1, base2, height):
"""Write a function to find the median length of a trapezium. """
median = 0.5 * (base1 + base2)
|
return median
|
|
code_infilling
|
python
|
python
|
MBPP/433/L1
|
[] |
[] |
MBPP_Infilling
|
return number > arr[-1]
|
[
[
"[1, 2, 3, 4, 5], 4",
"False"
],
[
"[2, 3, 4, 5, 6], 8",
"True"
],
[
"[9, 7, 4, 8, 6, 1], 11",
"True"
]
] |
check_greater
|
[] |
Write a function to check whether the entered number is greater than the elements of the given array.
|
def check_greater(arr, number):
"""Write a function to check whether the entered number is greater than the elements of the given array. """
|
arr.sort()
|
code_infilling
|
python
|
python
|
MBPP/433/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1, 2, 3, 4, 5], 4",
"False"
],
[
"[2, 3, 4, 5, 6], 8",
"True"
],
[
"[9, 7, 4, 8, 6, 1], 11",
"True"
]
] |
check_greater
|
[] |
Write a function to check whether the entered number is greater than the elements of the given array.
|
def check_greater(arr, number):
"""Write a function to check whether the entered number is greater than the elements of the given array. """
arr.sort()
|
return number > arr[-1]
|
|
code_infilling
|
python
|
python
|
MBPP/434/L3
|
[] |
[] |
MBPP_Infilling
|
if re.search(patterns, text):
return True
else:
return False
|
[
[
"\"ac\"",
"False"
],
[
"\"dc\"",
"False"
],
[
"\"abba\"",
"True"
]
] |
text_match_one
|
[
"import re"
] |
Write a function that matches a string that has an a followed by one or more b's.
|
import re
def text_match_one(text):
"""Write a function that matches a string that has an a followed by one or more b's. """
|
patterns = 'ab+?'
|
code_infilling
|
python
|
python
|
MBPP/434/L4
|
[] |
[] |
MBPP_Infilling
|
return True
else:
return False
|
[
[
"\"ac\"",
"False"
],
[
"\"dc\"",
"False"
],
[
"\"abba\"",
"True"
]
] |
text_match_one
|
[
"import re"
] |
Write a function that matches a string that has an a followed by one or more b's.
|
import re
def text_match_one(text):
"""Write a function that matches a string that has an a followed by one or more b's. """
patterns = 'ab+?'
|
if re.search(patterns, text):
|
code_infilling
|
python
|
python
|
MBPP/434/L5
|
[] |
[] |
MBPP_Infilling
|
else:
return False
|
[
[
"\"ac\"",
"False"
],
[
"\"dc\"",
"False"
],
[
"\"abba\"",
"True"
]
] |
text_match_one
|
[
"import re"
] |
Write a function that matches a string that has an a followed by one or more b's.
|
import re
def text_match_one(text):
"""Write a function that matches a string that has an a followed by one or more b's. """
patterns = 'ab+?'
if re.search(patterns, text):
|
return True
|
code_infilling
|
python
|
python
|
MBPP/434/L6
|
[] |
[] |
MBPP_Infilling
|
return False
|
[
[
"\"ac\"",
"False"
],
[
"\"dc\"",
"False"
],
[
"\"abba\"",
"True"
]
] |
text_match_one
|
[
"import re"
] |
Write a function that matches a string that has an a followed by one or more b's.
|
import re
def text_match_one(text):
"""Write a function that matches a string that has an a followed by one or more b's. """
patterns = 'ab+?'
if re.search(patterns, text):
return True
|
else:
|
code_infilling
|
python
|
python
|
MBPP/434/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"ac\"",
"False"
],
[
"\"dc\"",
"False"
],
[
"\"abba\"",
"True"
]
] |
text_match_one
|
[
"import re"
] |
Write a function that matches a string that has an a followed by one or more b's.
|
import re
def text_match_one(text):
"""Write a function that matches a string that has an a followed by one or more b's. """
patterns = 'ab+?'
if re.search(patterns, text):
return True
else:
|
return False
|
|
code_infilling
|
python
|
python
|
MBPP/435/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"123",
"3"
],
[
"25",
"5"
],
[
"30",
"0"
]
] |
last_Digit
|
[] |
Write a python function to find the last digit of a given number.
|
def last_Digit(n):
"""Write a python function to find the last digit of a given number. """
|
return n % 10
|
|
code_infilling
|
python
|
python
|
MBPP/436/L1
|
[] |
[] |
MBPP_Infilling
|
for num in list1:
if num < 0:
out.append(num)
return out
|
[
[
"[-1,4,5,-6]",
"[-1,-6]"
],
[
"[-1,-2,3,4]",
"[-1,-2]"
],
[
"[-7,-6,8,9]",
"[-7,-6]"
]
] |
neg_nos
|
[] |
Write a python function to return the negative numbers in a list.
|
def neg_nos(list1):
"""Write a python function to return the negative numbers in a list. """
|
out = []
|
code_infilling
|
python
|
python
|
MBPP/436/L2
|
[] |
[] |
MBPP_Infilling
|
if num < 0:
out.append(num)
return out
|
[
[
"[-1,4,5,-6]",
"[-1,-6]"
],
[
"[-1,-2,3,4]",
"[-1,-2]"
],
[
"[-7,-6,8,9]",
"[-7,-6]"
]
] |
neg_nos
|
[] |
Write a python function to return the negative numbers in a list.
|
def neg_nos(list1):
"""Write a python function to return the negative numbers in a list. """
out = []
|
for num in list1:
|
code_infilling
|
python
|
python
|
MBPP/436/L3
|
[] |
[] |
MBPP_Infilling
|
out.append(num)
return out
|
[
[
"[-1,4,5,-6]",
"[-1,-6]"
],
[
"[-1,-2,3,4]",
"[-1,-2]"
],
[
"[-7,-6,8,9]",
"[-7,-6]"
]
] |
neg_nos
|
[] |
Write a python function to return the negative numbers in a list.
|
def neg_nos(list1):
"""Write a python function to return the negative numbers in a list. """
out = []
for num in list1:
|
if num < 0:
|
code_infilling
|
python
|
python
|
MBPP/436/L4
|
[] |
[] |
MBPP_Infilling
|
return out
|
[
[
"[-1,4,5,-6]",
"[-1,-6]"
],
[
"[-1,-2,3,4]",
"[-1,-2]"
],
[
"[-7,-6,8,9]",
"[-7,-6]"
]
] |
neg_nos
|
[] |
Write a python function to return the negative numbers in a list.
|
def neg_nos(list1):
"""Write a python function to return the negative numbers in a list. """
out = []
for num in list1:
if num < 0:
|
out.append(num)
|
code_infilling
|
python
|
python
|
MBPP/436/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"[-1,4,5,-6]",
"[-1,-6]"
],
[
"[-1,-2,3,4]",
"[-1,-2]"
],
[
"[-7,-6,8,9]",
"[-7,-6]"
]
] |
neg_nos
|
[] |
Write a python function to return the negative numbers in a list.
|
def neg_nos(list1):
"""Write a python function to return the negative numbers in a list. """
out = []
for num in list1:
if num < 0:
out.append(num)
|
return out
|
|
code_infilling
|
python
|
python
|
MBPP/437/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(1, len(str1) + 1):
if i % 2 == 0:
str2 = str2 + str1[i - 1]
return str2
|
[
[
"\"python\"",
"(\"yhn\")"
],
[
"\"program\"",
"(\"rga\")"
],
[
"\"language\"",
"(\"agae\")"
]
] |
remove_odd
|
[] |
Write a function to remove odd characters in a string.
|
def remove_odd(str1):
"""Write a function to remove odd characters in a string. """
|
str2 = ''
|
code_infilling
|
python
|
python
|
MBPP/437/L2
|
[] |
[] |
MBPP_Infilling
|
if i % 2 == 0:
str2 = str2 + str1[i - 1]
return str2
|
[
[
"\"python\"",
"(\"yhn\")"
],
[
"\"program\"",
"(\"rga\")"
],
[
"\"language\"",
"(\"agae\")"
]
] |
remove_odd
|
[] |
Write a function to remove odd characters in a string.
|
def remove_odd(str1):
"""Write a function to remove odd characters in a string. """
str2 = ''
|
for i in range(1, len(str1) + 1):
|
code_infilling
|
python
|
python
|
MBPP/437/L3
|
[] |
[] |
MBPP_Infilling
|
str2 = str2 + str1[i - 1]
return str2
|
[
[
"\"python\"",
"(\"yhn\")"
],
[
"\"program\"",
"(\"rga\")"
],
[
"\"language\"",
"(\"agae\")"
]
] |
remove_odd
|
[] |
Write a function to remove odd characters in a string.
|
def remove_odd(str1):
"""Write a function to remove odd characters in a string. """
str2 = ''
for i in range(1, len(str1) + 1):
|
if i % 2 == 0:
|
code_infilling
|
python
|
python
|
MBPP/437/L4
|
[] |
[] |
MBPP_Infilling
|
return str2
|
[
[
"\"python\"",
"(\"yhn\")"
],
[
"\"program\"",
"(\"rga\")"
],
[
"\"language\"",
"(\"agae\")"
]
] |
remove_odd
|
[] |
Write a function to remove odd characters in a string.
|
def remove_odd(str1):
"""Write a function to remove odd characters in a string. """
str2 = ''
for i in range(1, len(str1) + 1):
if i % 2 == 0:
|
str2 = str2 + str1[i - 1]
|
code_infilling
|
python
|
python
|
MBPP/437/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"python\"",
"(\"yhn\")"
],
[
"\"program\"",
"(\"rga\")"
],
[
"\"language\"",
"(\"agae\")"
]
] |
remove_odd
|
[] |
Write a function to remove odd characters in a string.
|
def remove_odd(str1):
"""Write a function to remove odd characters in a string. """
str2 = ''
for i in range(1, len(str1) + 1):
if i % 2 == 0:
str2 = str2 + str1[i - 1]
|
return str2
|
|
code_infilling
|
python
|
python
|
MBPP/438/L1
|
[] |
[] |
MBPP_Infilling
|
for idx in range(0, len(test_list)):
for iidx in range(idx + 1, len(test_list)):
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
res += 1
return res
|
[
[
"[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"3"
],
[
"[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"2"
],
[
"[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ",
"4"
]
] |
count_bidirectional
|
[] |
Write a function to count bidirectional tuple pairs.
|
def count_bidirectional(test_list):
"""Write a function to count bidirectional tuple pairs. """
|
res = 0
|
code_infilling
|
python
|
python
|
MBPP/438/L2
|
[] |
[] |
MBPP_Infilling
|
for iidx in range(idx + 1, len(test_list)):
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
res += 1
return res
|
[
[
"[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"3"
],
[
"[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"2"
],
[
"[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ",
"4"
]
] |
count_bidirectional
|
[] |
Write a function to count bidirectional tuple pairs.
|
def count_bidirectional(test_list):
"""Write a function to count bidirectional tuple pairs. """
res = 0
|
for idx in range(0, len(test_list)):
|
code_infilling
|
python
|
python
|
MBPP/438/L3
|
[] |
[] |
MBPP_Infilling
|
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
res += 1
return res
|
[
[
"[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"3"
],
[
"[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"2"
],
[
"[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ",
"4"
]
] |
count_bidirectional
|
[] |
Write a function to count bidirectional tuple pairs.
|
def count_bidirectional(test_list):
"""Write a function to count bidirectional tuple pairs. """
res = 0
for idx in range(0, len(test_list)):
|
for iidx in range(idx + 1, len(test_list)):
|
code_infilling
|
python
|
python
|
MBPP/438/L4
|
[] |
[] |
MBPP_Infilling
|
res += 1
return res
|
[
[
"[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"3"
],
[
"[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"2"
],
[
"[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ",
"4"
]
] |
count_bidirectional
|
[] |
Write a function to count bidirectional tuple pairs.
|
def count_bidirectional(test_list):
"""Write a function to count bidirectional tuple pairs. """
res = 0
for idx in range(0, len(test_list)):
for iidx in range(idx + 1, len(test_list)):
|
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
|
code_infilling
|
python
|
python
|
MBPP/438/L5
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"3"
],
[
"[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"2"
],
[
"[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ",
"4"
]
] |
count_bidirectional
|
[] |
Write a function to count bidirectional tuple pairs.
|
def count_bidirectional(test_list):
"""Write a function to count bidirectional tuple pairs. """
res = 0
for idx in range(0, len(test_list)):
for iidx in range(idx + 1, len(test_list)):
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
|
res += 1
|
code_infilling
|
python
|
python
|
MBPP/438/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"3"
],
[
"[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ",
"2"
],
[
"[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ",
"4"
]
] |
count_bidirectional
|
[] |
Write a function to count bidirectional tuple pairs.
|
def count_bidirectional(test_list):
"""Write a function to count bidirectional tuple pairs. """
res = 0
for idx in range(0, len(test_list)):
for iidx in range(idx + 1, len(test_list)):
if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
res += 1
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/439/L1
|
[] |
[] |
MBPP_Infilling
|
return x
|
[
[
"[11, 33, 50]",
"113350"
],
[
"[-1,2,3,4,5,6]",
"-123456"
],
[
"[10,15,20,25]",
"10152025"
]
] |
multiple_to_single
|
[] |
Write a function to join a list of multiple integers into a single integer.
|
def multiple_to_single(L):
"""Write a function to join a list of multiple integers into a single integer. """
|
x = int(''.join(map(str, L)))
|
code_infilling
|
python
|
python
|
MBPP/439/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[11, 33, 50]",
"113350"
],
[
"[-1,2,3,4,5,6]",
"-123456"
],
[
"[10,15,20,25]",
"10152025"
]
] |
multiple_to_single
|
[] |
Write a function to join a list of multiple integers into a single integer.
|
def multiple_to_single(L):
"""Write a function to join a list of multiple integers into a single integer. """
x = int(''.join(map(str, L)))
|
return x
|
|
code_infilling
|
python
|
python
|
MBPP/440/L3
|
[] |
[] |
MBPP_Infilling
|
return (m.start(), m.end(), m.group(0))
|
[
[
"\"clearly!! we can see the sky\"",
"(0, 7, 'clearly')"
],
[
"\"seriously!! there are many roses\"",
"(0, 9, 'seriously')"
],
[
"\"unfortunately!! sita is going to home\"",
"(0, 13, 'unfortunately')"
]
] |
find_adverb_position
|
[
"import re"
] |
Write a function to find the first adverb and their positions in a given sentence.
|
import re
def find_adverb_position(text):
"""Write a function to find the first adverb and their positions in a given sentence. """
|
for m in re.finditer('\\w+ly', text):
|
code_infilling
|
python
|
python
|
MBPP/440/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"\"clearly!! we can see the sky\"",
"(0, 7, 'clearly')"
],
[
"\"seriously!! there are many roses\"",
"(0, 9, 'seriously')"
],
[
"\"unfortunately!! sita is going to home\"",
"(0, 13, 'unfortunately')"
]
] |
find_adverb_position
|
[
"import re"
] |
Write a function to find the first adverb and their positions in a given sentence.
|
import re
def find_adverb_position(text):
"""Write a function to find the first adverb and their positions in a given sentence. """
for m in re.finditer('\\w+ly', text):
|
return (m.start(), m.end(), m.group(0))
|
|
code_infilling
|
python
|
python
|
MBPP/441/L1
|
[] |
[] |
MBPP_Infilling
|
return surfacearea
|
[
[
"5",
"150"
],
[
"3",
"54"
],
[
"10",
"600"
]
] |
surfacearea_cube
|
[] |
Write a function to find the surface area of a cube of a given size.
|
def surfacearea_cube(l):
"""Write a function to find the surface area of a cube of a given size. """
|
surfacearea = 6 * l * l
|
code_infilling
|
python
|
python
|
MBPP/441/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"5",
"150"
],
[
"3",
"54"
],
[
"10",
"600"
]
] |
surfacearea_cube
|
[] |
Write a function to find the surface area of a cube of a given size.
|
def surfacearea_cube(l):
"""Write a function to find the surface area of a cube of a given size. """
surfacearea = 6 * l * l
|
return surfacearea
|
|
code_infilling
|
python
|
python
|
MBPP/442/L3
|
[] |
[] |
MBPP_Infilling
|
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
None
return round(n1 / n, 2)
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
|
n = len(nums)
|
code_infilling
|
python
|
python
|
MBPP/442/L4
|
[] |
[] |
MBPP_Infilling
|
for x in nums:
if x > 0:
n1 += 1
else:
None
return round(n1 / n, 2)
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
n = len(nums)
|
n1 = 0
|
code_infilling
|
python
|
python
|
MBPP/442/L5
|
[] |
[] |
MBPP_Infilling
|
if x > 0:
n1 += 1
else:
None
return round(n1 / n, 2)
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
n = len(nums)
n1 = 0
|
for x in nums:
|
code_infilling
|
python
|
python
|
MBPP/442/L6
|
[] |
[] |
MBPP_Infilling
|
n1 += 1
else:
None
return round(n1 / n, 2)
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
|
if x > 0:
|
code_infilling
|
python
|
python
|
MBPP/442/L7
|
[] |
[] |
MBPP_Infilling
|
else:
None
return round(n1 / n, 2)
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
|
n1 += 1
|
code_infilling
|
python
|
python
|
MBPP/442/L8
|
[] |
[] |
MBPP_Infilling
|
None
return round(n1 / n, 2)
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
|
else:
|
code_infilling
|
python
|
python
|
MBPP/442/L9
|
[] |
[] |
MBPP_Infilling
|
return round(n1 / n, 2)
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
|
None
|
code_infilling
|
python
|
python
|
MBPP/442/L10
|
[] |
[] |
MBPP_Infilling
|
[
[
"[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]",
"0.54"
],
[
"[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]",
"0.69"
],
[
"[2, 4, -6, -9, 11, -12, 14, -5, 17]",
"0.56"
]
] |
positive_count
|
[
"from array import array"
] |
Write a function to find the ration of positive numbers in an array of integers.
|
from array import array
def positive_count(nums):
"""Write a function to find the ration of positive numbers in an array of integers. """
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
None
|
return round(n1 / n, 2)
|
|
code_infilling
|
python
|
python
|
MBPP/443/L1
|
[] |
[] |
MBPP_Infilling
|
for x in list1:
if x < max:
max = x
return max
|
[
[
"[1,2,3,-4,-6]",
"-6"
],
[
"[1,2,3,-8,-9]",
"-9"
],
[
"[1,2,3,4,-1]",
"-1"
]
] |
largest_neg
|
[] |
Write a python function to find the largest negative number from the given list.
|
def largest_neg(list1):
"""Write a python function to find the largest negative number from the given list. """
|
max = list1[0]
|
code_infilling
|
python
|
python
|
MBPP/443/L2
|
[] |
[] |
MBPP_Infilling
|
if x < max:
max = x
return max
|
[
[
"[1,2,3,-4,-6]",
"-6"
],
[
"[1,2,3,-8,-9]",
"-9"
],
[
"[1,2,3,4,-1]",
"-1"
]
] |
largest_neg
|
[] |
Write a python function to find the largest negative number from the given list.
|
def largest_neg(list1):
"""Write a python function to find the largest negative number from the given list. """
max = list1[0]
|
for x in list1:
|
code_infilling
|
python
|
python
|
MBPP/443/L3
|
[] |
[] |
MBPP_Infilling
|
max = x
return max
|
[
[
"[1,2,3,-4,-6]",
"-6"
],
[
"[1,2,3,-8,-9]",
"-9"
],
[
"[1,2,3,4,-1]",
"-1"
]
] |
largest_neg
|
[] |
Write a python function to find the largest negative number from the given list.
|
def largest_neg(list1):
"""Write a python function to find the largest negative number from the given list. """
max = list1[0]
for x in list1:
|
if x < max:
|
code_infilling
|
python
|
python
|
MBPP/443/L4
|
[] |
[] |
MBPP_Infilling
|
return max
|
[
[
"[1,2,3,-4,-6]",
"-6"
],
[
"[1,2,3,-8,-9]",
"-9"
],
[
"[1,2,3,4,-1]",
"-1"
]
] |
largest_neg
|
[] |
Write a python function to find the largest negative number from the given list.
|
def largest_neg(list1):
"""Write a python function to find the largest negative number from the given list. """
max = list1[0]
for x in list1:
if x < max:
|
max = x
|
code_infilling
|
python
|
python
|
MBPP/443/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,2,3,-4,-6]",
"-6"
],
[
"[1,2,3,-8,-9]",
"-9"
],
[
"[1,2,3,4,-1]",
"-1"
]
] |
largest_neg
|
[] |
Write a python function to find the largest negative number from the given list.
|
def largest_neg(list1):
"""Write a python function to find the largest negative number from the given list. """
max = list1[0]
for x in list1:
if x < max:
max = x
|
return max
|
|
code_infilling
|
python
|
python
|
MBPP/444/L1
|
[] |
[] |
MBPP_Infilling
|
for ele in test_list:
N = len(ele)
res.append(tuple(list(ele)[K:N - K]))
return str(res)
|
[
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2",
"'[(2,), (9,), (2,), (2,)]'"
],
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1",
"'[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'"
],
[
"[(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1",
"'[(8, 4), (8, 12), (1, 7), (6, 9)]'"
]
] |
trim_tuple
|
[] |
Write a function to trim each tuple by k in the given tuple list.
|
def trim_tuple(test_list, K):
"""Write a function to trim each tuple by k in the given tuple list. """
|
res = []
|
code_infilling
|
python
|
python
|
MBPP/444/L2
|
[] |
[] |
MBPP_Infilling
|
N = len(ele)
res.append(tuple(list(ele)[K:N - K]))
return str(res)
|
[
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2",
"'[(2,), (9,), (2,), (2,)]'"
],
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1",
"'[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'"
],
[
"[(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1",
"'[(8, 4), (8, 12), (1, 7), (6, 9)]'"
]
] |
trim_tuple
|
[] |
Write a function to trim each tuple by k in the given tuple list.
|
def trim_tuple(test_list, K):
"""Write a function to trim each tuple by k in the given tuple list. """
res = []
|
for ele in test_list:
|
code_infilling
|
python
|
python
|
MBPP/444/L3
|
[] |
[] |
MBPP_Infilling
|
res.append(tuple(list(ele)[K:N - K]))
return str(res)
|
[
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2",
"'[(2,), (9,), (2,), (2,)]'"
],
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1",
"'[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'"
],
[
"[(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1",
"'[(8, 4), (8, 12), (1, 7), (6, 9)]'"
]
] |
trim_tuple
|
[] |
Write a function to trim each tuple by k in the given tuple list.
|
def trim_tuple(test_list, K):
"""Write a function to trim each tuple by k in the given tuple list. """
res = []
for ele in test_list:
|
N = len(ele)
|
code_infilling
|
python
|
python
|
MBPP/444/L4
|
[] |
[] |
MBPP_Infilling
|
return str(res)
|
[
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2",
"'[(2,), (9,), (2,), (2,)]'"
],
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1",
"'[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'"
],
[
"[(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1",
"'[(8, 4), (8, 12), (1, 7), (6, 9)]'"
]
] |
trim_tuple
|
[] |
Write a function to trim each tuple by k in the given tuple list.
|
def trim_tuple(test_list, K):
"""Write a function to trim each tuple by k in the given tuple list. """
res = []
for ele in test_list:
N = len(ele)
|
res.append(tuple(list(ele)[K:N - K]))
|
code_infilling
|
python
|
python
|
MBPP/444/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2",
"'[(2,), (9,), (2,), (2,)]'"
],
[
"[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1",
"'[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'"
],
[
"[(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1",
"'[(8, 4), (8, 12), (1, 7), (6, 9)]'"
]
] |
trim_tuple
|
[] |
Write a function to trim each tuple by k in the given tuple list.
|
def trim_tuple(test_list, K):
"""Write a function to trim each tuple by k in the given tuple list. """
res = []
for ele in test_list:
N = len(ele)
res.append(tuple(list(ele)[K:N - K]))
|
return str(res)
|
|
code_infilling
|
python
|
python
|
MBPP/445/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ",
"((6, 21), (12, 45), (2, 9), (7, 30))"
],
[
"((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ",
"((14, 32), (20, 60), (6, 20), (16, 44))"
],
[
"((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ",
"((24, 45), (30, 77), (12, 33), (27, 60))"
]
] |
index_multiplication
|
[] |
Write a function to perform index wise multiplication of tuple elements in the given two tuples.
|
def index_multiplication(test_tup1, test_tup2):
"""Write a function to perform index wise multiplication of tuple elements in the given two tuples. """
|
res = tuple((tuple((a * b for (a, b) in zip(tup1, tup2))) for (tup1, tup2) in zip(test_tup1, test_tup2)))
|
code_infilling
|
python
|
python
|
MBPP/445/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ",
"((6, 21), (12, 45), (2, 9), (7, 30))"
],
[
"((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ",
"((14, 32), (20, 60), (6, 20), (16, 44))"
],
[
"((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ",
"((24, 45), (30, 77), (12, 33), (27, 60))"
]
] |
index_multiplication
|
[] |
Write a function to perform index wise multiplication of tuple elements in the given two tuples.
|
def index_multiplication(test_tup1, test_tup2):
"""Write a function to perform index wise multiplication of tuple elements in the given two tuples. """
res = tuple((tuple((a * b for (a, b) in zip(tup1, tup2))) for (tup1, tup2) in zip(test_tup1, test_tup2)))
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/446/L3
|
[] |
[] |
MBPP_Infilling
|
for item in tup:
if item in lst:
count += 1
return count
|
[
[
"('a', 'a', 'c', 'b', 'd'),['a', 'b'] ",
"3"
],
[
"(1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]",
"6"
],
[
"(1,2,3,4,5,6),[1,2]",
"2"
]
] |
count_Occurrence
|
[
"from collections import Counter "
] |
Write a python function to count the occurence of all elements of list in a tuple.
|
from collections import Counter
def count_Occurrence(tup, lst):
"""Write a python function to count the occurence of all elements of list in a tuple. """
|
count = 0
|
code_infilling
|
python
|
python
|
MBPP/446/L4
|
[] |
[] |
MBPP_Infilling
|
if item in lst:
count += 1
return count
|
[
[
"('a', 'a', 'c', 'b', 'd'),['a', 'b'] ",
"3"
],
[
"(1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]",
"6"
],
[
"(1,2,3,4,5,6),[1,2]",
"2"
]
] |
count_Occurrence
|
[
"from collections import Counter "
] |
Write a python function to count the occurence of all elements of list in a tuple.
|
from collections import Counter
def count_Occurrence(tup, lst):
"""Write a python function to count the occurence of all elements of list in a tuple. """
count = 0
|
for item in tup:
|
code_infilling
|
python
|
python
|
MBPP/446/L5
|
[] |
[] |
MBPP_Infilling
|
count += 1
return count
|
[
[
"('a', 'a', 'c', 'b', 'd'),['a', 'b'] ",
"3"
],
[
"(1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]",
"6"
],
[
"(1,2,3,4,5,6),[1,2]",
"2"
]
] |
count_Occurrence
|
[
"from collections import Counter "
] |
Write a python function to count the occurence of all elements of list in a tuple.
|
from collections import Counter
def count_Occurrence(tup, lst):
"""Write a python function to count the occurence of all elements of list in a tuple. """
count = 0
for item in tup:
|
if item in lst:
|
code_infilling
|
python
|
python
|
MBPP/446/L6
|
[] |
[] |
MBPP_Infilling
|
return count
|
[
[
"('a', 'a', 'c', 'b', 'd'),['a', 'b'] ",
"3"
],
[
"(1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]",
"6"
],
[
"(1,2,3,4,5,6),[1,2]",
"2"
]
] |
count_Occurrence
|
[
"from collections import Counter "
] |
Write a python function to count the occurence of all elements of list in a tuple.
|
from collections import Counter
def count_Occurrence(tup, lst):
"""Write a python function to count the occurence of all elements of list in a tuple. """
count = 0
for item in tup:
if item in lst:
|
count += 1
|
code_infilling
|
python
|
python
|
MBPP/446/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"('a', 'a', 'c', 'b', 'd'),['a', 'b'] ",
"3"
],
[
"(1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]",
"6"
],
[
"(1,2,3,4,5,6),[1,2]",
"2"
]
] |
count_Occurrence
|
[
"from collections import Counter "
] |
Write a python function to count the occurence of all elements of list in a tuple.
|
from collections import Counter
def count_Occurrence(tup, lst):
"""Write a python function to count the occurence of all elements of list in a tuple. """
count = 0
for item in tup:
if item in lst:
count += 1
|
return count
|
|
code_infilling
|
python
|
python
|
MBPP/447/L1
|
[] |
[] |
MBPP_Infilling
|
return cube_nums
|
[
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]"
],
[
"[10,20,30]",
"([1000, 8000, 27000])"
],
[
"[12,15]",
"([1728, 3375])"
]
] |
cube_nums
|
[] |
Write a function to find cubes of individual elements in a list.
|
def cube_nums(nums):
"""Write a function to find cubes of individual elements in a list. """
|
cube_nums = list(map(lambda x: x ** 3, nums))
|
code_infilling
|
python
|
python
|
MBPP/447/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]",
"[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]"
],
[
"[10,20,30]",
"([1000, 8000, 27000])"
],
[
"[12,15]",
"([1728, 3375])"
]
] |
cube_nums
|
[] |
Write a function to find cubes of individual elements in a list.
|
def cube_nums(nums):
"""Write a function to find cubes of individual elements in a list. """
cube_nums = list(map(lambda x: x ** 3, nums))
|
return cube_nums
|
|
code_infilling
|
python
|
python
|
MBPP/448/L1
|
[] |
[] |
MBPP_Infilling
|
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
|
a = 3
|
code_infilling
|
python
|
python
|
MBPP/448/L2
|
[] |
[] |
MBPP_Infilling
|
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
|
b = 0
|
code_infilling
|
python
|
python
|
MBPP/448/L3
|
[] |
[] |
MBPP_Infilling
|
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
|
c = 2
|
code_infilling
|
python
|
python
|
MBPP/448/L4
|
[] |
[] |
MBPP_Infilling
|
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
|
if n == 0:
|
code_infilling
|
python
|
python
|
MBPP/448/L5
|
[] |
[] |
MBPP_Infilling
|
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
|
return 3
|
code_infilling
|
python
|
python
|
MBPP/448/L6
|
[] |
[] |
MBPP_Infilling
|
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
|
if n == 1:
|
code_infilling
|
python
|
python
|
MBPP/448/L7
|
[] |
[] |
MBPP_Infilling
|
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
|
return 3
|
code_infilling
|
python
|
python
|
MBPP/448/L8
|
[] |
[] |
MBPP_Infilling
|
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
|
if n == 2:
|
code_infilling
|
python
|
python
|
MBPP/448/L9
|
[] |
[] |
MBPP_Infilling
|
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
|
return 5
|
code_infilling
|
python
|
python
|
MBPP/448/L10
|
[] |
[] |
MBPP_Infilling
|
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
|
sum = 5
|
code_infilling
|
python
|
python
|
MBPP/448/L11
|
[] |
[] |
MBPP_Infilling
|
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
|
while n > 2:
|
code_infilling
|
python
|
python
|
MBPP/448/L12
|
[] |
[] |
MBPP_Infilling
|
sum = sum + d
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
|
d = a + b
|
code_infilling
|
python
|
python
|
MBPP/448/L13
|
[] |
[] |
MBPP_Infilling
|
a = b
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
|
sum = sum + d
|
code_infilling
|
python
|
python
|
MBPP/448/L14
|
[] |
[] |
MBPP_Infilling
|
b = c
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
|
a = b
|
code_infilling
|
python
|
python
|
MBPP/448/L15
|
[] |
[] |
MBPP_Infilling
|
c = d
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
|
b = c
|
code_infilling
|
python
|
python
|
MBPP/448/L16
|
[] |
[] |
MBPP_Infilling
|
n = n - 1
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
|
c = d
|
code_infilling
|
python
|
python
|
MBPP/448/L17
|
[] |
[] |
MBPP_Infilling
|
return sum
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
|
n = n - 1
|
code_infilling
|
python
|
python
|
MBPP/448/L18
|
[] |
[] |
MBPP_Infilling
|
[
[
"9",
"49"
],
[
"10",
"66"
],
[
"11",
"88"
]
] |
cal_sum
|
[] |
Write a function to calculate the sum of perrin numbers.
|
def cal_sum(n):
"""Write a function to calculate the sum of perrin numbers. """
a = 3
b = 0
c = 2
if n == 0:
return 3
if n == 1:
return 3
if n == 2:
return 5
sum = 5
while n > 2:
d = a + b
sum = sum + d
a = b
b = c
c = d
n = n - 1
|
return sum
|
|
code_infilling
|
python
|
python
|
MBPP/450/L1
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"['Python', 'list', 'exercises', 'practice', 'solution'] ,8",
"['practice', 'solution']"
],
[
"['Python', 'list', 'exercises', 'practice', 'solution'] ,6",
"['Python']"
],
[
"['Python', 'list', 'exercises', 'practice', 'solution'] ,9",
"['exercises']"
]
] |
extract_string
|
[] |
Write a function to extract specified size of strings from a given list of string values.
|
def extract_string(str, l):
"""Write a function to extract specified size of strings from a given list of string values. """
|
result = [e for e in str if len(e) == l]
|
code_infilling
|
python
|
python
|
MBPP/450/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"['Python', 'list', 'exercises', 'practice', 'solution'] ,8",
"['practice', 'solution']"
],
[
"['Python', 'list', 'exercises', 'practice', 'solution'] ,6",
"['Python']"
],
[
"['Python', 'list', 'exercises', 'practice', 'solution'] ,9",
"['exercises']"
]
] |
extract_string
|
[] |
Write a function to extract specified size of strings from a given list of string values.
|
def extract_string(str, l):
"""Write a function to extract specified size of strings from a given list of string values. """
result = [e for e in str if len(e) == l]
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/451/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
"' Google Flutter '",
"'GoogleFlutter'"
],
[
"' Google Dart '",
"'GoogleDart'"
],
[
"' iOS Swift '",
"'iOSSwift'"
]
] |
remove_whitespaces
|
[
"import re"
] |
Write a function to remove all whitespaces from the given string.
|
import re
def remove_whitespaces(text1):
"""Write a function to remove all whitespaces from the given string. """
|
return re.sub('\\s+', '', text1)
|
|
code_infilling
|
python
|
python
|
MBPP/452/L1
|
[] |
[] |
MBPP_Infilling
|
amount = sale_amount - actual_cost
return amount
else:
return 0
|
[
[
"1500,1200",
"0"
],
[
"100,200",
"100"
],
[
"2000,5000",
"3000"
]
] |
loss_amount
|
[] |
Write a function that gives loss amount on a sale if the given amount has loss else return 0.
|
def loss_amount(actual_cost, sale_amount):
"""Write a function that gives loss amount on a sale if the given amount has loss else return 0. """
|
if sale_amount > actual_cost:
|
code_infilling
|
python
|
python
|
MBPP/452/L2
|
[] |
[] |
MBPP_Infilling
|
return amount
else:
return 0
|
[
[
"1500,1200",
"0"
],
[
"100,200",
"100"
],
[
"2000,5000",
"3000"
]
] |
loss_amount
|
[] |
Write a function that gives loss amount on a sale if the given amount has loss else return 0.
|
def loss_amount(actual_cost, sale_amount):
"""Write a function that gives loss amount on a sale if the given amount has loss else return 0. """
if sale_amount > actual_cost:
|
amount = sale_amount - actual_cost
|
code_infilling
|
python
|
python
|
MBPP/452/L3
|
[] |
[] |
MBPP_Infilling
|
else:
return 0
|
[
[
"1500,1200",
"0"
],
[
"100,200",
"100"
],
[
"2000,5000",
"3000"
]
] |
loss_amount
|
[] |
Write a function that gives loss amount on a sale if the given amount has loss else return 0.
|
def loss_amount(actual_cost, sale_amount):
"""Write a function that gives loss amount on a sale if the given amount has loss else return 0. """
if sale_amount > actual_cost:
amount = sale_amount - actual_cost
|
return amount
|
code_infilling
|
python
|
python
|
MBPP/452/L4
|
[] |
[] |
MBPP_Infilling
|
return 0
|
[
[
"1500,1200",
"0"
],
[
"100,200",
"100"
],
[
"2000,5000",
"3000"
]
] |
loss_amount
|
[] |
Write a function that gives loss amount on a sale if the given amount has loss else return 0.
|
def loss_amount(actual_cost, sale_amount):
"""Write a function that gives loss amount on a sale if the given amount has loss else return 0. """
if sale_amount > actual_cost:
amount = sale_amount - actual_cost
return amount
|
else:
|
code_infilling
|
python
|
python
|
MBPP/452/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"1500,1200",
"0"
],
[
"100,200",
"100"
],
[
"2000,5000",
"3000"
]
] |
loss_amount
|
[] |
Write a function that gives loss amount on a sale if the given amount has loss else return 0.
|
def loss_amount(actual_cost, sale_amount):
"""Write a function that gives loss amount on a sale if the given amount has loss else return 0. """
if sale_amount > actual_cost:
amount = sale_amount - actual_cost
return amount
else:
|
return 0
|
|
code_infilling
|
python
|
python
|
MBPP/453/L3
|
[] |
[] |
MBPP_Infilling
|
return 0
res = 1
for i in range(2, int(math.sqrt(n)) + 1):
count = 0
curr_sum = 1
curr_term = 1
while n % i == 0:
count = count + 1
n = n // i
if i == 2 and count == 1:
curr_sum = 0
curr_term = curr_term * i
curr_sum = curr_sum + curr_term
res = res * curr_sum
if n >= 2:
res = res * (1 + n)
return res
|
[
[
"18",
"26"
],
[
"30",
"48"
],
[
"6",
"8"
]
] |
sumofFactors
|
[
"import math "
] |
Write a python function to find the sum of even factors of a number.
|
import math
def sumofFactors(n):
"""Write a python function to find the sum of even factors of a number. """
|
if n % 2 != 0:
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.