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 find the volume of a sphere. | def check(candidate):
assert math.isclose(volume_sphere(10), 4188.790204786391, rel_tol=0.001)
assert math.isclose(volume_sphere(25), 65449.84694978735, rel_tol=0.001)
assert math.isclose(volume_sphere(20), 33510.32163829113, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the character made by adding the ASCII value of all the characters of the given string modulo 26. | def check(candidate):
assert get_Char("abc") == "f"
assert get_Char("gfg") == "t"
assert get_Char("ab") == "c" | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the nth number in the newman conway sequence. | def check(candidate):
assert sequence(10) == 6
assert sequence(2) == 1
assert sequence(3) == 2 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the surface area of a sphere. | def check(candidate):
assert math.isclose(surfacearea_sphere(10), 1256.6370614359173, rel_tol=0.001)
assert math.isclose(surfacearea_sphere(15), 2827.4333882308138, rel_tol=0.001)
assert math.isclose(surfacearea_sphere(20), 5026.548245743669, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find nth centered hexagonal number. | def check(candidate):
assert centered_hexagonal_number(10) == 271
assert centered_hexagonal_number(2) == 7
assert centered_hexagonal_number(9) == 217 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to merge three dictionaries into a single dictionary. | def check(candidate):
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" },{ "O": "Orange", "W": "White", "B": "Black" })=={'B': 'Black', 'R': 'Red', 'P': 'Pink', 'G': 'Green', 'W': 'White', 'O': 'Orange'}
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" }, { "G": "Green", "W": "White" },{"L":"lavender","B":"Blue"})=={'W': 'White', 'P': 'Pink', 'B': 'Black', 'R': 'Red', 'G': 'Green', 'L': 'lavender'}
assert merge_dictionaries_three({ "R": "Red", "B": "Black", "P": "Pink" },{"L":"lavender","B":"Blue"},{ "G": "Green", "W": "White" })=={'B': 'Black', 'P': 'Pink', 'R': 'Red', 'G': 'Green', 'L': 'lavender', 'W': 'White'} | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to get the frequency of all the elements in a list, returned as a dictionary. | def check(candidate):
assert freq_count([10,10,10,10,20,20,20,20,40,40,50,50,30])==({10: 4, 20: 4, 40: 2, 50: 2, 30: 1})
assert freq_count([1,2,3,4,3,2,4,1,3,1,4])==({1:3, 2:2,3:3,4:3})
assert freq_count([5,6,7,4,9,10,4,5,6,7,9,5])==({10:1,5:3,6:2,7:2,4:2,9:2}) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the closest smaller number than n. | def check(candidate):
assert closest_num(11) == 10
assert closest_num(7) == 6
assert closest_num(12) == 11 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the length of the longest word. | def check(candidate):
assert len_log(["python","PHP","bigdata"]) == 7
assert len_log(["a","ab","abc"]) == 3
assert len_log(["small","big","tall"]) == 5 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to check if a string is present as a substring in a given list of string values. | def check(candidate):
assert find_substring(["red", "black", "white", "green", "orange"],"ack")==True
assert find_substring(["red", "black", "white", "green", "orange"],"abc")==False
assert find_substring(["red", "black", "white", "green", "orange"],"ange")==True | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to check whether the given number is undulating or not. | def check(candidate):
assert is_undulating(1212121) == True
assert is_undulating(1991) == False
assert is_undulating(121) == True | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to calculate the value of 'a' to the power 'b'. | def check(candidate):
assert power(3,4) == 81
assert power(2,3) == 8
assert power(5,5) == 3125 | mbpp_sanitized |

Write a unit test case for a Python function with description: Given a list of tuples, write a function that returns the first value of the tuple with the smallest second value. | def check(candidate):
assert index_minimum([('Rash', 143), ('Manjeet', 200), ('Varsha', 100)]) == 'Varsha'
assert index_minimum([('Yash', 185), ('Dawood', 125), ('Sanya', 175)]) == 'Dawood'
assert index_minimum([('Sai', 345), ('Salman', 145), ('Ayesha', 96)]) == 'Ayesha' | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the length of the smallest list in a list of lists. | def check(candidate):
assert Find_Min_Length([[1],[1,2]]) == 1
assert Find_Min_Length([[1,2],[1,2,3],[1,2,3,4]]) == 2
assert Find_Min_Length([[3,3,3],[4,4,4,4]]) == 3 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the number of divisors of a given integer. | def check(candidate):
assert divisor(15) == 4
assert divisor(12) == 6
assert divisor(9) == 3 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find frequency of each element in a flattened list of lists, returned in a dictionary. | def check(candidate):
assert frequency_lists([[1, 2, 3, 2], [4, 5, 6, 2], [7, 8, 9, 5]])=={1: 1, 2: 3, 3: 1, 4: 1, 5: 2, 6: 1, 7: 1, 8: 1, 9: 1}
assert frequency_lists([[1,2,3,4],[5,6,7,8],[9,10,11,12]])=={1: 1, 2: 1, 3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 9: 1,10:1,11:1,12:1}
assert frequency_lists([[20,30,40,17],[18,16,14,13],[10,20,30,40]])=={20:2,30:2,40:2,17: 1,18:1, 16: 1,14: 1,13: 1, 10: 1} | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to multiply all the numbers in a list and divide with the length of the list. | def check(candidate):
assert math.isclose(multiply_num((8, 2, 3, -1, 7)), -67.2, rel_tol=0.001)
assert math.isclose(multiply_num((-10,-20,-30)), -2000.0, rel_tol=0.001)
assert math.isclose(multiply_num((19,15,18)), 1710.0, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to convert the given decimal number to its binary equivalent, represented as a string with no leading zeros. | def check(candidate):
assert decimal_to_binary(8) == '1000'
assert decimal_to_binary(18) == '10010'
assert decimal_to_binary(7) == '111' | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the next smallest palindrome of a specified integer, returned as an integer. | def check(candidate):
assert next_smallest_palindrome(99)==101
assert next_smallest_palindrome(1221)==1331
assert next_smallest_palindrome(120)==121 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the kth element in the given array using 1-based indexing. | def check(candidate):
assert kth_element([12,3,5,7,19], 2) == 3
assert kth_element([17,24,8,23], 3) == 8
assert kth_element([16,21,25,36,4], 4) == 36 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to convert a snake case string to camel case string. | def check(candidate):
assert snake_to_camel('python_program')=='PythonProgram'
assert snake_to_camel('python_language')==('PythonLanguage')
assert snake_to_camel('programming_language')==('ProgrammingLanguage') | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the Eulerian number a(n, m). | def check(candidate):
assert eulerian_num(3, 1) == 4
assert eulerian_num(4, 1) == 11
assert eulerian_num(5, 3) == 26 | 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(([" red ","green" ],["blue "," black"],[" orange","brown"]))==[[' red ', 'green'], [' black', 'blue '], [' orange', 'brown']]
assert sort_sublists((["zilver","gold"], ["magnesium","aluminium"], ["steel", "bronze"]))==[['gold', 'zilver'],['aluminium', 'magnesium'], ['bronze', 'steel']] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to count true booleans in the given list. | def check(candidate):
assert count([True,False,True]) == 2
assert count([False,False]) == 0
assert count([True,True,True]) == 3 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to append the given list to the given tuples. | def check(candidate):
assert add_lists([5, 6, 7], (9, 10)) == (9, 10, 5, 6, 7)
assert add_lists([6, 7, 8], (10, 11)) == (10, 11, 6, 7, 8)
assert add_lists([7, 8, 9], (11, 12)) == (11, 12, 7, 8, 9) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to merge three lists into a single sorted list. | def check(candidate):
assert merge_sorted_list([25, 24, 15, 4, 5, 29, 110],[19, 20, 11, 56, 25, 233, 154],[24, 26, 54, 48])==[4, 5, 11, 15, 19, 20, 24, 24, 25, 25, 26, 29, 48, 54, 56, 110, 154, 233]
assert merge_sorted_list([1, 3, 5, 6, 8, 9], [2, 5, 7, 11], [1, 4, 7, 8, 12])==[1, 1, 2, 3, 4, 5, 5, 6, 7, 7, 8, 8, 9, 11, 12]
assert merge_sorted_list([18, 14, 10, 9, 8, 7, 9, 3, 2, 4, 1],[25, 35, 22, 85, 14, 65, 75, 25, 58],[12, 74, 9, 50, 61, 41])==[1, 2, 3, 4, 7, 8, 9, 9, 9, 10, 12, 14, 14, 18, 22, 25, 25, 35, 41, 50, 58, 61, 65, 74, 75, 85] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the number of numbers with an odd value when rotating a binary string the given number of times. | def check(candidate):
assert odd_Equivalent("011001",6) == 3
assert odd_Equivalent("11011",5) == 4
assert odd_Equivalent("1010",4) == 2 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the common elements in given nested lists. | def check(candidate):
assert set(common_in_nested_lists([[12, 18, 23, 25, 45], [7, 12, 18, 24, 28], [1, 5, 8, 12, 15, 16, 18]]))==set([18, 12])
assert set(common_in_nested_lists([[12, 5, 23, 25, 45], [7, 11, 5, 23, 28], [1, 5, 8, 18, 23, 16]]))==set([5,23])
assert set(common_in_nested_lists([[2, 3,4, 1], [4, 5], [6,4, 8],[4, 5], [6, 8,4]]))==set([4]) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to check if a string represents an integer or not. | def check(candidate):
assert check_integer("python")==False
assert check_integer("1")==True
assert check_integer("12345")==True | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to check whether all dictionaries in a list are empty or not. | def check(candidate):
assert empty_dit([{},{},{}])==True
assert empty_dit([{1,2},{},{}])==False
assert empty_dit({})==True | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to convert a given tuple of positive integers into a single integer. | def check(candidate):
assert tuple_to_int((1,2,3))==123
assert tuple_to_int((4,5,6))==456
assert tuple_to_int((5,6,7))==567 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to convert all possible convertible elements in a list of lists to floats. | def check(candidate):
assert list_to_float( [("3", "4"), ("1", "26.45"), ("7.32", "8"), ("4", "8")] ) == [(3.0, 4.0), (1.0, 26.45), (7.32, 8.0), (4.0, 8.0)]
assert list_to_float( [("4", "4"), ("2", "27"), ("4.12", "9"), ("7", "11")] ) == [(4.0, 4.0), (2.0, 27.0), (4.12, 9.0), (7.0, 11.0)]
assert list_to_float( [("6", "78"), ("5", "26.45"), ("1.33", "4"), ("82", "13")] ) == [(6.0, 78.0), (5.0, 26.45), (1.33, 4.0), (82.0, 13.0)] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to convert a string to a list of strings split on the space character. | def check(candidate):
assert string_to_list("python programming")==['python','programming']
assert string_to_list("lists tuples strings")==['lists','tuples','strings']
assert string_to_list("write a program")==['write','a','program'] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the element that appears only once in a sorted array. | def check(candidate):
assert search([1,1,2,2,3]) == 3
assert search([1,1,3,3,4,4,5,5,7,7,8]) == 8
assert search([1,2,2,3,3,4,4]) == 1 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the maximum absolute product between numbers in pairs of tuples within a given list. | def check(candidate):
assert max_product_tuple([(2, 7), (2, 6), (1, 8), (4, 9)] )==36
assert max_product_tuple([(10,20), (15,2), (5,10)] )==200
assert max_product_tuple([(11,44), (10,15), (20,5), (12, 9)] )==484 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to sum all amicable numbers from 1 to a specified number. | def check(candidate):
assert amicable_numbers_sum(999)==504
assert amicable_numbers_sum(9999)==31626
assert amicable_numbers_sum(99)==0 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to get the angle of a complex number. | def check(candidate):
assert math.isclose(angle_complex(0,1j), 1.5707963267948966, rel_tol=0.001)
assert math.isclose(angle_complex(2,1j), 0.4636476090008061, rel_tol=0.001)
assert math.isclose(angle_complex(0,2j), 1.5707963267948966, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string. | def check(candidate):
assert find_length("11000010001") == 6
assert find_length("10111") == 1
assert find_length("11011101100101") == 2 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the sum of common divisors of two given numbers. | def check(candidate):
assert sum(10,15) == 6
assert sum(100,150) == 93
assert sum(4,6) == 3 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to multiply two integers. | def check(candidate):
assert multiply_int(10,20)==200
assert multiply_int(5,10)==50
assert multiply_int(4,8)==32 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find words that are longer than n characters from a given list of words. | def check(candidate):
assert long_words(3,"python is a programming language")==['python','programming','language']
assert long_words(2,"writing a program")==['writing','program']
assert long_words(5,"sorting list")==['sorting'] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to calculate whether the matrix is a magic square. | def check(candidate):
assert magic_square_test([[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]])==True
assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 8]])==True
assert magic_square_test([[2, 7, 6], [9, 5, 1], [4, 3, 7]])==False | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the item with maximum frequency in a given list. | def check(candidate):
assert max_occurrences([2,3,8,4,7,9,8,2,6,5,1,6,1,2,3,2,4,6,9,1,2])==2
assert max_occurrences([2,3,8,4,7,9,8,7,9,15,14,10,12,13,16,18])==8
assert max_occurrences([10,20,20,30,40,90,80,50,30,20,50,10])==20 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to reverse only the vowels of a given string (where y is not a vowel). | def check(candidate):
assert reverse_vowels("Python") == "Python"
assert reverse_vowels("USA") == "ASU"
assert reverse_vowels("ab") == "ab" | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to convert a tuple to a string. | def check(candidate):
assert tup_string(('e', 'x', 'e', 'r', 'c', 'i', 's', 'e', 's'))==("exercises")
assert tup_string(('p','y','t','h','o','n'))==("python")
assert tup_string(('p','r','o','g','r','a','m'))==("program") | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to calculate the sum of the negative numbers of a given list of numbers. | def check(candidate):
assert sum_negativenum([2, 4, -6, -9, 11, -12, 14, -5, 17])==-32
assert sum_negativenum([10,15,-14,13,-18,12,-20])==-52
assert sum_negativenum([19, -65, 57, 39, 152,-639, 121, 44, 90, -190])==-894 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the nth hexagonal number. | def check(candidate):
assert hexagonal_num(10) == 190
assert hexagonal_num(5) == 45
assert hexagonal_num(7) == 91 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the ratio of zeroes to non-zeroes in an array of integers. | def check(candidate):
assert math.isclose(zero_count([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8]), 0.181818, rel_tol=0.001)
assert math.isclose(zero_count([2, 1, 2, -1, -5, 6, 4, -3, -2, 3, 4, 6, 8]), 0.00, rel_tol=0.001)
assert math.isclose(zero_count([2, 4, -6, -9, 11, -12, 14, -5, 17]), 0.00, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not. | def check(candidate):
assert is_Sum_Of_Powers_Of_Two(10) == True
assert is_Sum_Of_Powers_Of_Two(7) == False
assert is_Sum_Of_Powers_Of_Two(14) == True | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the circumference of a circle. | def check(candidate):
assert math.isclose(circle_circumference(10), 62.830000000000005, rel_tol=0.001)
assert math.isclose(circle_circumference(5), 31.415000000000003, rel_tol=0.001)
assert math.isclose(circle_circumference(4), 25.132, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to flatten the list of lists into a single set of numbers. | def check(candidate):
assert set(extract_singly([(3, 4, 5), (4, 5, 7), (1, 4)])) == set([3, 4, 5, 7, 1])
assert set(extract_singly([(1, 2, 3), (4, 2, 3), (7, 8)])) == set([1, 2, 3, 4, 7, 8])
assert set(extract_singly([(7, 8, 9), (10, 11, 12), (10, 11)])) == set([7, 8, 9, 10, 11, 12]) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to sort a list of elements. | def check(candidate):
assert pancake_sort([15, 79, 25, 38, 69]) == [15, 25, 38, 69, 79]
assert pancake_sort([98, 12, 54, 36, 85]) == [12, 36, 54, 85, 98]
assert pancake_sort([41, 42, 32, 12, 23]) == [12, 23, 32, 41, 42] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to count number items that are identical in the same position of three given lists. | def check(candidate):
assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,9],[2,1,3,1,2,6,7,9])==3
assert count_samepair([1,2,3,4,5,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==4
assert count_samepair([1,2,3,4,2,6,7,8],[2,2,3,1,2,6,7,8],[2,1,3,1,2,6,7,8])==5 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find number of lists present in the given tuple. | def check(candidate):
assert find_lists(([1, 2, 3, 4], [5, 6, 7, 8])) == 2
assert find_lists(([1, 2], [3, 4], [5, 6])) == 3
assert find_lists(([9, 8, 7, 6, 5, 4, 3, 2, 1])) == 1 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the maximum difference between any two elements in a given array. | def check(candidate):
assert max_Abs_Diff((2,1,5,3)) == 4
assert max_Abs_Diff((9,3,2,5,1)) == 8
assert max_Abs_Diff((3,2,1)) == 2 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that returns integers x and y that satisfy ax + by = n as a tuple, or return None if no solution exists. | def check(candidate):
assert find_solution(2, 3, 7) == (2, 1)
assert find_solution(4, 2, 7) == None
assert find_solution(1, 13, 17) == (4, 1) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to remove all elements from a given list present in another list. | def check(candidate):
assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [2, 4, 6, 8]) == [1, 3, 5, 7, 9, 10]
assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [1, 3, 5, 7]) == [2, 4, 6, 8, 9, 10]
assert remove_elements([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [5, 7]) == [1, 2, 3, 4, 6, 8, 9, 10] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to calculate the sum (n - 2*i) from i=0 to n // 2, for instance n + (n-2) + (n-4)... (until n-x =< 0). | def check(candidate):
assert sum_series(6) == 12
assert sum_series(10) == 30
assert sum_series(9) == 25 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to calculate the area of a regular polygon given the length and number of its sides. | def check(candidate):
assert math.isclose(area_polygon(4, 20), 400., rel_tol=0.001)
assert math.isclose(area_polygon(10, 15), 1731.197, rel_tol=0.001)
assert math.isclose(area_polygon(9, 7), 302.909, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to determine if the sum of the divisors of two integers are the same. | def check(candidate):
assert are_equivalent(36, 57) == False
assert are_equivalent(2, 4) == False
assert are_equivalent(23, 47) == True | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to count the number of characters in a string that occur at the same position in the string as in the English alphabet (case insensitive). | def check(candidate):
assert count_char_position("xbcefg") == 2
assert count_char_position("ABcED") == 3
assert count_char_position("AbgdeF") == 5 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that counts the number of pairs of integers in a list that xor to an even number. | def check(candidate):
assert find_even_pair([5, 4, 7, 2, 1]) == 4
assert find_even_pair([7, 2, 8, 1, 0, 5, 11]) == 9
assert find_even_pair([1, 2, 3]) == 1 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the smallest power of 2 greater than or equal to n. | def check(candidate):
assert next_power_of_2(0) == 1
assert next_power_of_2(5) == 8
assert next_power_of_2(17) == 32 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to count the number of occurrences of a number in a given list. | def check(candidate):
assert frequency([1,2,3], 4) == 0
assert frequency([1,2,2,3,3,3,4], 3) == 3
assert frequency([0,1,2,3,1,2], 1) == 2 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the sum of numbers in a list within a range specified by two indices. | def check(candidate):
assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 8, 10) == 29
assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 5, 7) == 16
assert sum_range_list([2,1,5,6,8,3,4,9,10,11,8,12], 7, 10) == 38 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the perimeter of a regular pentagon from the length of its sides. | def check(candidate):
assert perimeter_pentagon(5) == 25
assert perimeter_pentagon(10) == 50
assert perimeter_pentagon(15) == 75 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to count the number of occurence of the string 'std' in a given string. | def check(candidate):
assert count_occurance("letstdlenstdporstd") == 3
assert count_occurance("truststdsolensporsd") == 1
assert count_occurance("makestdsostdworthit") == 2
assert count_occurance("stds") == 1
assert count_occurance("") == 0 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to check if all the elements in tuple have same data type or not. | def check(candidate):
assert check_type((5, 6, 7, 3, 5, 6) ) == True
assert check_type((1, 2, "4") ) == False
assert check_type((3, 2, 1, 4, 5) ) == True | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in a sorted array, its length (n), and an element and returns whether the element is the majority element in the given sorted array. (The majority element is the element that occurs more than n/2 times.) | def check(candidate):
assert is_majority([1, 2, 3, 3, 3, 3, 10], 7, 3) == True
assert is_majority([1, 1, 2, 4, 4, 4, 6, 6], 8, 4) == False
assert is_majority([1, 1, 1, 2, 2], 5, 1) == True
assert is_majority([1, 1, 2, 2], 5, 1) == False | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to count the number of set bits (binary digits with value 1) in a given number. | def check(candidate):
assert count_Set_Bits(2) == 1
assert count_Set_Bits(4) == 1
assert count_Set_Bits(6) == 2 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to remove the characters which have odd index values of a given string. | def check(candidate):
assert odd_values_string('abcdef') == 'ace'
assert odd_values_string('python') == 'pto'
assert odd_values_string('data') == 'dt'
assert odd_values_string('lambs') == 'lms' | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find minimum of three numbers. | def check(candidate):
assert min_of_three(10,20,0)==0
assert min_of_three(19,15,18)==15
assert min_of_three(-10,-20,-30)==-30 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to check whether all the bits are unset in the given range or not. | def check(candidate):
assert all_Bits_Set_In_The_Given_Range(4,1,2) == True
assert all_Bits_Set_In_The_Given_Range(17,2,4) == True
assert all_Bits_Set_In_The_Given_Range(39,4,6) == False | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in an array and an integer n, and re-arranges the first n elements of the given array so that all negative elements appear before positive ones, and where the relative order among negative and positive elements is preserved. | def check(candidate):
assert re_arrange_array([-1, 2, -3, 4, 5, 6, -7, 8, 9], 9) == [-1, -3, -7, 4, 5, 6, 2, 8, 9]
assert re_arrange_array([12, -14, -26, 13, 15], 5) == [-14, -26, 12, 13, 15]
assert re_arrange_array([10, 24, 36, -42, -39, -78, 85], 7) == [-42, -39, -78, 10, 24, 36, 85] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in a string and character, replaces blank spaces in the string with the character, and returns the string. | def check(candidate):
assert replace_blank("hello people",'@')==("hello@people")
assert replace_blank("python program language",'$')==("python$program$language")
assert replace_blank("blank space","-")==("blank-space") | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in a list and an integer n and returns a list containing the n largest items from the list. | def check(candidate):
assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],2))==set([100,90])
assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],5))==set([100,90,80,70,60])
assert set(larg_nnum([10, 20, 50, 70, 90, 20, 50, 40, 60, 80, 100],3))==set([100,90,80]) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the lateral surface area of a cylinder. | def check(candidate):
assert math.isclose(lateralsuface_cylinder(10,5), 314.15000000000003, rel_tol=0.001)
assert math.isclose(lateralsuface_cylinder(4,5), 125.66000000000001, rel_tol=0.001)
assert math.isclose(lateralsuface_cylinder(4,10), 251.32000000000002, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the volume of a cube given its side length. | def check(candidate):
assert volume_cube(3)==27
assert volume_cube(2)==8
assert volume_cube(5)==125 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to set all even bits of a given number. | def check(candidate):
assert even_bit_set_number(10) == 10
assert even_bit_set_number(20) == 30
assert even_bit_set_number(30) == 30 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in a list of tuples and returns a dictionary mapping each unique tuple to the number of times it occurs in the list. | def check(candidate):
assert check_occurences([(3, 1), (1, 3), (2, 5), (5, 2), (6, 3)] ) == {(1, 3): 2, (2, 5): 2, (3, 6): 1}
assert check_occurences([(4, 2), (2, 4), (3, 6), (6, 3), (7, 4)] ) == {(2, 4): 2, (3, 6): 2, (4, 7): 1}
assert check_occurences([(13, 2), (11, 23), (12, 25), (25, 12), (16, 23)] ) == {(2, 13): 1, (11, 23): 1, (12, 25): 2, (16, 23): 1} | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to count the number of non-empty substrings of a given string. | def check(candidate):
assert number_of_substrings("abc") == 6
assert number_of_substrings("abcd") == 10
assert number_of_substrings("abcde") == 15 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in positive integers m and n and finds the number of possible sequences of length n, such that each element is a positive integer and is greater than or equal to twice the previous element but less than or equal to m. | def check(candidate):
assert get_total_number_of_sequences(10, 4) == 4
assert get_total_number_of_sequences(5, 2) == 6
assert get_total_number_of_sequences(16, 3) == 84 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in two lists and replaces the last element of the first list with the elements of the second list. | def check(candidate):
assert replace_list([1, 3, 5, 7, 9, 10],[2, 4, 6, 8])==[1, 3, 5, 7, 9, 2, 4, 6, 8]
assert replace_list([1,2,3,4,5],[5,6,7,8])==[1,2,3,4,5,6,7,8]
assert replace_list(["red","blue","green"],["yellow"])==["red","blue","yellow"] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to count the total number of characters in a string. | def check(candidate):
assert count_charac("python programming")==18
assert count_charac("language")==8
assert count_charac("words")==5 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to find the next perfect square greater than a given number. | def check(candidate):
assert next_Perfect_Square(35) == 36
assert next_Perfect_Square(6) == 9
assert next_Perfect_Square(9) == 16 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes an array and finds the maximum sum of a bitonic subsequence for the given array, where a sequence is bitonic if it is first increasing and then decreasing. | def check(candidate):
assert max_sum([1, 15, 51, 45, 33, 100, 12, 18, 9]) == 194
assert max_sum([80, 60, 30, 40, 20, 10]) == 210
assert max_sum([2, 3 ,14, 16, 21, 23, 29, 30]) == 138 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function for computing square roots using the babylonian method. | def check(candidate):
assert math.isclose(babylonian_squareroot(10), 3.162277660168379, rel_tol=0.001)
assert math.isclose(babylonian_squareroot(2), 1.414213562373095, rel_tol=0.001)
assert math.isclose(babylonian_squareroot(9), 3.0, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the length of the longest palindromic subsequence in the given string. | def check(candidate):
assert lps("TENS FOR TENS") == 5
assert lps("CARDIO FOR CARDS") == 7
assert lps("PART OF THE JOURNEY IS PART") == 9 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in an integer n and calculates the harmonic sum of n-1. | def check(candidate):
assert math.isclose(harmonic_sum(7), 2.5928571428571425, rel_tol=0.001)
assert math.isclose(harmonic_sum(4), 2.083333333333333, rel_tol=0.001)
assert math.isclose(harmonic_sum(19), 3.547739657143682, rel_tol=0.001) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the intersection of two arrays. | def check(candidate):
assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[1, 2, 4, 8, 9])==[1, 2, 8, 9]
assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[3,5,7,9])==[3,5,7,9]
assert intersection_array([1, 2, 3, 5, 7, 8, 9, 10],[10,20,30,40])==[10] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function that takes in a tuple and an element and counts the occcurences of the element in the tuple. | def check(candidate):
assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),4) == 0
assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),10) == 3
assert count_X((10, 8, 5, 2, 10, 15, 10, 8, 5, 8, 8, 2),8) == 4 | mbpp_sanitized |

