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/250/L3
|
[] |
[] |
MBPP_Infilling
|
count = count + 1
return count
|
[
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4",
"0"
],
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10",
"3"
],
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8",
"4"
]
] |
count_X
|
[] |
Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.
|
def count_X(tup, x):
"""Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple. """
count = 0
for ele in tup:
|
if ele == x:
|
code_infilling
|
python
|
python
|
MBPP/250/L4
|
[] |
[] |
MBPP_Infilling
|
return count
|
[
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4",
"0"
],
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10",
"3"
],
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8",
"4"
]
] |
count_X
|
[] |
Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.
|
def count_X(tup, x):
"""Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple. """
count = 0
for ele in tup:
if ele == x:
|
count = count + 1
|
code_infilling
|
python
|
python
|
MBPP/250/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4",
"0"
],
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10",
"3"
],
[
"(10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8",
"4"
]
] |
count_X
|
[] |
Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple.
|
def count_X(tup, x):
"""Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple. """
count = 0
for ele in tup:
if ele == x:
count = count + 1
|
return count
|
|
code_infilling
|
python
|
python
|
MBPP/251/L1
|
[] |
[] |
MBPP_Infilling
|
return list
|
[
[
"['Red', 'Green', 'Black'] ,'c'",
"['c', 'Red', 'c', 'Green', 'c', 'Black']"
],
[
"['python', 'java'] ,'program'",
"['program', 'python', 'program', 'java']"
],
[
"['happy', 'sad'] ,'laugh'",
"['laugh', 'happy', 'laugh', 'sad']"
]
] |
insert_element
|
[] |
Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list.
|
def insert_element(list, element):
"""Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list. """
|
list = [v for elt in list for v in (element, elt)]
|
code_infilling
|
python
|
python
|
MBPP/251/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"['Red', 'Green', 'Black'] ,'c'",
"['c', 'Red', 'c', 'Green', 'c', 'Black']"
],
[
"['python', 'java'] ,'program'",
"['program', 'python', 'program', 'java']"
],
[
"['happy', 'sad'] ,'laugh'",
"['laugh', 'happy', 'laugh', 'sad']"
]
] |
insert_element
|
[] |
Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list.
|
def insert_element(list, element):
"""Write a function that takes in a list and an element and inserts the element before each element in the list, and returns the resulting list. """
list = [v for elt in list for v in (element, elt)]
|
return list
|
|
code_infilling
|
python
|
python
|
MBPP/252/L3
|
[] |
[] |
MBPP_Infilling
|
return num
|
[
[
"1",
"(1.0, 0.0)"
],
[
"4",
"(4.0,0.0)"
],
[
"5",
"(5.0,0.0)"
]
] |
convert
|
[
"import cmath "
] |
Write a python function to convert complex numbers to polar coordinates.
|
import cmath
def convert(numbers):
"""Write a python function to convert complex numbers to polar coordinates. """
|
num = cmath.polar(numbers)
|
code_infilling
|
python
|
python
|
MBPP/252/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"1",
"(1.0, 0.0)"
],
[
"4",
"(4.0,0.0)"
],
[
"5",
"(5.0,0.0)"
]
] |
convert
|
[
"import cmath "
] |
Write a python function to convert complex numbers to polar coordinates.
|
import cmath
def convert(numbers):
"""Write a python function to convert complex numbers to polar coordinates. """
num = cmath.polar(numbers)
|
return num
|
|
code_infilling
|
python
|
python
|
MBPP/253/L1
|
[] |
[] |
MBPP_Infilling
|
for i in list1:
if isinstance(i, int):
ctr = ctr + 1
return ctr
|
[
[
"[1,2,'abc',1.2]",
"2"
],
[
"[1,2,3]",
"3"
],
[
"[1,1.2,4,5.1]",
"2"
]
] |
count_integer
|
[] |
Write a python function that returns the number of integer elements in a given list.
|
def count_integer(list1):
"""Write a python function that returns the number of integer elements in a given list. """
|
ctr = 0
|
code_infilling
|
python
|
python
|
MBPP/253/L2
|
[] |
[] |
MBPP_Infilling
|
if isinstance(i, int):
ctr = ctr + 1
return ctr
|
[
[
"[1,2,'abc',1.2]",
"2"
],
[
"[1,2,3]",
"3"
],
[
"[1,1.2,4,5.1]",
"2"
]
] |
count_integer
|
[] |
Write a python function that returns the number of integer elements in a given list.
|
def count_integer(list1):
"""Write a python function that returns the number of integer elements in a given list. """
ctr = 0
|
for i in list1:
|
code_infilling
|
python
|
python
|
MBPP/253/L3
|
[] |
[] |
MBPP_Infilling
|
ctr = ctr + 1
return ctr
|
[
[
"[1,2,'abc',1.2]",
"2"
],
[
"[1,2,3]",
"3"
],
[
"[1,1.2,4,5.1]",
"2"
]
] |
count_integer
|
[] |
Write a python function that returns the number of integer elements in a given list.
|
def count_integer(list1):
"""Write a python function that returns the number of integer elements in a given list. """
ctr = 0
for i in list1:
|
if isinstance(i, int):
|
code_infilling
|
python
|
python
|
MBPP/253/L4
|
[] |
[] |
MBPP_Infilling
|
return ctr
|
[
[
"[1,2,'abc',1.2]",
"2"
],
[
"[1,2,3]",
"3"
],
[
"[1,1.2,4,5.1]",
"2"
]
] |
count_integer
|
[] |
Write a python function that returns the number of integer elements in a given list.
|
def count_integer(list1):
"""Write a python function that returns the number of integer elements in a given list. """
ctr = 0
for i in list1:
if isinstance(i, int):
|
ctr = ctr + 1
|
code_infilling
|
python
|
python
|
MBPP/253/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,2,'abc',1.2]",
"2"
],
[
"[1,2,3]",
"3"
],
[
"[1,1.2,4,5.1]",
"2"
]
] |
count_integer
|
[] |
Write a python function that returns the number of integer elements in a given list.
|
def count_integer(list1):
"""Write a python function that returns the number of integer elements in a given list. """
ctr = 0
for i in list1:
if isinstance(i, int):
ctr = ctr + 1
|
return ctr
|
|
code_infilling
|
python
|
python
|
MBPP/255/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
" [\"Red\",\"Green\",\"Blue\"],1",
"[('Red',), ('Green',), ('Blue',)]"
],
[
" [\"Red\",\"Green\",\"Blue\"],2",
"[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]"
],
[
" [\"Red\",\"Green\",\"Blue\"],3",
"[('Red', 'Red', 'Red'), ('Red', 'Red', 'Green'), ('Red', 'Red', 'Blue'), ('Red', 'Green', 'Green'), ('Red', 'Green', 'Blue'), ('Red', 'Blue', 'Blue'), ('Green', 'Green', 'Green'), ('Green', 'Green', 'Blue'), ('Green', 'Blue', 'Blue'), ('Blue', 'Blue', 'Blue')]"
]
] |
combinations_colors
|
[
"from itertools import combinations_with_replacement "
] |
Write a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination.
|
from itertools import combinations_with_replacement
def combinations_colors(l, n):
"""Write a function that takes in a list and length n, and generates all combinations (with repetition) of the elements of the list and returns a list with a tuple for each combination. """
|
return list(combinations_with_replacement(l, n))
|
|
code_infilling
|
python
|
python
|
MBPP/256/L1
|
[] |
[] |
MBPP_Infilling
|
for num in range(n):
if num <= 1:
continue
for i in range(2, num):
if num % i == 0:
break
else:
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
|
ctr = 0
|
code_infilling
|
python
|
python
|
MBPP/256/L2
|
[] |
[] |
MBPP_Infilling
|
if num <= 1:
continue
for i in range(2, num):
if num % i == 0:
break
else:
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
|
for num in range(n):
|
code_infilling
|
python
|
python
|
MBPP/256/L3
|
[] |
[] |
MBPP_Infilling
|
continue
for i in range(2, num):
if num % i == 0:
break
else:
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
|
if num <= 1:
|
code_infilling
|
python
|
python
|
MBPP/256/L4
|
[] |
[] |
MBPP_Infilling
|
for i in range(2, num):
if num % i == 0:
break
else:
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
if num <= 1:
|
continue
|
code_infilling
|
python
|
python
|
MBPP/256/L5
|
[] |
[] |
MBPP_Infilling
|
if num % i == 0:
break
else:
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
if num <= 1:
continue
|
for i in range(2, num):
|
code_infilling
|
python
|
python
|
MBPP/256/L6
|
[] |
[] |
MBPP_Infilling
|
break
else:
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
if num <= 1:
continue
for i in range(2, num):
|
if num % i == 0:
|
code_infilling
|
python
|
python
|
MBPP/256/L7
|
[] |
[] |
MBPP_Infilling
|
else:
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
if num <= 1:
continue
for i in range(2, num):
if num % i == 0:
|
break
|
code_infilling
|
python
|
python
|
MBPP/256/L8
|
[] |
[] |
MBPP_Infilling
|
ctr += 1
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
if num <= 1:
continue
for i in range(2, num):
if num % i == 0:
break
|
else:
|
code_infilling
|
python
|
python
|
MBPP/256/L9
|
[] |
[] |
MBPP_Infilling
|
return ctr
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
if num <= 1:
continue
for i in range(2, num):
if num % i == 0:
break
else:
|
ctr += 1
|
code_infilling
|
python
|
python
|
MBPP/256/L10
|
[] |
[] |
MBPP_Infilling
|
[
[
"5",
"2"
],
[
"10",
"4"
],
[
"100",
"25"
]
] |
count_Primes_nums
|
[] |
Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number.
|
def count_Primes_nums(n):
"""Write a python function that takes in a non-negative number and returns the number of prime numbers less than the given non-negative number. """
ctr = 0
for num in range(n):
if num <= 1:
continue
for i in range(2, num):
if num % i == 0:
break
else:
ctr += 1
|
return ctr
|
|
code_infilling
|
python
|
python
|
MBPP/257/L1
|
[] |
[] |
MBPP_Infilling
|
a = b
b = temp
return (a, b)
|
[
[
"10,20",
"(20,10)"
],
[
"15,17",
"(17,15)"
],
[
"100,200",
"(200,100)"
]
] |
swap_numbers
|
[] |
Write a function that takes in two numbers and returns a tuple with the second number and then the first number.
|
def swap_numbers(a, b):
"""Write a function that takes in two numbers and returns a tuple with the second number and then the first number. """
|
temp = a
|
code_infilling
|
python
|
python
|
MBPP/257/L2
|
[] |
[] |
MBPP_Infilling
|
b = temp
return (a, b)
|
[
[
"10,20",
"(20,10)"
],
[
"15,17",
"(17,15)"
],
[
"100,200",
"(200,100)"
]
] |
swap_numbers
|
[] |
Write a function that takes in two numbers and returns a tuple with the second number and then the first number.
|
def swap_numbers(a, b):
"""Write a function that takes in two numbers and returns a tuple with the second number and then the first number. """
temp = a
|
a = b
|
code_infilling
|
python
|
python
|
MBPP/257/L3
|
[] |
[] |
MBPP_Infilling
|
return (a, b)
|
[
[
"10,20",
"(20,10)"
],
[
"15,17",
"(17,15)"
],
[
"100,200",
"(200,100)"
]
] |
swap_numbers
|
[] |
Write a function that takes in two numbers and returns a tuple with the second number and then the first number.
|
def swap_numbers(a, b):
"""Write a function that takes in two numbers and returns a tuple with the second number and then the first number. """
temp = a
a = b
|
b = temp
|
code_infilling
|
python
|
python
|
MBPP/257/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"10,20",
"(20,10)"
],
[
"15,17",
"(17,15)"
],
[
"100,200",
"(200,100)"
]
] |
swap_numbers
|
[] |
Write a function that takes in two numbers and returns a tuple with the second number and then the first number.
|
def swap_numbers(a, b):
"""Write a function that takes in two numbers and returns a tuple with the second number and then the first number. """
temp = a
a = b
b = temp
|
return (a, b)
|
|
code_infilling
|
python
|
python
|
MBPP/259/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))",
"((6, 7), (4, 9), (2, 9), (7, 10))"
],
[
"((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))",
"((7, 8), (5, 10), (3, 10), (8, 11))"
],
[
"((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))",
"((8, 9), (6, 11), (4, 11), (9, 12))"
]
] |
maximize_elements
|
[] |
Write a function to maximize the given two tuples.
|
def maximize_elements(test_tup1, test_tup2):
"""Write a function to maximize the given two tuples. """
|
res = tuple((tuple((max(a, b) for (a, b) in zip(tup1, tup2))) for (tup1, tup2) in zip(test_tup1, test_tup2)))
|
code_infilling
|
python
|
python
|
MBPP/259/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))",
"((6, 7), (4, 9), (2, 9), (7, 10))"
],
[
"((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))",
"((7, 8), (5, 10), (3, 10), (8, 11))"
],
[
"((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))",
"((8, 9), (6, 11), (4, 11), (9, 12))"
]
] |
maximize_elements
|
[] |
Write a function to maximize the given two tuples.
|
def maximize_elements(test_tup1, test_tup2):
"""Write a function to maximize the given two tuples. """
res = tuple((tuple((max(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/260/L1
|
[] |
[] |
MBPP_Infilling
|
return 1
return 2 * newman_prime(n - 1) + newman_prime(n - 2)
|
[
[
"3",
"7"
],
[
"4",
"17"
],
[
"5",
"41"
]
] |
newman_prime
|
[] |
Write a function to find the nth newman–shanks–williams prime number.
|
def newman_prime(n):
"""Write a function to find the nth newman–shanks–williams prime number. """
|
if n == 0 or n == 1:
|
code_infilling
|
python
|
python
|
MBPP/260/L2
|
[] |
[] |
MBPP_Infilling
|
return 2 * newman_prime(n - 1) + newman_prime(n - 2)
|
[
[
"3",
"7"
],
[
"4",
"17"
],
[
"5",
"41"
]
] |
newman_prime
|
[] |
Write a function to find the nth newman–shanks–williams prime number.
|
def newman_prime(n):
"""Write a function to find the nth newman–shanks–williams prime number. """
if n == 0 or n == 1:
|
return 1
|
code_infilling
|
python
|
python
|
MBPP/260/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
"3",
"7"
],
[
"4",
"17"
],
[
"5",
"41"
]
] |
newman_prime
|
[] |
Write a function to find the nth newman–shanks–williams prime number.
|
def newman_prime(n):
"""Write a function to find the nth newman–shanks–williams prime number. """
if n == 0 or n == 1:
return 1
|
return 2 * newman_prime(n - 1) + newman_prime(n - 2)
|
|
code_infilling
|
python
|
python
|
MBPP/261/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"(10, 4, 6, 9),(5, 2, 3, 3)",
"(2, 2, 2, 3)"
],
[
"(12, 6, 8, 16),(6, 3, 4, 4)",
"(2, 2, 2, 4)"
],
[
"(20, 14, 36, 18),(5, 7, 6, 9)",
"(4, 2, 6, 2)"
]
] |
division_elements
|
[] |
Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.
|
def division_elements(test_tup1, test_tup2):
"""Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples. """
|
res = tuple((ele1 // ele2 for (ele1, ele2) in zip(test_tup1, test_tup2)))
|
code_infilling
|
python
|
python
|
MBPP/261/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"(10, 4, 6, 9),(5, 2, 3, 3)",
"(2, 2, 2, 3)"
],
[
"(12, 6, 8, 16),(6, 3, 4, 4)",
"(2, 2, 2, 4)"
],
[
"(20, 14, 36, 18),(5, 7, 6, 9)",
"(4, 2, 6, 2)"
]
] |
division_elements
|
[] |
Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples.
|
def division_elements(test_tup1, test_tup2):
"""Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples. """
res = tuple((ele1 // ele2 for (ele1, ele2) in zip(test_tup1, test_tup2)))
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/262/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,1,2,3,4,4,5,1],3",
"([1, 1, 2], [3, 4, 4, 5, 1])"
],
[
"['a', 'b', 'c', 'd'],2",
"(['a', 'b'], ['c', 'd'])"
],
[
"['p', 'y', 't', 'h', 'o', 'n'],4",
"(['p', 'y', 't', 'h'], ['o', 'n'])"
]
] |
split_two_parts
|
[] |
Write a function that takes in a list and an integer L and splits the given list into two parts where the length of the first part of the list is L, and returns the resulting lists in a tuple.
|
def split_two_parts(list1, L):
"""Write a function that takes in a list and an integer L and splits the given list into two parts where the length of the first part of the list is L, and returns the resulting lists in a tuple. """
|
return (list1[:L], list1[L:])
|
|
code_infilling
|
python
|
python
|
MBPP/264/L1
|
[] |
[] |
MBPP_Infilling
|
exit()
elif h_age <= 2:
d_age = h_age * 10.5
else:
d_age = 21 + (h_age - 2) * 4
return d_age
|
[
[
"12",
"61"
],
[
"15",
"73"
],
[
"24",
"109"
]
] |
dog_age
|
[] |
Write a function to calculate a dog's age in dog's years.
|
def dog_age(h_age):
"""Write a function to calculate a dog's age in dog's years. """
|
if h_age < 0:
|
code_infilling
|
python
|
python
|
MBPP/264/L2
|
[] |
[] |
MBPP_Infilling
|
elif h_age <= 2:
d_age = h_age * 10.5
else:
d_age = 21 + (h_age - 2) * 4
return d_age
|
[
[
"12",
"61"
],
[
"15",
"73"
],
[
"24",
"109"
]
] |
dog_age
|
[] |
Write a function to calculate a dog's age in dog's years.
|
def dog_age(h_age):
"""Write a function to calculate a dog's age in dog's years. """
if h_age < 0:
|
exit()
|
code_infilling
|
python
|
python
|
MBPP/264/L3
|
[] |
[] |
MBPP_Infilling
|
d_age = h_age * 10.5
else:
d_age = 21 + (h_age - 2) * 4
return d_age
|
[
[
"12",
"61"
],
[
"15",
"73"
],
[
"24",
"109"
]
] |
dog_age
|
[] |
Write a function to calculate a dog's age in dog's years.
|
def dog_age(h_age):
"""Write a function to calculate a dog's age in dog's years. """
if h_age < 0:
exit()
|
elif h_age <= 2:
|
code_infilling
|
python
|
python
|
MBPP/264/L4
|
[] |
[] |
MBPP_Infilling
|
else:
d_age = 21 + (h_age - 2) * 4
return d_age
|
[
[
"12",
"61"
],
[
"15",
"73"
],
[
"24",
"109"
]
] |
dog_age
|
[] |
Write a function to calculate a dog's age in dog's years.
|
def dog_age(h_age):
"""Write a function to calculate a dog's age in dog's years. """
if h_age < 0:
exit()
elif h_age <= 2:
|
d_age = h_age * 10.5
|
code_infilling
|
python
|
python
|
MBPP/264/L5
|
[] |
[] |
MBPP_Infilling
|
d_age = 21 + (h_age - 2) * 4
return d_age
|
[
[
"12",
"61"
],
[
"15",
"73"
],
[
"24",
"109"
]
] |
dog_age
|
[] |
Write a function to calculate a dog's age in dog's years.
|
def dog_age(h_age):
"""Write a function to calculate a dog's age in dog's years. """
if h_age < 0:
exit()
elif h_age <= 2:
d_age = h_age * 10.5
|
else:
|
code_infilling
|
python
|
python
|
MBPP/264/L6
|
[] |
[] |
MBPP_Infilling
|
return d_age
|
[
[
"12",
"61"
],
[
"15",
"73"
],
[
"24",
"109"
]
] |
dog_age
|
[] |
Write a function to calculate a dog's age in dog's years.
|
def dog_age(h_age):
"""Write a function to calculate a dog's age in dog's years. """
if h_age < 0:
exit()
elif h_age <= 2:
d_age = h_age * 10.5
else:
|
d_age = 21 + (h_age - 2) * 4
|
code_infilling
|
python
|
python
|
MBPP/264/L7
|
[] |
[] |
MBPP_Infilling
|
[
[
"12",
"61"
],
[
"15",
"73"
],
[
"24",
"109"
]
] |
dog_age
|
[] |
Write a function to calculate a dog's age in dog's years.
|
def dog_age(h_age):
"""Write a function to calculate a dog's age in dog's years. """
if h_age < 0:
exit()
elif h_age <= 2:
d_age = h_age * 10.5
else:
d_age = 21 + (h_age - 2) * 4
|
return d_age
|
|
code_infilling
|
python
|
python
|
MBPP/265/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n'],3",
"[['a', 'd', 'g', 'j', 'm'], ['b', 'e', 'h', 'k', 'n'], ['c', 'f', 'i', 'l']]"
],
[
"[1,2,3,4,5,6,7,8,9,10,11,12,13,14],3",
"[[1,4,7,10,13], [2,5,8,11,14], [3,6,9,12]]"
],
[
"['python','java','C','C++','DBMS','SQL'],2",
"[['python', 'C', 'DBMS'], ['java', 'C++', 'SQL']]"
]
] |
list_split
|
[] |
Write a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists.
|
def list_split(S, step):
"""Write a function that takes in a list and an integer n and splits a list for every nth element, returning a list of the resulting lists. """
|
return [S[i::step] for i in range(step)]
|
|
code_infilling
|
python
|
python
|
MBPP/266/L1
|
[] |
[] |
MBPP_Infilling
|
return LSA
|
[
[
"5",
"100"
],
[
"9",
"324"
],
[
"10",
"400"
]
] |
lateralsurface_cube
|
[] |
Write a function to find the lateral surface area of a cube given its side length.
|
def lateralsurface_cube(l):
"""Write a function to find the lateral surface area of a cube given its side length. """
|
LSA = 4 * (l * l)
|
code_infilling
|
python
|
python
|
MBPP/266/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"5",
"100"
],
[
"9",
"324"
],
[
"10",
"400"
]
] |
lateralsurface_cube
|
[] |
Write a function to find the lateral surface area of a cube given its side length.
|
def lateralsurface_cube(l):
"""Write a function to find the lateral surface area of a cube given its side length. """
LSA = 4 * (l * l)
|
return LSA
|
|
code_infilling
|
python
|
python
|
MBPP/267/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"2",
"10"
],
[
"3",
"35"
],
[
"4",
"84"
]
] |
square_Sum
|
[] |
Write a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers.
|
def square_Sum(n):
"""Write a python function that takes in an integer n and returns the sum of the squares of the first n odd natural numbers. """
|
return int(n * (4 * n * n - 1) / 3)
|
|
code_infilling
|
python
|
python
|
MBPP/268/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"3",
"37"
],
[
"4",
"73"
],
[
"5",
"121"
]
] |
find_star_num
|
[] |
Write a function to find the n'th star number.
|
def find_star_num(n):
"""Write a function to find the n'th star number. """
|
return 6 * n * (n - 1) + 1
|
|
code_infilling
|
python
|
python
|
MBPP/269/L1
|
[] |
[] |
MBPP_Infilling
|
return ord(ch)
|
[
[
"'A'",
"65"
],
[
"'R'",
"82"
],
[
"'S'",
"83"
]
] |
ascii_value
|
[] |
Write a function to find the ascii value of a character.
|
def ascii_value(k):
"""Write a function to find the ascii value of a character. """
|
ch = k
|
code_infilling
|
python
|
python
|
MBPP/269/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"'A'",
"65"
],
[
"'R'",
"82"
],
[
"'S'",
"83"
]
] |
ascii_value
|
[] |
Write a function to find the ascii value of a character.
|
def ascii_value(k):
"""Write a function to find the ascii value of a character. """
ch = k
|
return ord(ch)
|
|
code_infilling
|
python
|
python
|
MBPP/270/L1
|
[] |
[] |
MBPP_Infilling
|
sum = 0
for i in range(0, len(arr), 2):
if arr[i] % 2 == 0:
sum += arr[i]
return sum
|
[
[
"[5, 6, 12, 1, 18, 8]",
"30"
],
[
"[3, 20, 17, 9, 2, 10, 18, 13, 6, 18]",
"26"
],
[
"[5, 6, 12, 1]",
"12"
]
] |
sum_even_and_even_index
|
[] |
Write a python function to find the sum of even numbers at even positions of a list.
|
def sum_even_and_even_index(arr):
"""Write a python function to find the sum of even numbers at even positions of a list. """
|
i = 0
|
code_infilling
|
python
|
python
|
MBPP/270/L2
|
[] |
[] |
MBPP_Infilling
|
for i in range(0, len(arr), 2):
if arr[i] % 2 == 0:
sum += arr[i]
return sum
|
[
[
"[5, 6, 12, 1, 18, 8]",
"30"
],
[
"[3, 20, 17, 9, 2, 10, 18, 13, 6, 18]",
"26"
],
[
"[5, 6, 12, 1]",
"12"
]
] |
sum_even_and_even_index
|
[] |
Write a python function to find the sum of even numbers at even positions of a list.
|
def sum_even_and_even_index(arr):
"""Write a python function to find the sum of even numbers at even positions of a list. """
i = 0
|
sum = 0
|
code_infilling
|
python
|
python
|
MBPP/270/L3
|
[] |
[] |
MBPP_Infilling
|
if arr[i] % 2 == 0:
sum += arr[i]
return sum
|
[
[
"[5, 6, 12, 1, 18, 8]",
"30"
],
[
"[3, 20, 17, 9, 2, 10, 18, 13, 6, 18]",
"26"
],
[
"[5, 6, 12, 1]",
"12"
]
] |
sum_even_and_even_index
|
[] |
Write a python function to find the sum of even numbers at even positions of a list.
|
def sum_even_and_even_index(arr):
"""Write a python function to find the sum of even numbers at even positions of a list. """
i = 0
sum = 0
|
for i in range(0, len(arr), 2):
|
code_infilling
|
python
|
python
|
MBPP/270/L4
|
[] |
[] |
MBPP_Infilling
|
sum += arr[i]
return sum
|
[
[
"[5, 6, 12, 1, 18, 8]",
"30"
],
[
"[3, 20, 17, 9, 2, 10, 18, 13, 6, 18]",
"26"
],
[
"[5, 6, 12, 1]",
"12"
]
] |
sum_even_and_even_index
|
[] |
Write a python function to find the sum of even numbers at even positions of a list.
|
def sum_even_and_even_index(arr):
"""Write a python function to find the sum of even numbers at even positions of a list. """
i = 0
sum = 0
for i in range(0, len(arr), 2):
|
if arr[i] % 2 == 0:
|
code_infilling
|
python
|
python
|
MBPP/270/L5
|
[] |
[] |
MBPP_Infilling
|
return sum
|
[
[
"[5, 6, 12, 1, 18, 8]",
"30"
],
[
"[3, 20, 17, 9, 2, 10, 18, 13, 6, 18]",
"26"
],
[
"[5, 6, 12, 1]",
"12"
]
] |
sum_even_and_even_index
|
[] |
Write a python function to find the sum of even numbers at even positions of a list.
|
def sum_even_and_even_index(arr):
"""Write a python function to find the sum of even numbers at even positions of a list. """
i = 0
sum = 0
for i in range(0, len(arr), 2):
if arr[i] % 2 == 0:
|
sum += arr[i]
|
code_infilling
|
python
|
python
|
MBPP/270/L6
|
[] |
[] |
MBPP_Infilling
|
[
[
"[5, 6, 12, 1, 18, 8]",
"30"
],
[
"[3, 20, 17, 9, 2, 10, 18, 13, 6, 18]",
"26"
],
[
"[5, 6, 12, 1]",
"12"
]
] |
sum_even_and_even_index
|
[] |
Write a python function to find the sum of even numbers at even positions of a list.
|
def sum_even_and_even_index(arr):
"""Write a python function to find the sum of even numbers at even positions of a list. """
i = 0
sum = 0
for i in range(0, len(arr), 2):
if arr[i] % 2 == 0:
sum += arr[i]
|
return sum
|
|
code_infilling
|
python
|
python
|
MBPP/271/L1
|
[] |
[] |
MBPP_Infilling
|
for i in range(1, n + 1):
j = 2 * i
sum = sum + j * j * j * j * j
return sum
|
[
[
"2",
"1056"
],
[
"3",
"8832"
],
[
"1",
"32"
]
] |
even_Power_Sum
|
[] |
Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
|
def even_Power_Sum(n):
"""Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power. """
|
sum = 0
|
code_infilling
|
python
|
python
|
MBPP/271/L2
|
[] |
[] |
MBPP_Infilling
|
j = 2 * i
sum = sum + j * j * j * j * j
return sum
|
[
[
"2",
"1056"
],
[
"3",
"8832"
],
[
"1",
"32"
]
] |
even_Power_Sum
|
[] |
Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
|
def even_Power_Sum(n):
"""Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power. """
sum = 0
|
for i in range(1, n + 1):
|
code_infilling
|
python
|
python
|
MBPP/271/L3
|
[] |
[] |
MBPP_Infilling
|
sum = sum + j * j * j * j * j
return sum
|
[
[
"2",
"1056"
],
[
"3",
"8832"
],
[
"1",
"32"
]
] |
even_Power_Sum
|
[] |
Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
|
def even_Power_Sum(n):
"""Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power. """
sum = 0
for i in range(1, n + 1):
|
j = 2 * i
|
code_infilling
|
python
|
python
|
MBPP/271/L4
|
[] |
[] |
MBPP_Infilling
|
return sum
|
[
[
"2",
"1056"
],
[
"3",
"8832"
],
[
"1",
"32"
]
] |
even_Power_Sum
|
[] |
Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
|
def even_Power_Sum(n):
"""Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power. """
sum = 0
for i in range(1, n + 1):
j = 2 * i
|
sum = sum + j * j * j * j * j
|
code_infilling
|
python
|
python
|
MBPP/271/L5
|
[] |
[] |
MBPP_Infilling
|
[
[
"2",
"1056"
],
[
"3",
"8832"
],
[
"1",
"32"
]
] |
even_Power_Sum
|
[] |
Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power.
|
def even_Power_Sum(n):
"""Write a python function that takes in an integer n and finds the sum of the first n even natural numbers that are raised to the fifth power. """
sum = 0
for i in range(1, n + 1):
j = 2 * i
sum = sum + j * j * j * j * j
|
return sum
|
|
code_infilling
|
python
|
python
|
MBPP/272/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"[(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]",
"[21, 20, 19]"
],
[
"[(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]",
"[36, 25, 45]"
],
[
"[(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]",
"[14, 36, 56]"
]
] |
rear_extract
|
[] |
Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple.
|
def rear_extract(test_list):
"""Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple. """
|
res = [lis[-1] for lis in test_list]
|
code_infilling
|
python
|
python
|
MBPP/272/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[(1, 'Rash', 21), (2, 'Varsha', 20), (3, 'Kil', 19)]",
"[21, 20, 19]"
],
[
"[(1, 'Sai', 36), (2, 'Ayesha', 25), (3, 'Salman', 45)]",
"[36, 25, 45]"
],
[
"[(1, 'Sudeep', 14), (2, 'Vandana', 36), (3, 'Dawood', 56)]",
"[14, 36, 56]"
]
] |
rear_extract
|
[] |
Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple.
|
def rear_extract(test_list):
"""Write a function that takes in a list of tuples and returns a list containing the rear element of each tuple. """
res = [lis[-1] for lis in test_list]
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/273/L1
|
[] |
[] |
MBPP_Infilling
|
return res
|
[
[
"(10, 4, 5), (2, 5, 18)",
"(8, -1, -13)"
],
[
"(11, 2, 3), (24, 45 ,16)",
"(-13, -43, -13)"
],
[
"(7, 18, 9), (10, 11, 12)",
"(-3, 7, -3)"
]
] |
substract_elements
|
[] |
Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.
|
def substract_elements(test_tup1, test_tup2):
"""Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index. """
|
res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))
|
code_infilling
|
python
|
python
|
MBPP/273/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"(10, 4, 5), (2, 5, 18)",
"(8, -1, -13)"
],
[
"(11, 2, 3), (24, 45 ,16)",
"(-13, -43, -13)"
],
[
"(7, 18, 9), (10, 11, 12)",
"(-3, 7, -3)"
]
] |
substract_elements
|
[] |
Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index.
|
def substract_elements(test_tup1, test_tup2):
"""Write a function that takes in two tuples and subtracts the elements of the first tuple by the elements of the second tuple with the same index. """
res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))
|
return res
|
|
code_infilling
|
python
|
python
|
MBPP/274/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
"4",
"8"
],
[
"6",
"32"
],
[
"2",
"2"
]
] |
even_binomial_Coeff_Sum
|
[
"import math "
] |
Write a python function that takes in a positive integer n and finds the sum of even index binomial coefficients.
|
import math
def even_binomial_Coeff_Sum(n):
"""Write a python function that takes in a positive integer n and finds the sum of even index binomial coefficients. """
|
return 1 << n - 1
|
|
code_infilling
|
python
|
python
|
MBPP/276/L1
|
[] |
[] |
MBPP_Infilling
|
return volume
|
[] |
volume_cylinder
|
[] |
Write a function that takes in the radius and height of a cylinder and returns the the volume.
|
def volume_cylinder(r, h):
"""Write a function that takes in the radius and height of a cylinder and returns the the volume. """
|
volume = 3.1415 * r * r * h
|
code_infilling
|
python
|
python
|
MBPP/276/L2
|
[] |
[] |
MBPP_Infilling
|
[] |
volume_cylinder
|
[] |
Write a function that takes in the radius and height of a cylinder and returns the the volume.
|
def volume_cylinder(r, h):
"""Write a function that takes in the radius and height of a cylinder and returns the the volume. """
volume = 3.1415 * r * r * h
|
return volume
|
|
code_infilling
|
python
|
python
|
MBPP/277/L1
|
[] |
[] |
MBPP_Infilling
|
return result
|
[
[
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170",
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}"
],
[
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180",
"{ 'Alden Cantrell': 180, 'Pierre Cox': 190}"
],
[
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190",
"{ 'Pierre Cox': 190}"
]
] |
dict_filter
|
[] |
Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n.
|
def dict_filter(dict, n):
"""Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n. """
|
result = {key: value for (key, value) in dict.items() if value >= n}
|
code_infilling
|
python
|
python
|
MBPP/277/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},170",
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Pierre Cox': 190}"
],
[
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},180",
"{ 'Alden Cantrell': 180, 'Pierre Cox': 190}"
],
[
"{'Cierra Vega': 175, 'Alden Cantrell': 180, 'Kierra Gentry': 165, 'Pierre Cox': 190},190",
"{ 'Pierre Cox': 190}"
]
] |
dict_filter
|
[] |
Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n.
|
def dict_filter(dict, n):
"""Write a function that takes in a dictionary and integer n and filters the dictionary to only include entries with values greater than or equal to n. """
result = {key: value for (key, value) in dict.items() if value >= n}
|
return result
|
|
code_infilling
|
python
|
python
|
MBPP/278/L1
|
[] |
[] |
MBPP_Infilling
|
if isinstance(ele, tuple):
break
return count
|
[
[
"(1, 5, 7, (4, 6), 10) ",
"3"
],
[
"(2, 9, (5, 7), 11) ",
"2"
],
[
"(11, 15, 5, 8, (2, 3), 8) ",
"4"
]
] |
count_first_elements
|
[] |
Write a function to find the number of elements that occurs before the tuple element in the given tuple.
|
def count_first_elements(test_tup):
"""Write a function to find the number of elements that occurs before the tuple element in the given tuple. """
|
for (count, ele) in enumerate(test_tup):
|
code_infilling
|
python
|
python
|
MBPP/278/L2
|
[] |
[] |
MBPP_Infilling
|
break
return count
|
[
[
"(1, 5, 7, (4, 6), 10) ",
"3"
],
[
"(2, 9, (5, 7), 11) ",
"2"
],
[
"(11, 15, 5, 8, (2, 3), 8) ",
"4"
]
] |
count_first_elements
|
[] |
Write a function to find the number of elements that occurs before the tuple element in the given tuple.
|
def count_first_elements(test_tup):
"""Write a function to find the number of elements that occurs before the tuple element in the given tuple. """
for (count, ele) in enumerate(test_tup):
|
if isinstance(ele, tuple):
|
code_infilling
|
python
|
python
|
MBPP/278/L3
|
[] |
[] |
MBPP_Infilling
|
return count
|
[
[
"(1, 5, 7, (4, 6), 10) ",
"3"
],
[
"(2, 9, (5, 7), 11) ",
"2"
],
[
"(11, 15, 5, 8, (2, 3), 8) ",
"4"
]
] |
count_first_elements
|
[] |
Write a function to find the number of elements that occurs before the tuple element in the given tuple.
|
def count_first_elements(test_tup):
"""Write a function to find the number of elements that occurs before the tuple element in the given tuple. """
for (count, ele) in enumerate(test_tup):
if isinstance(ele, tuple):
|
break
|
code_infilling
|
python
|
python
|
MBPP/278/L4
|
[] |
[] |
MBPP_Infilling
|
[
[
"(1, 5, 7, (4, 6), 10) ",
"3"
],
[
"(2, 9, (5, 7), 11) ",
"2"
],
[
"(11, 15, 5, 8, (2, 3), 8) ",
"4"
]
] |
count_first_elements
|
[] |
Write a function to find the number of elements that occurs before the tuple element in the given tuple.
|
def count_first_elements(test_tup):
"""Write a function to find the number of elements that occurs before the tuple element in the given tuple. """
for (count, ele) in enumerate(test_tup):
if isinstance(ele, tuple):
break
|
return count
|
|
code_infilling
|
python
|
python
|
MBPP/279/L1
|
[] |
[] |
MBPP_Infilling
|
[
[
"3",
"27"
],
[
"7",
"175"
],
[
"10",
"370"
]
] |
is_num_decagonal
|
[] |
Write a function to find the nth decagonal number.
|
def is_num_decagonal(n):
"""Write a function to find the nth decagonal number. """
|
return 4 * n * n - 3 * n
|
|
code_infilling
|
python
|
python
|
MBPP/280/L1
|
[] |
[] |
MBPP_Infilling
|
found = False
while pos < len(dlist) and (not found):
if dlist[pos] == item:
found = True
else:
pos = pos + 1
return (found, pos)
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
|
pos = 0
|
code_infilling
|
python
|
python
|
MBPP/280/L2
|
[] |
[] |
MBPP_Infilling
|
while pos < len(dlist) and (not found):
if dlist[pos] == item:
found = True
else:
pos = pos + 1
return (found, pos)
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
pos = 0
|
found = False
|
code_infilling
|
python
|
python
|
MBPP/280/L3
|
[] |
[] |
MBPP_Infilling
|
if dlist[pos] == item:
found = True
else:
pos = pos + 1
return (found, pos)
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
pos = 0
found = False
|
while pos < len(dlist) and (not found):
|
code_infilling
|
python
|
python
|
MBPP/280/L4
|
[] |
[] |
MBPP_Infilling
|
found = True
else:
pos = pos + 1
return (found, pos)
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
pos = 0
found = False
while pos < len(dlist) and (not found):
|
if dlist[pos] == item:
|
code_infilling
|
python
|
python
|
MBPP/280/L5
|
[] |
[] |
MBPP_Infilling
|
else:
pos = pos + 1
return (found, pos)
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
pos = 0
found = False
while pos < len(dlist) and (not found):
if dlist[pos] == item:
|
found = True
|
code_infilling
|
python
|
python
|
MBPP/280/L6
|
[] |
[] |
MBPP_Infilling
|
pos = pos + 1
return (found, pos)
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
pos = 0
found = False
while pos < len(dlist) and (not found):
if dlist[pos] == item:
found = True
|
else:
|
code_infilling
|
python
|
python
|
MBPP/280/L7
|
[] |
[] |
MBPP_Infilling
|
return (found, pos)
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
pos = 0
found = False
while pos < len(dlist) and (not found):
if dlist[pos] == item:
found = True
else:
|
pos = pos + 1
|
code_infilling
|
python
|
python
|
MBPP/280/L8
|
[] |
[] |
MBPP_Infilling
|
[
[
"[11,23,58,31,56,77,43,12,65,19],31",
"(True, 3)"
],
[
"[12, 32, 45, 62, 35, 47, 44, 61],61",
"(True, 7)"
],
[
"[9, 10, 17, 19, 22, 39, 48, 56],48",
"(True, 6)"
]
] |
sequential_search
|
[] |
Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found).
|
def sequential_search(dlist, item):
"""Write a function that takes in an array and element and returns a tuple containing a boolean that indicates if the element is in the array and the index position of the element (or -1 if the element is not found). """
pos = 0
found = False
while pos < len(dlist) and (not found):
if dlist[pos] == item:
found = True
else:
pos = pos + 1
|
return (found, pos)
|
|
code_infilling
|
python
|
python
|
MBPP/281/L1
|
[] |
[] |
MBPP_Infilling
|
return False
return True
|
[
[
"[1,2,3]",
"True"
],
[
"[1,2,1,2]",
"False"
],
[
"[1,2,3,4,5]",
"True"
]
] |
all_unique
|
[] |
Write a python function to check if the elements of a given list are unique or not.
|
def all_unique(test_list):
"""Write a python function to check if the elements of a given list are unique or not. """
|
if len(test_list) > len(set(test_list)):
|
code_infilling
|
python
|
python
|
MBPP/281/L2
|
[] |
[] |
MBPP_Infilling
|
return True
|
[
[
"[1,2,3]",
"True"
],
[
"[1,2,1,2]",
"False"
],
[
"[1,2,3,4,5]",
"True"
]
] |
all_unique
|
[] |
Write a python function to check if the elements of a given list are unique or not.
|
def all_unique(test_list):
"""Write a python function to check if the elements of a given list are unique or not. """
if len(test_list) > len(set(test_list)):
|
return False
|
code_infilling
|
python
|
python
|
MBPP/281/L3
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1,2,3]",
"True"
],
[
"[1,2,1,2]",
"False"
],
[
"[1,2,3,4,5]",
"True"
]
] |
all_unique
|
[] |
Write a python function to check if the elements of a given list are unique or not.
|
def all_unique(test_list):
"""Write a python function to check if the elements of a given list are unique or not. """
if len(test_list) > len(set(test_list)):
return False
|
return True
|
|
code_infilling
|
python
|
python
|
MBPP/282/L1
|
[] |
[] |
MBPP_Infilling
|
return list(result)
|
[
[
"[1, 2, 3],[4,5,6]",
"[-3,-3,-3]"
],
[
"[1,2],[3,4]",
"[-2,-2]"
],
[
"[90,120],[50,70]",
"[40,50]"
]
] |
sub_list
|
[] |
Write a function to subtract two lists element-wise.
|
def sub_list(nums1, nums2):
"""Write a function to subtract two lists element-wise. """
|
result = map(lambda x, y: x - y, nums1, nums2)
|
code_infilling
|
python
|
python
|
MBPP/282/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[1, 2, 3],[4,5,6]",
"[-3,-3,-3]"
],
[
"[1,2],[3,4]",
"[-2,-2]"
],
[
"[90,120],[50,70]",
"[40,50]"
]
] |
sub_list
|
[] |
Write a function to subtract two lists element-wise.
|
def sub_list(nums1, nums2):
"""Write a function to subtract two lists element-wise. """
result = map(lambda x, y: x - y, nums1, nums2)
|
return list(result)
|
|
code_infilling
|
python
|
python
|
MBPP/283/L1
|
[] |
[] |
MBPP_Infilling
|
temp = n
count = 0
while temp:
if temp % 10 == i:
count += 1
if count > i:
return False
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
|
for i in range(10):
|
code_infilling
|
python
|
python
|
MBPP/283/L2
|
[] |
[] |
MBPP_Infilling
|
count = 0
while temp:
if temp % 10 == i:
count += 1
if count > i:
return False
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
|
temp = n
|
code_infilling
|
python
|
python
|
MBPP/283/L3
|
[] |
[] |
MBPP_Infilling
|
while temp:
if temp % 10 == i:
count += 1
if count > i:
return False
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
|
count = 0
|
code_infilling
|
python
|
python
|
MBPP/283/L4
|
[] |
[] |
MBPP_Infilling
|
if temp % 10 == i:
count += 1
if count > i:
return False
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
count = 0
|
while temp:
|
code_infilling
|
python
|
python
|
MBPP/283/L5
|
[] |
[] |
MBPP_Infilling
|
count += 1
if count > i:
return False
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
count = 0
while temp:
|
if temp % 10 == i:
|
code_infilling
|
python
|
python
|
MBPP/283/L6
|
[] |
[] |
MBPP_Infilling
|
if count > i:
return False
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
count = 0
while temp:
if temp % 10 == i:
|
count += 1
|
code_infilling
|
python
|
python
|
MBPP/283/L7
|
[] |
[] |
MBPP_Infilling
|
return False
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
count = 0
while temp:
if temp % 10 == i:
count += 1
|
if count > i:
|
code_infilling
|
python
|
python
|
MBPP/283/L8
|
[] |
[] |
MBPP_Infilling
|
temp //= 10
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
count = 0
while temp:
if temp % 10 == i:
count += 1
if count > i:
|
return False
|
code_infilling
|
python
|
python
|
MBPP/283/L9
|
[] |
[] |
MBPP_Infilling
|
return True
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
count = 0
while temp:
if temp % 10 == i:
count += 1
if count > i:
return False
|
temp //= 10
|
code_infilling
|
python
|
python
|
MBPP/283/L10
|
[] |
[] |
MBPP_Infilling
|
[
[
"1234",
"True"
],
[
"51241",
"False"
],
[
"321",
"True"
]
] |
validate
|
[] |
Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself.
|
def validate(n):
"""Write a python function takes in an integer and check whether the frequency of each digit in the integer is less than or equal to the digit itself. """
for i in range(10):
temp = n
count = 0
while temp:
if temp % 10 == i:
count += 1
if count > i:
return False
temp //= 10
|
return True
|
|
code_infilling
|
python
|
python
|
MBPP/284/L1
|
[] |
[] |
MBPP_Infilling
|
return check_element
|
[
[
"[\"green\", \"orange\", \"black\", \"white\"],'blue'",
"False"
],
[
"[1,2,3,4],7",
"False"
],
[
"[\"green\", \"green\", \"green\", \"green\"],'green'",
"True"
]
] |
check_element
|
[] |
Write a function that takes in a list and element and checks whether all items in the list are equal to the given element.
|
def check_element(list, element):
"""Write a function that takes in a list and element and checks whether all items in the list are equal to the given element. """
|
check_element = all((v == element for v in list))
|
code_infilling
|
python
|
python
|
MBPP/284/L2
|
[] |
[] |
MBPP_Infilling
|
[
[
"[\"green\", \"orange\", \"black\", \"white\"],'blue'",
"False"
],
[
"[1,2,3,4],7",
"False"
],
[
"[\"green\", \"green\", \"green\", \"green\"],'green'",
"True"
]
] |
check_element
|
[] |
Write a function that takes in a list and element and checks whether all items in the list are equal to the given element.
|
def check_element(list, element):
"""Write a function that takes in a list and element and checks whether all items in the list are equal to the given element. """
check_element = all((v == element for v in list))
|
return check_element
|
|
code_infilling
|
python
|
python
|
MBPP/285/L3
|
[] |
[] |
MBPP_Infilling
|
if re.search(patterns, text):
return True
else:
return False
|
[
[
"\"ac\"",
"(False)"
],
[
"\"dc\"",
"(False)"
],
[
"\"abbbba\"",
"(True)"
]
] |
text_match_two_three
|
[
"import re"
] |
Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters.
|
import re
def text_match_two_three(text):
"""Write a function that checks whether a string contains the 'a' character followed by two or three 'b' characters. """
|
patterns = 'ab{2,3}'
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.