INSTRUCTION
stringlengths
85
1.13k
RESPONSE
stringlengths
98
2.66k
SOURCE
stringclasses
2 values
Write a unit test case for a Python function with description: Write a function to calculate the sum of perrin numbers.
def check(candidate): assert cal_sum(9) == 49 assert cal_sum(10) == 66 assert cal_sum(11) == 88
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to extract specified size of strings from a given list of string values.
def check(candidate): assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,8)==['practice', 'solution'] assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,6)==['Python'] assert extract_string(['Python', 'list', 'exercises', 'practice', 'solution'] ,9)==['exercises']
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove all whitespaces from the given string.
def check(candidate): assert remove_whitespaces(' Google Flutter ') == 'GoogleFlutter' assert remove_whitespaces(' Google Dart ') == 'GoogleDart' assert remove_whitespaces(' iOS Swift ') == 'iOSSwift'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that gives loss amount on a sale if the given amount has loss else return 0.
def check(candidate): assert loss_amount(1500,1200)==0 assert loss_amount(100,200)==100 assert loss_amount(2000,5000)==3000
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of even factors of a number.
def check(candidate): assert sumofFactors(18) == 26 assert sumofFactors(30) == 48 assert sumofFactors(6) == 8
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function that matches a word containing 'z'.
def check(candidate): assert text_match_wordz("pythonz.")==True assert text_match_wordz("xyz.")==True assert text_match_wordz(" lang .")==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether the given month number contains 31 days or not.
def check(candidate): assert check_monthnumb_number(5)==True assert check_monthnumb_number(2)==False assert check_monthnumb_number(6)==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to reverse each string in a given list of string values.
def check(candidate): assert reverse_string_list(['Red', 'Green', 'Blue', 'White', 'Black'])==['deR', 'neerG', 'eulB', 'etihW', 'kcalB'] assert reverse_string_list(['john','amal','joel','george'])==['nhoj','lama','leoj','egroeg'] assert reverse_string_list(['jack','john','mary'])==['kcaj','nhoj','yram']
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sublist having minimum length.
def check(candidate): assert Find_Min([[1],[1,2],[1,2,3]]) == [1] assert Find_Min([[1,1],[1,1,1],[1,2,7,8]]) == [1,1] assert Find_Min([['x'],['x','y'],['x','y','z']]) == ['x']
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the area of a rectangle.
def check(candidate): assert rectangle_area(10,20)==200 assert rectangle_area(10,5)==50 assert rectangle_area(4,2)==8
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove uppercase substrings from a given string.
def check(candidate): assert remove_uppercase('cAstyoUrFavoRitETVshoWs') == 'cstyoravoitshos' assert remove_uppercase('wAtchTheinTernEtrAdIo') == 'wtchheinerntrdo' assert remove_uppercase('VoicESeaRchAndreComMendaTionS') == 'oiceachndreomendaion'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to get the first element of each sublist.
def check(candidate): assert Extract([[1, 2], [3, 4, 5], [6, 7, 8, 9]]) == [1, 3, 6] assert Extract([[1,2,3],[4, 5]]) == [1,4] assert Extract([[9,8,1],[1,2]]) == [9,1]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count the upper case characters in a given string.
def check(candidate): assert upper_ctr('PYthon') == 1 assert upper_ctr('BigData') == 1 assert upper_ctr('program') == 0
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find all possible combinations of the elements of a given list.
def check(candidate): assert combinations_list(['orange', 'red', 'green', 'blue'])==[[], ['orange'], ['red'], ['red', 'orange'], ['green'], ['green', 'orange'], ['green', 'red'], ['green', 'red', 'orange'], ['blue'], ['blue', 'orange'], ['blue', 'red'], ['blue', 'red', 'orange'], ['blue', 'green'], ['blue', 'green', 'orange'], ['blue', 'green', 'red'], ['blue', 'green', 'red', 'orange']] assert combinations_list(['red', 'green', 'blue', 'white', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['blue'], ['blue', 'red'], ['blue', 'green'], ['blue', 'green', 'red'], ['white'], ['white', 'red'], ['white', 'green'], ['white', 'green', 'red'], ['white', 'blue'], ['white', 'blue', 'red'], ['white', 'blue', 'green'], ['white', 'blue', 'green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['black', 'blue'], ['black', 'blue', 'red'], ['black', 'blue', 'green'], ['black', 'blue', 'green', 'red'], ['black', 'white'], ['black', 'white', 'red'], ['black', 'white', 'green'], ['black', 'white', 'green', 'red'], ['black', 'white', 'blue'], ['black', 'white', 'blue', 'red'], ['black', 'white', 'blue', 'green'], ['black', 'white', 'blue', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'blue'], ['orange', 'blue', 'red'], ['orange', 'blue', 'green'], ['orange', 'blue', 'green', 'red'], ['orange', 'white'], ['orange', 'white', 'red'], ['orange', 'white', 'green'], ['orange', 'white', 'green', 'red'], ['orange', 'white', 'blue'], ['orange', 'white', 'blue', 'red'], ['orange', 'white', 'blue', 'green'], ['orange', 'white', 'blue', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red'], ['orange', 'black', 'blue'], ['orange', 'black', 'blue', 'red'], ['orange', 'black', 'blue', 'green'], ['orange', 'black', 'blue', 'green', 'red'], ['orange', 'black', 'white'], ['orange', 'black', 'white', 'red'], ['orange', 'black', 'white', 'green'], ['orange', 'black', 'white', 'green', 'red'], ['orange', 'black', 'white', 'blue'], ['orange', 'black', 'white', 'blue', 'red'], ['orange', 'black', 'white', 'blue', 'green'], ['orange', 'black', 'white', 'blue', 'green', 'red']] assert combinations_list(['red', 'green', 'black', 'orange'])==[[], ['red'], ['green'], ['green', 'red'], ['black'], ['black', 'red'], ['black', 'green'], ['black', 'green', 'red'], ['orange'], ['orange', 'red'], ['orange', 'green'], ['orange', 'green', 'red'], ['orange', 'black'], ['orange', 'black', 'red'], ['orange', 'black', 'green'], ['orange', 'black', 'green', 'red']]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the maximum product subarray of the given array.
def check(candidate): assert max_subarray_product([1, -2, -3, 0, 7, -8, -2]) == 112 assert max_subarray_product([6, -3, -10, 0, 2]) == 180 assert max_subarray_product([-2, -40, 0, -2, -3]) == 80
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if all values are same in a dictionary.
def check(candidate): assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},10)==False assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},12)==True assert check_value({'Cierra Vega': 12, 'Alden Cantrell': 12, 'Kierra Gentry': 12, 'Pierre Cox': 12},5)==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to drop empty items from a given dictionary.
def check(candidate): assert drop_empty({'c1': 'Red', 'c2': 'Green', 'c3':None})=={'c1': 'Red', 'c2': 'Green'} assert drop_empty({'c1': 'Red', 'c2': None, 'c3':None})=={'c1': 'Red'} assert drop_empty({'c1': None, 'c2': 'Green', 'c3':None})=={ 'c2': 'Green'}
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.
def check(candidate): assert max_product([3, 100, 4, 5, 150, 6]) == 3000 assert max_product([4, 42, 55, 68, 80]) == 50265600 assert max_product([10, 22, 9, 33, 21, 50, 41, 60]) == 2460
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the pairwise addition of the neighboring elements of the given tuple.
def check(candidate): assert add_pairwise((1, 5, 7, 8, 10)) == (6, 12, 15, 18) assert add_pairwise((2, 6, 8, 9, 11)) == (8, 14, 17, 20) assert add_pairwise((3, 7, 9, 10, 12)) == (10, 16, 19, 22)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the product of the array multiplication modulo n.
def check(candidate): assert find_remainder([ 100, 10, 5, 25, 35, 14 ],11) ==9 assert find_remainder([1,1,1],1) == 0 assert find_remainder([1,2,1],2) == 0
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether the given list contains consecutive numbers or not.
def check(candidate): assert check_Consecutive([1,2,3,4,5]) == True assert check_Consecutive([1,2,3,5,6]) == False assert check_Consecutive([1,2,1]) == False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.
def check(candidate): assert tuple_intersection([(3, 4), (5, 6), (9, 10), (4, 5)] , [(5, 4), (3, 4), (6, 5), (9, 11)]) == {(4, 5), (3, 4), (5, 6)} assert tuple_intersection([(4, 1), (7, 4), (11, 13), (17, 14)] , [(1, 4), (7, 4), (16, 12), (10, 13)]) == {(4, 7), (1, 4)} assert tuple_intersection([(2, 1), (3, 2), (1, 3), (1, 4)] , [(11, 2), (2, 3), (6, 2), (1, 3)]) == {(1, 3), (2, 3)}
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to replace characters in a string.
def check(candidate): assert replace_char("polygon",'y','l')==("pollgon") assert replace_char("character",'c','a')==("aharaater") assert replace_char("python",'l','a')==("python")
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to sort a dictionary by value.
def check(candidate): assert sort_counter({'Math':81, 'Physics':83, 'Chemistry':87})==[('Chemistry', 87), ('Physics', 83), ('Math', 81)] assert sort_counter({'Math':400, 'Physics':300, 'Chemistry':250})==[('Math', 400), ('Physics', 300), ('Chemistry', 250)] assert sort_counter({'Math':900, 'Physics':1000, 'Chemistry':1250})==[('Chemistry', 1250), ('Physics', 1000), ('Math', 900)]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of the largest and smallest value in a given array.
def check(candidate): assert big_sum([1,2,3]) == 4 assert big_sum([-1,2,3,4]) == 3 assert big_sum([2,3,6]) == 8
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to convert the given string to lower case.
def check(candidate): assert is_lower("InValid") == "invalid" assert is_lower("TruE") == "true" assert is_lower("SenTenCE") == "sentence"
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove lowercase substrings from a given string.
def check(candidate): assert remove_lowercase("PYTHon")==('PYTH') assert remove_lowercase("FInD")==('FID') assert remove_lowercase("STRinG")==('STRG')
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the first digit of a given number.
def check(candidate): assert first_Digit(123) == 1 assert first_Digit(456) == 4 assert first_Digit(12) == 1
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function which takes a list of integers and only returns the odd ones.
def check(candidate): assert Split([1,2,3,4,5,6]) == [1,3,5] assert Split([10,11,12,13]) == [11,13] assert Split([7,8,9,1]) == [7,9,1]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the difference between the sum of cubes of the first n natural numbers and the sum of the first n natural numbers.
def check(candidate): assert difference(3) == 30 assert difference(5) == 210 assert difference(2) == 6
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count the number of pairs whose xor value is odd.
def check(candidate): assert find_Odd_Pair([5,4,7,2,1],5) == 6 assert find_Odd_Pair([7,2,8,1,0,5,11],7) == 12 assert find_Odd_Pair([1,2,3],3) == 2
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to toggle the case of all characters in a string.
def check(candidate): assert toggle_string("Python")==("pYTHON") assert toggle_string("Pangram")==("pANGRAM") assert toggle_string("LIttLE")==("liTTle")
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of the per-digit difference between two integers.
def check(candidate): assert digit_distance_nums(1,2) == 1 assert digit_distance_nums(23,56) == 6 assert digit_distance_nums(123,256) == 7
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the sum of the largest contiguous sublist in the given list.
def check(candidate): assert max_sub_array_sum([-2, -3, 4, -1, -2, 1, 5, -3], 8) == 7 assert max_sub_array_sum([-3, -4, 5, -2, -3, 2, 6, -4], 8) == 8 assert max_sub_array_sum([-4, -5, 6, -3, -4, 3, 7, -5], 8) == 10
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the union of the elements of two given tuples and output them in sorted order.
def check(candidate): assert union_elements((3, 4, 5, 6),(5, 7, 4, 10) ) == (3, 4, 5, 6, 7, 10) assert union_elements((1, 2, 3, 4),(3, 4, 5, 6) ) == (1, 2, 3, 4, 5, 6) assert union_elements((11, 12, 13, 14),(13, 15, 16, 17) ) == (11, 12, 13, 14, 15, 16, 17)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the length of the longest sublists.
def check(candidate): assert Find_Max_Length([[1],[1,4],[5,6,7,8]]) == 4 assert Find_Max_Length([[0,1],[2,2,],[3,2,1]]) == 3 assert Find_Max_Length([[7],[22,23],[13,14,15],[10,20,30,40,50]]) == 5
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to extract values between quotation marks from a string.
def check(candidate): assert extract_values('"Python", "PHP", "Java"')==['Python', 'PHP', 'Java'] assert extract_values('"python","program","language"')==['python','program','language'] assert extract_values('"red","blue","green","yellow"')==['red','blue','green','yellow']
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function which takes a list of integers and counts the number of possible unordered pairs where both elements are unequal.
def check(candidate): assert count_Pairs([1,2,1],3) == 2 assert count_Pairs([1,1,1,1],4) == 0 assert count_Pairs([1,2,3,4,5],5) == 10
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to split a string into characters.
def check(candidate): assert split('python') == ['p','y','t','h','o','n'] assert split('Name') == ['N','a','m','e'] assert split('program') == ['p','r','o','g','r','a','m']
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to get the sum of the digits of a non-negative integer.
def check(candidate): assert sum_digits(345)==12 assert sum_digits(12)==3 assert sum_digits(97)==16
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether a specified list is sorted or not.
def check(candidate): assert issort_list([1,2,4,6,8,10,12,14,16,17])==True assert issort_list([1, 2, 4, 6, 8, 10, 12, 14, 20, 17])==False assert issort_list([1, 2, 4, 6, 8, 10,15,14,20])==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to create a list of N empty dictionaries.
def check(candidate): assert empty_list(5)==[{},{},{},{},{}] assert empty_list(6)==[{},{},{},{},{},{}] assert empty_list(7)==[{},{},{},{},{},{},{}]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to sort each sublist of strings in a given list of lists.
def check(candidate): assert sort_sublists([['green', 'orange'], ['black', 'white'], ['white', 'black', 'orange']])==[['green', 'orange'], ['black', 'white'], ['black', 'orange', 'white']] assert sort_sublists([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])==[['green', 'orange'], ['black'], ['green', 'orange'], ['white']] assert sort_sublists([['a','b'],['d','c'],['g','h'] , ['f','e']])==[['a', 'b'], ['c', 'd'], ['g', 'h'], ['e', 'f']]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to remove duplicate numbers from a given number of lists.
def check(candidate): assert two_unique_nums([1,2,3,2,3,4,5]) == [1, 4, 5] assert two_unique_nums([1,2,3,2,4,5]) == [1, 3, 4, 5] assert two_unique_nums([1,2,3,4,5]) == [1, 2, 3, 4, 5]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to calculate the product of the unique numbers in a given list.
def check(candidate): assert unique_product([10, 20, 30, 40, 20, 50, 60, 40]) == 720000000 assert unique_product([1, 2, 3, 1,]) == 6 assert unique_product([7, 8, 9, 0, 1, 1]) == 0
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the surface area of a cylinder.
def check(candidate): assert surfacearea_cylinder(10,5)==942.45 assert surfacearea_cylinder(4,5)==226.18800000000002 assert surfacearea_cylinder(4,10)==351.848
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether a list is sublist of another or not.
def check(candidate): assert is_Sub_Array([1,4,3,5],[1,2]) == False assert is_Sub_Array([1,2,1],[1,2,1]) == True assert is_Sub_Array([1,0,2,2],[2,2,0]) ==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the last digit in factorial of a given number.
def check(candidate): assert last_Digit_Factorial(4) == 4 assert last_Digit_Factorial(21) == 0 assert last_Digit_Factorial(30) == 0
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to interleave 3 lists of the same length into a single flat list.
def check(candidate): assert interleave_lists([1,2,3,4,5,6,7],[10,20,30,40,50,60,70],[100,200,300,400,500,600,700])==[1, 10, 100, 2, 20, 200, 3, 30, 300, 4, 40, 400, 5, 50, 500, 6, 60, 600, 7, 70, 700] assert interleave_lists([10,20],[15,2],[5,10])==[10,15,5,20,2,10] assert interleave_lists([11,44], [10,15], [20,5])==[11,10,20,44,15,5]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the dissimilar elements in the given two tuples.
def check(candidate): assert find_dissimilar((3, 4, 5, 6), (5, 7, 4, 10)) == (3, 6, 7, 10) assert find_dissimilar((1, 2, 3, 4), (7, 2, 3, 9)) == (1, 4, 7, 9) assert find_dissimilar((21, 11, 25, 26), (26, 34, 21, 36)) == (34, 36, 11, 25)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove uneven elements in the nested mixed tuple.
def check(candidate): assert extract_even((4, 5, (7, 6, (2, 4)), 6, 8)) == (4, (6, (2, 4)), 6, 8) assert extract_even((5, 6, (8, 7, (4, 8)), 7, 9)) == (6, (8, (4, 8))) assert extract_even((5, 6, (9, 8, (4, 6)), 8, 10)) == (6, (8, (4, 6)), 8, 10)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the surface area of a square pyramid with a given base edge and height.
def check(candidate): assert surface_Area(3,4) == 33 assert surface_Area(4,5) == 56 assert surface_Area(1,2) == 5
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if a dictionary is empty
def check(candidate): assert my_dict({10})==False assert my_dict({11})==False assert my_dict({})==True
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function which returns nth catalan number.
def check(candidate): assert catalan_number(10)==16796 assert catalan_number(9)==4862 assert catalan_number(7)==429
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the first adverb ending with ly and its positions in a given string.
def check(candidate): assert find_adverbs("Clearly, he has no excuse for such behavior.") == '0-7: Clearly' assert find_adverbs("Please handle the situation carefuly") == '28-36: carefuly' assert find_adverbs("Complete the task quickly") == '18-25: quickly'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the n most expensive items in a given dataset.
def check(candidate): assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-2', 'price': 555.22}] assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09}],2)==[{'name': 'Item-2', 'price': 555.22},{'name': 'Item-1', 'price': 101.1}] assert expensive_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}, {'name': 'Item-3', 'price': 45.09},{'name': 'Item-4', 'price': 22.75}],1)==[{'name': 'Item-2', 'price': 555.22}]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to split a list at the nth eelment and add the first part to the end.
def check(candidate): assert split_Arr([12,10,5,6,52,36],2) == [5,6,52,36,12,10] assert split_Arr([1,2,3,4],1) == [2,3,4,1] assert split_Arr([0,1,2,3,4,5,6,7],3) == [3,4,5,6,7,0,1,2]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to convert a list to a tuple.
def check(candidate): assert list_tuple([5, 10, 7, 4, 15, 3])==(5, 10, 7, 4, 15, 3) assert list_tuple([2, 4, 5, 6, 2, 3, 4, 4, 7])==(2, 4, 5, 6, 2, 3, 4, 4, 7) assert list_tuple([58,44,56])==(58,44,56)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the difference between largest and smallest value in a given list.
def check(candidate): assert big_diff([1,2,3,4]) == 3 assert big_diff([4,5,12]) == 8 assert big_diff([9,2,3]) == 7
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find perfect squares between two given numbers.
def check(candidate): assert perfect_squares(1,30)==[1, 4, 9, 16, 25] assert perfect_squares(50,100)==[64, 81, 100] assert perfect_squares(100,200)==[100, 121, 144, 169, 196]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to convert polar coordinates to rectangular coordinates.
def check(candidate): assert polar_rect(3,4)==((5.0, 0.9272952180016122), (-2+2.4492935982947064e-16j)) assert polar_rect(4,7)==((8.06225774829855, 1.0516502125483738), (-2+2.4492935982947064e-16j)) assert polar_rect(15,17)==((22.67156809750927, 0.8478169733934057), (-2+2.4492935982947064e-16j))
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to interchange the first and last elements in a list.
def check(candidate): assert swap_List([12, 35, 9, 56, 24]) == [24, 35, 9, 56, 12] assert swap_List([1, 2, 3]) == [3, 2, 1] assert swap_List([4, 5, 6]) == [6, 5, 4]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of the product of consecutive binomial co-efficients.
def check(candidate): assert sum_Of_product(3) == 15 assert sum_Of_product(4) == 56 assert sum_Of_product(1) == 1
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to remove leading zeroes from an ip address.
def check(candidate): assert removezero_ip("216.08.094.196")==('216.8.94.196') assert removezero_ip("12.01.024")==('12.1.24') assert removezero_ip("216.08.094.0196")==('216.8.94.196')
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the difference of the first even and first odd number of a given list.
def check(candidate): assert diff_even_odd([1,3,5,7,4,1,6,8])==3 assert diff_even_odd([1,2,3,4,5,6,7,8,9,10])==1 assert diff_even_odd([1,5,7,9,10])==9
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to count minimum number of swaps required to convert one binary number represented as a string to another.
def check(candidate): assert min_Swaps("1101","1110") == 1 assert min_Swaps("111","000") == "Not Possible" assert min_Swaps("111","110") == "Not Possible"
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the size in bytes of the given tuple.
def check(candidate): assert tuple_size(("A", 1, "B", 2, "C", 3) ) == sys.getsizeof(("A", 1, "B", 2, "C", 3)) assert tuple_size((1, "Raju", 2, "Nikhil", 3, "Deepanshu") ) == sys.getsizeof((1, "Raju", 2, "Nikhil", 3, "Deepanshu")) assert tuple_size(((1, "Lion"), ( 2, "Tiger"), (3, "Fox"), (4, "Wolf")) ) == sys.getsizeof(((1, "Lion"), ( 2, "Tiger"), (3, "Fox"), (4, "Wolf")))
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find kth element from the given two sorted arrays.
def check(candidate): assert find_kth([2, 3, 6, 7, 9], [1, 4, 8, 10], 5) == 6 assert find_kth([100, 112, 256, 349, 770], [72, 86, 113, 119, 265, 445, 892], 7) == 256 assert find_kth([3, 4, 7, 8, 10], [2, 5, 9, 11], 6) == 8
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check whether the given number is armstrong or not.
def check(candidate): assert armstrong_number(153)==True assert armstrong_number(259)==False assert armstrong_number(4458)==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find sum and average of first n natural numbers.
def check(candidate): assert sum_average(10)==(55, 5.5) assert sum_average(15)==(120, 8.0) assert sum_average(20)==(210, 10.5)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to check whether the given number is even or not.
def check(candidate): assert is_Even(1) == False assert is_Even(2) == True assert is_Even(3) == False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the first repeated character in a given string.
def check(candidate): assert first_repeated_char("abcabc") == "a" assert first_repeated_char("abc") == None assert first_repeated_char("123123") == "1"
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to get all lucid numbers smaller than or equal to a given integer.
def check(candidate): assert get_ludic(10) == [1, 2, 3, 5, 7] assert get_ludic(25) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25] assert get_ludic(45) == [1, 2, 3, 5, 7, 11, 13, 17, 23, 25, 29, 37, 41, 43]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to reverse words seperated by spaces in a given string.
def check(candidate): assert reverse_words("python program")==("program python") assert reverse_words("java language")==("language java") assert reverse_words("indian man")==("man indian")
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check if the given integer is a prime number.
def check(candidate): assert prime_num(13)==True assert prime_num(7)==True assert prime_num(-1010)==False
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to convert degrees to radians.
def check(candidate): assert radian_degree(90)==1.5707963267948966 assert radian_degree(60)==1.0471975511965976 assert radian_degree(120)==2.0943951023931953
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to search a string for a regex pattern. The function should return the matching subtring, a start index and an end index.
def check(candidate): assert find_literals('The quick brown fox jumps over the lazy dog.', 'fox') == ('fox', 16, 19) assert find_literals('Its been a very crazy procedure right', 'crazy') == ('crazy', 16, 21) assert find_literals('Hardest choices required strongest will', 'will') == ('will', 35, 39)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find nth bell number.
def check(candidate): assert bell_Number(2) == 2 assert bell_Number(3) == 5 assert bell_Number(4) == 15
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function which takes a list and returns a list with the same elements, but the k'th element removed.
def check(candidate): assert remove_kth_element([1,1,2,3,4,4,5,1],3)==[1, 1, 3, 4, 4, 5, 1] assert remove_kth_element([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4],4)==[0, 0, 1, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4] assert remove_kth_element([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10],5)==[10,10,15,19, 18, 17, 26, 26, 17, 18, 10]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function which given a matrix represented as a list of lists returns the max of the n'th column.
def check(candidate): assert max_of_nth([[5, 6, 7], [1, 3, 5], [8, 9, 19]], 2) == 19 assert max_of_nth([[6, 7, 8], [2, 4, 6], [9, 10, 20]], 1) == 10 assert max_of_nth([[7, 8, 9], [3, 5, 7], [10, 11, 21]], 1) == 11
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function which takes a list of lists, where each sublist has two elements, and returns a list of two lists where the first list has the first element of each sublist and the second one has the second.
def check(candidate): assert merge([['x', 'y'], ['a', 'b'], ['m', 'n']]) == [['x', 'a', 'm'], ['y', 'b', 'n']] assert merge([[1, 2], [3, 4], [5, 6], [7, 8]]) == [[1, 3, 5, 7], [2, 4, 6, 8]] assert merge([['x', 'y','z' ], ['a', 'b','c'], ['m', 'n','o']]) == [['x', 'a', 'm'], ['y', 'b', 'n'],['z', 'c','o']]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the cumulative sum of all the values that are present in the given tuple list.
def check(candidate): assert cummulative_sum([(1, 3), (5, 6, 7), (2, 6)]) == 30 assert cummulative_sum([(2, 4), (6, 7, 8), (3, 7)]) == 37 assert cummulative_sum([(3, 5), (7, 8, 9), (4, 8)]) == 44
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function which takes a tuple of tuples and returns the average value for each tuple as a list.
def check(candidate): assert average_tuple(((10, 10, 10, 12), (30, 45, 56, 45), (81, 80, 39, 32), (1, 2, 3, 4)))==[30.5, 34.25, 27.0, 23.25] assert average_tuple(((1, 1, -5), (30, -15, 56), (81, -60, -39), (-10, 2, 3)))== [25.5, -18.0, 3.75] assert average_tuple( ((100, 100, 100, 120), (300, 450, 560, 450), (810, 800, 390, 320), (10, 20, 30, 40)))==[305.0, 342.5, 270.0, 232.5]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function which takes two tuples of the same length and performs the element wise modulo.
def check(candidate): assert tuple_modulo((10, 4, 5, 6), (5, 6, 7, 5)) == (0, 4, 5, 1) assert tuple_modulo((11, 5, 6, 7), (6, 7, 8, 6)) == (5, 5, 6, 1) assert tuple_modulo((12, 6, 7, 8), (7, 8, 9, 7)) == (5, 6, 7, 1)
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.
def check(candidate): assert min_Jumps((3,4),11)==3.5 assert min_Jumps((3,4),0)==0 assert min_Jumps((11,14),11)==1
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to divide two lists element wise.
def check(candidate): assert div_list([4,5,6],[1, 2, 3])==[4.0,2.5,2.0] assert div_list([3,2],[1,4])==[3.0, 0.5] assert div_list([90,120],[50,70])==[1.8, 1.7142857142857142]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to move all the numbers to the end of the given string.
def check(candidate): assert move_num('I1love143you55three3000thousand') == 'Iloveyouthreethousand1143553000' assert move_num('Avengers124Assemble') == 'AvengersAssemble124' assert move_num('Its11our12path13to14see15things16do17things') == 'Itsourpathtoseethingsdothings11121314151617'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the size of the largest subset of a list of numbers so that every pair is divisible.
def check(candidate): assert largest_subset([ 1, 3, 6, 13, 17, 18 ]) == 4 assert largest_subset([10, 5, 3, 15, 20]) == 3 assert largest_subset([18, 1, 3, 6, 13, 17]) == 4
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to find the median of two sorted lists of same size.
def check(candidate): assert get_median([1, 12, 15, 26, 38], [2, 13, 17, 30, 45], 5) == 16.0 assert get_median([2, 4, 8, 9], [7, 13, 19, 28], 4) == 8.5 assert get_median([3, 6, 14, 23, 36, 42], [2, 18, 27, 39, 49, 55], 6) == 25.0
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to compute the n-th power of each number in a list.
def check(candidate): assert nth_nums([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],2)==[1, 4, 9, 16, 25, 36, 49, 64, 81, 100] assert nth_nums([10,20,30],3)==([1000, 8000, 27000]) assert nth_nums([12,15],5)==([248832, 759375])
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to convert a given string to uppercase.
def check(candidate): assert is_upper("person") =="PERSON" assert is_upper("final") == "FINAL" assert is_upper("Valid") == "VALID"
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to interchange the first and last element in a given list.
def check(candidate): assert swap_List([1,2,3]) == [3,2,1] assert swap_List([1,2,3,4,4]) == [4,2,3,4,1] assert swap_List([4,5,6]) == [6,5,4]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the area of the largest triangle that can be inscribed in a semicircle with a given radius.
def check(candidate): assert triangle_area(-1) == None assert triangle_area(0) == 0 assert triangle_area(2) == 4
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the smallest missing number from a sorted list of natural numbers.
def check(candidate): assert find_First_Missing([0,1,2,3]) == 4 assert find_First_Missing([0,1,2,6,9]) == 3 assert find_First_Missing([2,3,5,8,9]) == 0
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to replace all spaces in the given string with '%20'.
def check(candidate): assert replace_spaces("My Name is Dawood") == 'My%20Name%20is%20Dawood' assert replace_spaces("I am a Programmer") == 'I%20am%20a%20Programmer' assert replace_spaces("I love Coding") == 'I%20love%20Coding'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find even numbers from a list of numbers.
def check(candidate): assert Split([1,2,3,4,5]) == [2,4] assert Split([4,5,6,7,8,0,1]) == [4,6,8,0] assert Split ([8,12,15,19]) == [8,12]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to extract all the adjacent coordinates of the given coordinate tuple.
def check(candidate): assert get_coordinates((3, 4)) == [[2, 3], [2, 4], [2, 5], [3, 3], [3, 4], [3, 5], [4, 3], [4, 4], [4, 5]] assert get_coordinates((4, 5)) ==[[3, 4], [3, 5], [3, 6], [4, 4], [4, 5], [4, 6], [5, 4], [5, 5], [5, 6]] assert get_coordinates((5, 6)) == [[4, 5], [4, 6], [4, 7], [5, 5], [5, 6], [5, 7], [6, 5], [6, 6], [6, 7]]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a function to replace whitespaces with an underscore and vice versa in a given string.
def check(candidate): assert replace_spaces('Jumanji The Jungle') == 'Jumanji_The_Jungle' assert replace_spaces('The_Avengers') == 'The Avengers' assert replace_spaces('Fast and Furious') == 'Fast_and_Furious'
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to move all zeroes to the end of the given list.
def check(candidate): assert move_zero([1,0,2,0,3,4]) == [1,2,3,4,0,0] assert move_zero([2,3,2,0,0,4,0,5,0]) == [2,3,2,4,5,0,0,0,0] assert move_zero([0,1,0,1,1]) == [1,1,1,0,0]
mbpp_sanitized
Write a unit test case for a Python function with description: Write a python function to find the sum of xor of all pairs of numbers in the given list.
def check(candidate): assert pair_xor_Sum([5,9,7,6],4) == 47 assert pair_xor_Sum([7,3,5],3) == 12 assert pair_xor_Sum([7,3],2) == 4
mbpp_sanitized