Write a unit test case for a Python function with description: 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 check(candidate):
assert insert_element(['Red', 'Green', 'Black'] ,'c')==['c', 'Red', 'c', 'Green', 'c', 'Black']
assert insert_element(['python', 'java'] ,'program')==['program', 'python', 'program', 'java']
assert insert_element(['happy', 'sad'] ,'laugh')==['laugh', 'happy', 'laugh', 'sad'] | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function to convert complex numbers to polar coordinates. | def check(candidate):
assert convert(1) == (1.0, 0.0)
assert convert(4) == (4.0,0.0)
assert convert(5) == (5.0,0.0) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a python function that returns the number of integer elements in a given list. | def check(candidate):
assert count_integer([1,2,'abc',1.2]) == 2
assert count_integer([1,2,3]) == 3
assert count_integer([1,1.2,4,5.1]) == 2 | mbpp_sanitized |

Write a unit test case for a Python function with description: 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. | def check(candidate):
assert combinations_colors( ["Red","Green","Blue"],1)==[('Red',), ('Green',), ('Blue',)]
assert combinations_colors( ["Red","Green","Blue"],2)==[('Red', 'Red'), ('Red', 'Green'), ('Red', 'Blue'), ('Green', 'Green'), ('Green', 'Blue'), ('Blue', 'Blue')]
assert combinations_colors( ["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')] | mbpp_sanitized |

Write a unit test case for a Python function with description: 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 check(candidate):
assert count_Primes_nums(5) == 2
assert count_Primes_nums(10) == 4
assert count_Primes_nums(100) == 25 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in two numbers and returns a tuple with the second number and then the first number. | def check(candidate):
assert swap_numbers(10,20)==(20,10)
assert swap_numbers(15,17)==(17,15)
assert swap_numbers(100,200)==(200,100) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to maximize the given two tuples. | def check(candidate):
assert maximize_elements(((1, 3), (4, 5), (2, 9), (1, 10)), ((6, 7), (3, 9), (1, 1), (7, 3))) == ((6, 7), (4, 9), (2, 9), (7, 10))
assert maximize_elements(((2, 4), (5, 6), (3, 10), (2, 11)), ((7, 8), (4, 10), (2, 2), (8, 4))) == ((7, 8), (5, 10), (3, 10), (8, 11))
assert maximize_elements(((3, 5), (6, 7), (4, 11), (3, 12)), ((8, 9), (5, 11), (3, 3), (9, 5))) == ((8, 9), (6, 11), (4, 11), (9, 12)) | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function to find the nth newman–shanks–williams prime number. | def check(candidate):
assert newman_prime(3) == 7
assert newman_prime(4) == 17
assert newman_prime(5) == 41 | mbpp_sanitized |

Write a unit test case for a Python function with description: Write a function that takes in two tuples and performs mathematical division operation element-wise across the given tuples. | def check(candidate):
assert division_elements((10, 4, 6, 9),(5, 2, 3, 3)) == (2, 2, 2, 3)
assert division_elements((12, 6, 8, 16),(6, 3, 4, 4)) == (2, 2, 2, 4)
assert division_elements((20, 14, 36, 18),(5, 7, 6, 9)) == (4, 2, 6, 2) | mbpp_sanitized |