question_title
stringlengths 7
8
| question_content
stringlengths 37
191
| question_id
stringlengths 2
3
| contest_id
stringclasses 1
value | test_id
int64 0
5
| contest_date
timestamp[us] | starter_code
stringlengths 37
1.33k
| function_name
stringlengths 3
32
| difficulty
stringclasses 1
value | test
stringlengths 57
1.94k
|
---|---|---|---|---|---|---|---|---|---|
Mbpp_426 | Write a function to filter odd numbers using lambda function. | 426 | mbpp | 2 | 2024-11-26T21:40:54.421837 | def filter_oddnumbers(nums):
odd_nums = list(filter(lambda x: x%2 != 0, nums))
return odd_nums | filter_oddnumbers | easy | [{"input": "[5,7,9,8,6,4,3]", "output": "[5,7,9,3]", "testtype": "functional"}] |
Mbpp_427 | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format by using regex. | 427 | mbpp | 0 | 2024-11-26T21:40:54.422104 | import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) | change_date_format | easy | [{"input": "\"2026-01-02\"", "output": "'02-01-2026'", "testtype": "functional"}] |
Mbpp_427 | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format by using regex. | 427 | mbpp | 1 | 2024-11-26T21:40:54.422283 | import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) | change_date_format | easy | [{"input": "\"2020-11-13\"", "output": "'13-11-2020'", "testtype": "functional"}] |
Mbpp_427 | Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format by using regex. | 427 | mbpp | 2 | 2024-11-26T21:40:54.422455 | import re
def change_date_format(dt):
return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt) | change_date_format | easy | [{"input": "\"2021-04-26\"", "output": "'26-04-2021'", "testtype": "functional"}] |
Mbpp_428 | Write a function to sort the given array by using shell sort. | 428 | mbpp | 0 | 2024-11-26T21:40:54.422969 | def shell_sort(my_list):
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 | shell_sort | easy | [{"input": "[12, 23, 4, 5, 3, 2, 12, 81, 56, 95]", "output": "[2, 3, 4, 5, 12, 12, 23, 56, 81, 95]", "testtype": "functional"}] |
Mbpp_428 | Write a function to sort the given array by using shell sort. | 428 | mbpp | 1 | 2024-11-26T21:40:54.423447 | def shell_sort(my_list):
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 | shell_sort | easy | [{"input": "[24, 22, 39, 34, 87, 73, 68]", "output": "[22, 24, 34, 39, 68, 73, 87]", "testtype": "functional"}] |
Mbpp_428 | Write a function to sort the given array by using shell sort. | 428 | mbpp | 2 | 2024-11-26T21:40:54.423901 | def shell_sort(my_list):
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 | shell_sort | easy | [{"input": "[32, 30, 16, 96, 82, 83, 74]", "output": "[16, 30, 32, 74, 82, 83, 96]", "testtype": "functional"}] |
Mbpp_429 | Write a function to extract the elementwise and tuples from the given two tuples. | 429 | mbpp | 0 | 2024-11-26T21:40:54.424109 | def and_tuples(test_tup1, test_tup2):
res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | and_tuples | easy | [{"input": "(10, 4, 6, 9), (5, 2, 3, 3)", "output": "(0, 0, 2, 1)", "testtype": "functional"}] |
Mbpp_429 | Write a function to extract the elementwise and tuples from the given two tuples. | 429 | mbpp | 1 | 2024-11-26T21:40:54.424280 | def and_tuples(test_tup1, test_tup2):
res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | and_tuples | easy | [{"input": "(1, 2, 3, 4), (5, 6, 7, 8)", "output": "(1, 2, 3, 0)", "testtype": "functional"}] |
Mbpp_429 | Write a function to extract the elementwise and tuples from the given two tuples. | 429 | mbpp | 2 | 2024-11-26T21:40:54.424668 | def and_tuples(test_tup1, test_tup2):
res = tuple(ele1 & ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
return (res) | and_tuples | easy | [{"input": "(8, 9, 11, 12), (7, 13, 14, 17)", "output": "(0, 9, 10, 0)", "testtype": "functional"}] |
Mbpp_430 | Write a function to find the directrix of a parabola. | 430 | mbpp | 0 | 2024-11-26T21:40:54.424882 | def parabola_directrix(a, b, c):
directrix=((int)(c - ((b * b) + 1) * 4 * a ))
return directrix | parabola_directrix | easy | [{"input": "5,3,2", "output": "-198", "testtype": "functional"}] |
Mbpp_430 | Write a function to find the directrix of a parabola. | 430 | mbpp | 1 | 2024-11-26T21:40:54.425078 | def parabola_directrix(a, b, c):
directrix=((int)(c - ((b * b) + 1) * 4 * a ))
return directrix | parabola_directrix | easy | [{"input": "9,8,4", "output": "-2336", "testtype": "functional"}] |
Mbpp_430 | Write a function to find the directrix of a parabola. | 430 | mbpp | 2 | 2024-11-26T21:40:54.425252 | def parabola_directrix(a, b, c):
directrix=((int)(c - ((b * b) + 1) * 4 * a ))
return directrix | parabola_directrix | easy | [{"input": "2,4,6", "output": "-130", "testtype": "functional"}] |
Mbpp_431 | Write a function that takes two lists and returns true if they have at least one common element. | 431 | mbpp | 0 | 2024-11-26T21:40:54.425474 | def common_element(list1, list2):
result = False
for x in list1:
for y in list2:
if x == y:
result = True
return result | common_element | easy | [{"input": "[1,2,3,4,5], [5,6,7,8,9]", "output": "True", "testtype": "functional"}] |
Mbpp_431 | Write a function that takes two lists and returns true if they have at least one common element. | 431 | mbpp | 1 | 2024-11-26T21:40:54.425671 | def common_element(list1, list2):
result = False
for x in list1:
for y in list2:
if x == y:
result = True
return result | common_element | easy | [{"input": "[1,2,3,4,5], [6,7,8,9]", "output": "None", "testtype": "functional"}] |
Mbpp_431 | Write a function that takes two lists and returns true if they have at least one common element. | 431 | mbpp | 2 | 2024-11-26T21:40:54.425855 | def common_element(list1, list2):
result = False
for x in list1:
for y in list2:
if x == y:
result = True
return result | common_element | easy | [{"input": "['a','b','c'], ['d','b','e']", "output": "True", "testtype": "functional"}] |
Mbpp_432 | Write a function to find the median of a trapezium. | 432 | mbpp | 0 | 2024-11-26T21:40:54.426002 | def median_trapezium(base1,base2,height):
median = 0.5 * (base1+ base2)
return median | median_trapezium | easy | [{"input": "15,25,35", "output": "20", "testtype": "functional"}] |
Mbpp_432 | Write a function to find the median of a trapezium. | 432 | mbpp | 1 | 2024-11-26T21:40:54.426128 | def median_trapezium(base1,base2,height):
median = 0.5 * (base1+ base2)
return median | median_trapezium | easy | [{"input": "10,20,30", "output": "15", "testtype": "functional"}] |
Mbpp_432 | Write a function to find the median of a trapezium. | 432 | mbpp | 2 | 2024-11-26T21:40:54.426244 | def median_trapezium(base1,base2,height):
median = 0.5 * (base1+ base2)
return median | median_trapezium | easy | [{"input": "6,9,4", "output": "7.5", "testtype": "functional"}] |
Mbpp_433 | Write a function to check whether the entered number is greater than the elements of the given array. | 433 | mbpp | 0 | 2024-11-26T21:40:54.426686 | def check_greater(arr, number):
arr.sort()
if number > arr[-1]:
return ('Yes, the entered number is greater than those in the array')
else:
return ('No, entered number is less than those in the array') | check_greater | easy | [{"input": "[1, 2, 3, 4, 5], 4", "output": "'No, entered number is less than those in the array'", "testtype": "functional"}] |
Mbpp_433 | Write a function to check whether the entered number is greater than the elements of the given array. | 433 | mbpp | 1 | 2024-11-26T21:40:54.426906 | def check_greater(arr, number):
arr.sort()
if number > arr[-1]:
return ('Yes, the entered number is greater than those in the array')
else:
return ('No, entered number is less than those in the array') | check_greater | easy | [{"input": "[2, 3, 4, 5, 6], 8", "output": "'Yes, the entered number is greater than those in the array'", "testtype": "functional"}] |
Mbpp_433 | Write a function to check whether the entered number is greater than the elements of the given array. | 433 | mbpp | 2 | 2024-11-26T21:40:54.427071 | def check_greater(arr, number):
arr.sort()
if number > arr[-1]:
return ('Yes, the entered number is greater than those in the array')
else:
return ('No, entered number is less than those in the array') | check_greater | easy | [{"input": "[9, 7, 4, 8, 6, 1], 11", "output": "'Yes, the entered number is greater than those in the array'", "testtype": "functional"}] |
Mbpp_434 | Write a function that matches a string that has an a followed by one or more b's. | 434 | mbpp | 0 | 2024-11-26T21:40:54.427247 | import re
def text_match_one(text):
patterns = 'ab+?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
| text_match_one | easy | [{"input": "\"ac\"", "output": "('Not matched!')", "testtype": "functional"}] |
Mbpp_434 | Write a function that matches a string that has an a followed by one or more b's. | 434 | mbpp | 1 | 2024-11-26T21:40:54.427423 | import re
def text_match_one(text):
patterns = 'ab+?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
| text_match_one | easy | [{"input": "\"dc\"", "output": "('Not matched!')", "testtype": "functional"}] |
Mbpp_434 | Write a function that matches a string that has an a followed by one or more b's. | 434 | mbpp | 2 | 2024-11-26T21:40:54.427578 | import re
def text_match_one(text):
patterns = 'ab+?'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!')
| text_match_one | easy | [{"input": "\"abba\"", "output": "('Found a match!')", "testtype": "functional"}] |
Mbpp_435 | Write a python function to find the last digit of a given number. | 435 | mbpp | 0 | 2024-11-26T21:40:54.427754 | def last_Digit(n) :
return (n % 10) | last_Digit | easy | [{"input": "123", "output": "3", "testtype": "functional"}] |
Mbpp_435 | Write a python function to find the last digit of a given number. | 435 | mbpp | 1 | 2024-11-26T21:40:54.427855 | def last_Digit(n) :
return (n % 10) | last_Digit | easy | [{"input": "25", "output": "5", "testtype": "functional"}] |
Mbpp_435 | Write a python function to find the last digit of a given number. | 435 | mbpp | 2 | 2024-11-26T21:40:54.427938 | def last_Digit(n) :
return (n % 10) | last_Digit | easy | [{"input": "30", "output": "0", "testtype": "functional"}] |
Mbpp_436 | Write a python function to print negative numbers in a list. | 436 | mbpp | 0 | 2024-11-26T21:40:54.428194 | def neg_nos(list1):
for num in list1:
if num < 0:
return num | neg_nos | easy | [{"input": "[-1,4,5,-6]", "output": "-1,-6", "testtype": "functional"}] |
Mbpp_436 | Write a python function to print negative numbers in a list. | 436 | mbpp | 1 | 2024-11-26T21:40:54.428400 | def neg_nos(list1):
for num in list1:
if num < 0:
return num | neg_nos | easy | [{"input": "[-1,-2,3,4]", "output": "-1,-2", "testtype": "functional"}] |
Mbpp_436 | Write a python function to print negative numbers in a list. | 436 | mbpp | 2 | 2024-11-26T21:40:54.428535 | def neg_nos(list1):
for num in list1:
if num < 0:
return num | neg_nos | easy | [{"input": "[-7,-6,8,9]", "output": "-7,-6", "testtype": "functional"}] |
Mbpp_437 | Write a function to remove odd characters in a string. | 437 | mbpp | 0 | 2024-11-26T21:40:54.428816 | def remove_odd(str1):
str2 = ''
for i in range(1, len(str1) + 1):
if(i % 2 == 0):
str2 = str2 + str1[i - 1]
return str2 | remove_odd | easy | [{"input": "\"python\"", "output": "(\"yhn\")", "testtype": "functional"}] |
Mbpp_437 | Write a function to remove odd characters in a string. | 437 | mbpp | 1 | 2024-11-26T21:40:54.429052 | def remove_odd(str1):
str2 = ''
for i in range(1, len(str1) + 1):
if(i % 2 == 0):
str2 = str2 + str1[i - 1]
return str2 | remove_odd | easy | [{"input": "\"program\"", "output": "(\"rga\")", "testtype": "functional"}] |
Mbpp_437 | Write a function to remove odd characters in a string. | 437 | mbpp | 2 | 2024-11-26T21:40:54.429293 | def remove_odd(str1):
str2 = ''
for i in range(1, len(str1) + 1):
if(i % 2 == 0):
str2 = str2 + str1[i - 1]
return str2 | remove_odd | easy | [{"input": "\"language\"", "output": "(\"agae\")", "testtype": "functional"}] |
Mbpp_438 | Write a function to count bidirectional tuple pairs. | 438 | mbpp | 0 | 2024-11-26T21:40:54.429878 | def count_bidirectional(test_list):
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 (str(res)) | count_bidirectional | easy | [{"input": "[(5, 6), (1, 2), (6, 5), (9, 1), (6, 5), (2, 1)] ", "output": "'3'", "testtype": "functional"}] |
Mbpp_438 | Write a function to count bidirectional tuple pairs. | 438 | mbpp | 1 | 2024-11-26T21:40:54.430265 | def count_bidirectional(test_list):
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 (str(res)) | count_bidirectional | easy | [{"input": "[(5, 6), (1, 3), (6, 5), (9, 1), (6, 5), (2, 1)] ", "output": "'2'", "testtype": "functional"}] |
Mbpp_438 | Write a function to count bidirectional tuple pairs. | 438 | mbpp | 2 | 2024-11-26T21:40:54.430664 | def count_bidirectional(test_list):
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 (str(res)) | count_bidirectional | easy | [{"input": "[(5, 6), (1, 2), (6, 5), (9, 2), (6, 5), (2, 1)] ", "output": "'4'", "testtype": "functional"}] |
Mbpp_439 | Write a function to convert a list of multiple integers into a single integer. | 439 | mbpp | 0 | 2024-11-26T21:40:54.430836 | def multiple_to_single(L):
x = int("".join(map(str, L)))
return x | multiple_to_single | easy | [{"input": "[11, 33, 50]", "output": "113350", "testtype": "functional"}] |
Mbpp_439 | Write a function to convert a list of multiple integers into a single integer. | 439 | mbpp | 1 | 2024-11-26T21:40:54.430970 | def multiple_to_single(L):
x = int("".join(map(str, L)))
return x | multiple_to_single | easy | [{"input": "[-1,2,3,4,5,6]", "output": "-123456", "testtype": "functional"}] |
Mbpp_439 | Write a function to convert a list of multiple integers into a single integer. | 439 | mbpp | 2 | 2024-11-26T21:40:54.431103 | def multiple_to_single(L):
x = int("".join(map(str, L)))
return x | multiple_to_single | easy | [{"input": "[10,15,20,25]", "output": "10152025", "testtype": "functional"}] |
Mbpp_440 | Write a function to find all adverbs and their positions in a given sentence. | 440 | mbpp | 0 | 2024-11-26T21:40:54.431308 | import re
def find_adverb_position(text):
for m in re.finditer(r"\w+ly", text):
return (m.start(), m.end(), m.group(0)) | find_adverb_position | easy | [{"input": "\"clearly!! we can see the sky\"", "output": "(0, 7, 'clearly')", "testtype": "functional"}] |
Mbpp_440 | Write a function to find all adverbs and their positions in a given sentence. | 440 | mbpp | 1 | 2024-11-26T21:40:54.431522 | import re
def find_adverb_position(text):
for m in re.finditer(r"\w+ly", text):
return (m.start(), m.end(), m.group(0)) | find_adverb_position | easy | [{"input": "\"seriously!! there are many roses\"", "output": "(0, 9, 'seriously')", "testtype": "functional"}] |
Mbpp_440 | Write a function to find all adverbs and their positions in a given sentence. | 440 | mbpp | 2 | 2024-11-26T21:40:54.431746 | import re
def find_adverb_position(text):
for m in re.finditer(r"\w+ly", text):
return (m.start(), m.end(), m.group(0)) | find_adverb_position | easy | [{"input": "\"unfortunately!! sita is going to home\"", "output": "(0, 13, 'unfortunately')", "testtype": "functional"}] |
Mbpp_441 | Write a function to find the surface area of a cube. | 441 | mbpp | 0 | 2024-11-26T21:40:54.431883 | def surfacearea_cube(l):
surfacearea= 6*l*l
return surfacearea | surfacearea_cube | easy | [{"input": "5", "output": "150", "testtype": "functional"}] |
Mbpp_441 | Write a function to find the surface area of a cube. | 441 | mbpp | 1 | 2024-11-26T21:40:54.431995 | def surfacearea_cube(l):
surfacearea= 6*l*l
return surfacearea | surfacearea_cube | easy | [{"input": "3", "output": "54", "testtype": "functional"}] |
Mbpp_441 | Write a function to find the surface area of a cube. | 441 | mbpp | 2 | 2024-11-26T21:40:54.432112 | def surfacearea_cube(l):
surfacearea= 6*l*l
return surfacearea | surfacearea_cube | easy | [{"input": "10", "output": "600", "testtype": "functional"}] |
Mbpp_442 | Write a function to find the ration of positive numbers in an array of integers. | 442 | mbpp | 0 | 2024-11-26T21:40:54.432411 | from array import array
def positive_count(nums):
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
None
return round(n1/n,2) | positive_count | easy | [{"input": "[0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]", "output": "0.54", "testtype": "functional"}] |
Mbpp_442 | Write a function to find the ration of positive numbers in an array of integers. | 442 | mbpp | 1 | 2024-11-26T21:40:54.432671 | from array import array
def positive_count(nums):
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
None
return round(n1/n,2) | positive_count | easy | [{"input": "[2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]", "output": "0.69", "testtype": "functional"}] |
Mbpp_442 | Write a function to find the ration of positive numbers in an array of integers. | 442 | mbpp | 2 | 2024-11-26T21:40:54.432910 | from array import array
def positive_count(nums):
n = len(nums)
n1 = 0
for x in nums:
if x > 0:
n1 += 1
else:
None
return round(n1/n,2) | positive_count | easy | [{"input": "[2, 4, -6, -9, 11, -12, 14, -5, 17]", "output": "0.56", "testtype": "functional"}] |
Mbpp_443 | Write a python function to find the largest negative number from the given list. | 443 | mbpp | 0 | 2024-11-26T21:40:54.433089 | def largest_neg(list1):
max = list1[0]
for x in list1:
if x < max :
max = x
return max | largest_neg | easy | [{"input": "[1,2,3,-4,-6]", "output": "-6", "testtype": "functional"}] |
Mbpp_443 | Write a python function to find the largest negative number from the given list. | 443 | mbpp | 1 | 2024-11-26T21:40:54.433257 | def largest_neg(list1):
max = list1[0]
for x in list1:
if x < max :
max = x
return max | largest_neg | easy | [{"input": "[1,2,3,-8,-9]", "output": "-9", "testtype": "functional"}] |
Mbpp_443 | Write a python function to find the largest negative number from the given list. | 443 | mbpp | 2 | 2024-11-26T21:40:54.433429 | def largest_neg(list1):
max = list1[0]
for x in list1:
if x < max :
max = x
return max | largest_neg | easy | [{"input": "[1,2,3,4,-1]", "output": "-1", "testtype": "functional"}] |
Mbpp_444 | Write a function to trim each tuple by k in the given tuple list. | 444 | mbpp | 0 | 2024-11-26T21:40:54.433724 | def trim_tuple(test_list, K):
res = []
for ele in test_list:
N = len(ele)
res.append(tuple(list(ele)[K: N - K]))
return (str(res)) | trim_tuple | easy | [{"input": "[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1),(9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 2", "output": "'[(2,), (9,), (2,), (2,)]'", "testtype": "functional"}] |
Mbpp_444 | Write a function to trim each tuple by k in the given tuple list. | 444 | mbpp | 1 | 2024-11-26T21:40:54.433993 | def trim_tuple(test_list, K):
res = []
for ele in test_list:
N = len(ele)
res.append(tuple(list(ele)[K: N - K]))
return (str(res)) | trim_tuple | easy | [{"input": "[(5, 3, 2, 1, 4), (3, 4, 9, 2, 1), (9, 1, 2, 3, 5), (4, 8, 2, 1, 7)], 1", "output": "'[(3, 2, 1), (4, 9, 2), (1, 2, 3), (8, 2, 1)]'", "testtype": "functional"}] |
Mbpp_444 | Write a function to trim each tuple by k in the given tuple list. | 444 | mbpp | 2 | 2024-11-26T21:40:54.434263 | def trim_tuple(test_list, K):
res = []
for ele in test_list:
N = len(ele)
res.append(tuple(list(ele)[K: N - K]))
return (str(res)) | trim_tuple | easy | [{"input": "[(7, 8, 4, 9), (11, 8, 12, 4),(4, 1, 7, 8), (3, 6, 9, 7)], 1", "output": "'[(8, 4), (8, 12), (1, 7), (6, 9)]'", "testtype": "functional"}] |
Mbpp_445 | Write a function to perform index wise multiplication of tuple elements in the given two tuples. | 445 | mbpp | 0 | 2024-11-26T21:40:54.434530 | def index_multiplication(test_tup1, test_tup2):
res = tuple(tuple(a * b for a, b in zip(tup1, tup2))
for tup1, tup2 in zip(test_tup1, test_tup2))
return (res) | index_multiplication | easy | [{"input": "((1, 3), (4, 5), (2, 9), (1, 10)),((6, 7), (3, 9), (1, 1), (7, 3)) ", "output": "((6, 21), (12, 45), (2, 9), (7, 30))", "testtype": "functional"}] |
Mbpp_445 | Write a function to perform index wise multiplication of tuple elements in the given two tuples. | 445 | mbpp | 1 | 2024-11-26T21:40:54.434786 | def index_multiplication(test_tup1, test_tup2):
res = tuple(tuple(a * b for a, b in zip(tup1, tup2))
for tup1, tup2 in zip(test_tup1, test_tup2))
return (res) | index_multiplication | easy | [{"input": "((2, 4), (5, 6), (3, 10), (2, 11)),((7, 8), (4, 10), (2, 2), (8, 4)) ", "output": "((14, 32), (20, 60), (6, 20), (16, 44))", "testtype": "functional"}] |
Mbpp_445 | Write a function to perform index wise multiplication of tuple elements in the given two tuples. | 445 | mbpp | 2 | 2024-11-26T21:40:54.435007 | def index_multiplication(test_tup1, test_tup2):
res = tuple(tuple(a * b for a, b in zip(tup1, tup2))
for tup1, tup2 in zip(test_tup1, test_tup2))
return (res) | index_multiplication | easy | [{"input": "((3, 5), (6, 7), (4, 11), (3, 12)),((8, 9), (5, 11), (3, 3), (9, 5)) ", "output": "((24, 45), (30, 77), (12, 33), (27, 60))", "testtype": "functional"}] |
Mbpp_446 | Write a python function to count the occurence of all elements of list in a tuple. | 446 | mbpp | 0 | 2024-11-26T21:40:54.435194 | from collections import Counter
def count_Occurrence(tup, lst):
count = 0
for item in tup:
if item in lst:
count+= 1
return count | count_Occurrence | easy | [{"input": "('a', 'a', 'c', 'b', 'd'),['a', 'b'] ", "output": "3", "testtype": "functional"}] |
Mbpp_446 | Write a python function to count the occurence of all elements of list in a tuple. | 446 | mbpp | 1 | 2024-11-26T21:40:54.435386 | from collections import Counter
def count_Occurrence(tup, lst):
count = 0
for item in tup:
if item in lst:
count+= 1
return count | count_Occurrence | easy | [{"input": "(1, 2, 3, 1, 4, 6, 7, 1, 4),[1, 4, 7]", "output": "6", "testtype": "functional"}] |
Mbpp_446 | Write a python function to count the occurence of all elements of list in a tuple. | 446 | mbpp | 2 | 2024-11-26T21:40:54.435551 | from collections import Counter
def count_Occurrence(tup, lst):
count = 0
for item in tup:
if item in lst:
count+= 1
return count | count_Occurrence | easy | [{"input": "(1,2,3,4,5,6),[1,2]", "output": "2", "testtype": "functional"}] |
Mbpp_447 | Write a function to find cubes of individual elements in a list using lambda function. | 447 | mbpp | 0 | 2024-11-26T21:40:54.435736 | def cube_nums(nums):
cube_nums = list(map(lambda x: x ** 3, nums))
return cube_nums | cube_nums | easy | [{"input": "[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]", "output": "[1, 8, 27, 64, 125, 216, 343, 512, 729, 1000]", "testtype": "functional"}] |
Mbpp_447 | Write a function to find cubes of individual elements in a list using lambda function. | 447 | mbpp | 1 | 2024-11-26T21:40:54.435878 | def cube_nums(nums):
cube_nums = list(map(lambda x: x ** 3, nums))
return cube_nums | cube_nums | easy | [{"input": "[10,20,30]", "output": "([1000, 8000, 27000])", "testtype": "functional"}] |
Mbpp_447 | Write a function to find cubes of individual elements in a list using lambda function. | 447 | mbpp | 2 | 2024-11-26T21:40:54.436017 | def cube_nums(nums):
cube_nums = list(map(lambda x: x ** 3, nums))
return cube_nums | cube_nums | easy | [{"input": "[12,15]", "output": "([1728, 3375])", "testtype": "functional"}] |
Mbpp_448 | Write a function to calculate the sum of perrin numbers. | 448 | mbpp | 0 | 2024-11-26T21:40:54.436415 | def cal_sum(n):
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 | cal_sum | easy | [{"input": "9", "output": "49", "testtype": "functional"}] |
Mbpp_448 | Write a function to calculate the sum of perrin numbers. | 448 | mbpp | 1 | 2024-11-26T21:40:54.436811 | def cal_sum(n):
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 | cal_sum | easy | [{"input": "10", "output": "66", "testtype": "functional"}] |
Mbpp_448 | Write a function to calculate the sum of perrin numbers. | 448 | mbpp | 2 | 2024-11-26T21:40:54.437782 | def cal_sum(n):
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 | cal_sum | easy | [{"input": "11", "output": "88", "testtype": "functional"}] |
Mbpp_449 | Write a python function to check whether the triangle is valid or not if 3 points are given. | 449 | mbpp | 0 | 2024-11-26T21:40:54.438082 | def check_Triangle(x1,y1,x2,y2,x3,y3):
a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))
if a == 0:
return ('No')
else:
return ('Yes') | check_Triangle | easy | [{"input": "1,5,2,5,4,6", "output": "'Yes'", "testtype": "functional"}] |
Mbpp_449 | Write a python function to check whether the triangle is valid or not if 3 points are given. | 449 | mbpp | 1 | 2024-11-26T21:40:54.438368 | def check_Triangle(x1,y1,x2,y2,x3,y3):
a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))
if a == 0:
return ('No')
else:
return ('Yes') | check_Triangle | easy | [{"input": "1,1,1,4,1,5", "output": "'No'", "testtype": "functional"}] |
Mbpp_449 | Write a python function to check whether the triangle is valid or not if 3 points are given. | 449 | mbpp | 2 | 2024-11-26T21:40:54.438620 | def check_Triangle(x1,y1,x2,y2,x3,y3):
a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))
if a == 0:
return ('No')
else:
return ('Yes') | check_Triangle | easy | [{"input": "1,1,1,1,1,1", "output": "'No'", "testtype": "functional"}] |
Mbpp_450 | Write a function to extract specified size of strings from a give list of string values. | 450 | mbpp | 0 | 2024-11-26T21:40:54.438824 | def extract_string(str, l):
result = [e for e in str if len(e) == l]
return result | extract_string | easy | [{"input": "['Python', 'list', 'exercises', 'practice', 'solution'] ,8", "output": "['practice', 'solution']", "testtype": "functional"}] |
Mbpp_450 | Write a function to extract specified size of strings from a give list of string values. | 450 | mbpp | 1 | 2024-11-26T21:40:54.438971 | def extract_string(str, l):
result = [e for e in str if len(e) == l]
return result | extract_string | easy | [{"input": "['Python', 'list', 'exercises', 'practice', 'solution'] ,6", "output": "['Python']", "testtype": "functional"}] |
Mbpp_450 | Write a function to extract specified size of strings from a give list of string values. | 450 | mbpp | 2 | 2024-11-26T21:40:54.439106 | def extract_string(str, l):
result = [e for e in str if len(e) == l]
return result | extract_string | easy | [{"input": "['Python', 'list', 'exercises', 'practice', 'solution'] ,9", "output": "['exercises']", "testtype": "functional"}] |
Mbpp_451 | Write a function to remove all whitespaces from the given string using regex. | 451 | mbpp | 0 | 2024-11-26T21:40:54.439230 | import re
def remove_whitespaces(text1):
return (re.sub(r'\s+', '',text1)) | remove_whitespaces | easy | [{"input": "' Google Flutter '", "output": "'GoogleFlutter'", "testtype": "functional"}] |
Mbpp_451 | Write a function to remove all whitespaces from the given string using regex. | 451 | mbpp | 1 | 2024-11-26T21:40:54.439352 | import re
def remove_whitespaces(text1):
return (re.sub(r'\s+', '',text1)) | remove_whitespaces | easy | [{"input": "' Google Dart '", "output": "'GoogleDart'", "testtype": "functional"}] |
Mbpp_451 | Write a function to remove all whitespaces from the given string using regex. | 451 | mbpp | 2 | 2024-11-26T21:40:54.439454 | import re
def remove_whitespaces(text1):
return (re.sub(r'\s+', '',text1)) | remove_whitespaces | easy | [{"input": "' iOS Swift '", "output": "'iOSSwift'", "testtype": "functional"}] |
Mbpp_452 | Write a function that gives loss amount if the given amount has loss else return none. | 452 | mbpp | 0 | 2024-11-26T21:40:54.439601 | def loss_amount(actual_cost,sale_amount):
if(sale_amount > actual_cost):
amount = sale_amount - actual_cost
return amount
else:
return None | loss_amount | easy | [{"input": "1500,1200", "output": "None", "testtype": "functional"}] |
Mbpp_452 | Write a function that gives loss amount if the given amount has loss else return none. | 452 | mbpp | 1 | 2024-11-26T21:40:54.439764 | def loss_amount(actual_cost,sale_amount):
if(sale_amount > actual_cost):
amount = sale_amount - actual_cost
return amount
else:
return None | loss_amount | easy | [{"input": "100,200", "output": "100", "testtype": "functional"}] |
Mbpp_452 | Write a function that gives loss amount if the given amount has loss else return none. | 452 | mbpp | 2 | 2024-11-26T21:40:54.439905 | def loss_amount(actual_cost,sale_amount):
if(sale_amount > actual_cost):
amount = sale_amount - actual_cost
return amount
else:
return None | loss_amount | easy | [{"input": "2000,5000", "output": "3000", "testtype": "functional"}] |
Mbpp_453 | Write a python function to find the sum of even factors of a number. | 453 | mbpp | 0 | 2024-11-26T21:40:54.440498 | import math
def sumofFactors(n) :
if (n % 2 != 0) :
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 | sumofFactors | easy | [{"input": "18", "output": "26", "testtype": "functional"}] |
Mbpp_453 | Write a python function to find the sum of even factors of a number. | 453 | mbpp | 1 | 2024-11-26T21:40:54.441128 | import math
def sumofFactors(n) :
if (n % 2 != 0) :
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 | sumofFactors | easy | [{"input": "30", "output": "48", "testtype": "functional"}] |
Mbpp_453 | Write a python function to find the sum of even factors of a number. | 453 | mbpp | 2 | 2024-11-26T21:40:54.441704 | import math
def sumofFactors(n) :
if (n % 2 != 0) :
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 | sumofFactors | easy | [{"input": "6", "output": "8", "testtype": "functional"}] |
Mbpp_454 | Write a function that matches a word containing 'z'. | 454 | mbpp | 0 | 2024-11-26T21:40:54.441904 | import re
def text_match_wordz(text):
patterns = '\w*z.\w*'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | text_match_wordz | easy | [{"input": "\"pythonz.\"", "output": "('Found a match!')", "testtype": "functional"}] |
Mbpp_454 | Write a function that matches a word containing 'z'. | 454 | mbpp | 1 | 2024-11-26T21:40:54.442073 | import re
def text_match_wordz(text):
patterns = '\w*z.\w*'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | text_match_wordz | easy | [{"input": "\"xyz.\"", "output": "('Found a match!')", "testtype": "functional"}] |
Mbpp_454 | Write a function that matches a word containing 'z'. | 454 | mbpp | 2 | 2024-11-26T21:40:54.442222 | import re
def text_match_wordz(text):
patterns = '\w*z.\w*'
if re.search(patterns, text):
return 'Found a match!'
else:
return('Not matched!') | text_match_wordz | easy | [{"input": "\" lang .\"", "output": "('Not matched!')", "testtype": "functional"}] |
Mbpp_455 | Write a function to check whether the given month number contains 31 days or not. | 455 | mbpp | 0 | 2024-11-26T21:40:54.442449 | def check_monthnumb_number(monthnum2):
if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):
return True
else:
return False | check_monthnumb_number | easy | [{"input": "5", "output": "True", "testtype": "functional"}] |
Mbpp_455 | Write a function to check whether the given month number contains 31 days or not. | 455 | mbpp | 1 | 2024-11-26T21:40:54.443701 | def check_monthnumb_number(monthnum2):
if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):
return True
else:
return False | check_monthnumb_number | easy | [{"input": "2", "output": "False", "testtype": "functional"}] |
Mbpp_455 | Write a function to check whether the given month number contains 31 days or not. | 455 | mbpp | 2 | 2024-11-26T21:40:54.443959 | def check_monthnumb_number(monthnum2):
if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):
return True
else:
return False | check_monthnumb_number | easy | [{"input": "6", "output": "False", "testtype": "functional"}] |
Mbpp_456 | Write a function to reverse strings in a given list of string values. | 456 | mbpp | 0 | 2024-11-26T21:40:54.444129 | def reverse_string_list(stringlist):
result = [x[::-1] for x in stringlist]
return result | reverse_string_list | easy | [{"input": "['Red', 'Green', 'Blue', 'White', 'Black']", "output": "['deR', 'neerG', 'eulB', 'etihW', 'kcalB']", "testtype": "functional"}] |
Mbpp_456 | Write a function to reverse strings in a given list of string values. | 456 | mbpp | 1 | 2024-11-26T21:40:54.444279 | def reverse_string_list(stringlist):
result = [x[::-1] for x in stringlist]
return result | reverse_string_list | easy | [{"input": "['john','amal','joel','george']", "output": "['nhoj','lama','leoj','egroeg']", "testtype": "functional"}] |
Mbpp_456 | Write a function to reverse strings in a given list of string values. | 456 | mbpp | 2 | 2024-11-26T21:40:54.444435 | def reverse_string_list(stringlist):
result = [x[::-1] for x in stringlist]
return result | reverse_string_list | easy | [{"input": "['jack','john','mary']", "output": "['kcaj','nhoj','yram']", "testtype": "functional"}] |
Mbpp_457 | Write a python function to find the sublist having minimum length. | 457 | mbpp | 0 | 2024-11-26T21:40:54.444574 | def Find_Min(lst):
minList = min((x) for x in lst)
return minList | Find_Min | easy | [{"input": "[[1],[1,2],[1,2,3]]", "output": "[1]", "testtype": "functional"}] |
Mbpp_457 | Write a python function to find the sublist having minimum length. | 457 | mbpp | 1 | 2024-11-26T21:40:54.444724 | def Find_Min(lst):
minList = min((x) for x in lst)
return minList | Find_Min | easy | [{"input": "[[1,1],[1,1,1],[1,2,7,8]]", "output": "[1,1]", "testtype": "functional"}] |
Mbpp_457 | Write a python function to find the sublist having minimum length. | 457 | mbpp | 2 | 2024-11-26T21:40:54.444854 | def Find_Min(lst):
minList = min((x) for x in lst)
return minList | Find_Min | easy | [{"input": "[['x'],['x','y'],['x','y','z']]", "output": "['x']", "testtype": "functional"}] |
Mbpp_458 | Write a function to find the area of a rectangle. | 458 | mbpp | 0 | 2024-11-26T21:40:54.444968 | def rectangle_area(l,b):
area=l*b
return area | rectangle_area | easy | [{"input": "10,20", "output": "200", "testtype": "functional"}] |
Mbpp_458 | Write a function to find the area of a rectangle. | 458 | mbpp | 1 | 2024-11-26T21:40:54.445063 | def rectangle_area(l,b):
area=l*b
return area | rectangle_area | easy | [{"input": "10,5", "output": "50", "testtype": "functional"}] |
Mbpp_458 | Write a function to find the area of a rectangle. | 458 | mbpp | 2 | 2024-11-26T21:40:54.445153 | def rectangle_area(l,b):
area=l*b
return area | rectangle_area | easy | [{"input": "4,2", "output": "8", "testtype": "functional"}] |
Mbpp_459 | Write a function to remove uppercase substrings from a given string by using regex. | 459 | mbpp | 0 | 2024-11-26T21:40:54.445361 | import re
def remove_uppercase(str1):
remove_upper = lambda text: re.sub('[A-Z]', '', text)
result = remove_upper(str1)
return (result) | remove_uppercase | easy | [{"input": "'cAstyoUrFavoRitETVshoWs'", "output": "'cstyoravoitshos'", "testtype": "functional"}] |
Mbpp_459 | Write a function to remove uppercase substrings from a given string by using regex. | 459 | mbpp | 1 | 2024-11-26T21:40:54.445560 | import re
def remove_uppercase(str1):
remove_upper = lambda text: re.sub('[A-Z]', '', text)
result = remove_upper(str1)
return (result) | remove_uppercase | easy | [{"input": "'wAtchTheinTernEtrAdIo'", "output": "'wtchheinerntrdo'", "testtype": "functional"}] |
Mbpp_459 | Write a function to remove uppercase substrings from a given string by using regex. | 459 | mbpp | 2 | 2024-11-26T21:40:54.445760 | import re
def remove_uppercase(str1):
remove_upper = lambda text: re.sub('[A-Z]', '', text)
result = remove_upper(str1)
return (result) | remove_uppercase | easy | [{"input": "'VoicESeaRchAndreComMendaTionS'", "output": "'oiceachndreomendaion'", "testtype": "functional"}] |