text
stringlengths
297
1.47k
You are an expert Python programmer, and here is your task: Write a function to find the equilibrium index of the given array. Your code should pass these tests: assert equilibrium_index([1, 2, 3, 4, 1, 2, 3]) == 3 assert equilibrium_index([-7, 1, 5, 2, -4, 3, 0]) == 3 assert equilibrium_index([1, 2, 3]) == -1 [BEGIN]...
You are an expert Python programmer, and here is your task: Write a function to find the minimum number of elements that should be removed such that amax-amin<=k. Your code should pass these tests: assert removals([1, 3, 4, 9, 10,11, 12, 17, 20], 9, 4) == 5 assert removals([1, 5, 6, 2, 8], 5, 2) == 3 assert removals([...
You are an expert Python programmer, and here is your task: Write a function to check whether the given key is present in the dictionary or not. Your code should pass these tests: assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},5)==True assert is_key_present({1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60},...
You are an expert Python programmer, and here is your task: Write a function to calculate the harmonic sum of n-1. Your code should pass these tests: assert harmonic_sum(10)==2.9289682539682538 assert harmonic_sum(4)==2.083333333333333 assert harmonic_sum(7)==2.5928571428571425 [BEGIN] def harmonic_sum(n): if n < ...
You are an expert Python programmer, and here is your task: Write a function to sort a list of lists by length and value. Your code should pass these tests: assert sort_sublists([[2], [0], [1, 3], [0, 7], [9, 11], [13, 15, 17]])==[[0], [2], [0, 7], [1, 3], [9, 11], [13, 15, 17]] assert sort_sublists([[1], [2, 3], [4, ...
You are an expert Python programmer, and here is your task: Write a function to find whether an array is subset of another array. Your code should pass these tests: assert is_subset([11, 1, 13, 21, 3, 7], 6, [11, 3, 7, 1], 4) == True assert is_subset([1, 2, 3, 4, 5, 6], 6, [1, 2, 4], 3) == True assert is_subset([10, 5...
You are an expert Python programmer, and here is your task: Write a python function to count the total set bits from 1 to n. Your code should pass these tests: assert count_Set_Bits(16) == 33 assert count_Set_Bits(2) == 2 assert count_Set_Bits(14) == 28 [BEGIN] def count_Set_Bits(n) : n += 1; powerOf2 = 2...
You are an expert Python programmer, and here is your task: Write a python function to convert a string to a list. Your code should pass these tests: assert Convert('python program') == ['python','program'] assert Convert('Data Analysis') ==['Data','Analysis'] assert Convert('Hadoop Training') == ['Hadoop','Training']...
You are an expert Python programmer, and here is your task: Write a function to count unique keys for each value present in the tuple. Your code should pass these tests: assert get_unique([(3, 4), (1, 2), (2, 4), (8, 2), (7, 2), (8, 1), (9, 1), (8, 4), (10, 4)] ) == '{4: 4, 2: 3, 1: 2}' assert get_unique([(4, 5), (2, ...
You are an expert Python programmer, and here is your task: Write a function to access the initial and last data of the given tuple record. Your code should pass these tests: assert front_and_rear((10, 4, 5, 6, 7)) == (10, 7) assert front_and_rear((1, 2, 3, 4, 5)) == (1, 5) assert front_and_rear((6, 7, 8, 9, 10)) == (...
You are an expert Python programmer, and here is your task: Write a python function to check whether the product of digits of a number at even and odd places is equal or not. Your code should pass these tests: assert product_Equal(2841) == True assert product_Equal(1234) == False assert product_Equal(1212) == False [B...
You are an expert Python programmer, and here is your task: Write a function to remove duplicates from a list of lists. Your code should pass these tests: assert remove_duplicate([[10, 20], [40], [30, 56, 25], [10, 20], [33], [40]])==[[10, 20], [30, 56, 25], [33], [40]] assert remove_duplicate(["a", "b", "a", "c", "c...
You are an expert Python programmer, and here is your task: Write a function to check if the given tuple contains all valid values or not. Your code should pass these tests: assert check_valid((True, True, True, True) ) == True assert check_valid((True, False, True, True) ) == False assert check_valid((True, True, Tru...
You are an expert Python programmer, and here is your task: Write a python function to count the number of distinct power of prime factor of given number. Your code should pass these tests: assert count_Fac(24) == 3 assert count_Fac(12) == 2 assert count_Fac(4) == 1 [BEGIN] def count_Fac(n): m = n count =...
You are an expert Python programmer, and here is your task: Write a function to convert the given string of integers into a tuple. Your code should pass these tests: assert str_to_tuple("1, -5, 4, 6, 7") == (1, -5, 4, 6, 7) assert str_to_tuple("1, 2, 3, 4, 5") == (1, 2, 3, 4, 5) assert str_to_tuple("4, 6, 9, 11, 13, 1...
You are an expert Python programmer, and here is your task: Write a function to find the perimeter of a rombus. Your code should pass these tests: assert rombus_perimeter(10)==40 assert rombus_perimeter(5)==20 assert rombus_perimeter(4)==16 [BEGIN] def rombus_perimeter(a): perimeter=4*a return perimeter [DONE]
You are an expert Python programmer, and here is your task: Write a function to calculate the standard deviation. Your code should pass these tests: assert sd_calc([4, 2, 5, 8, 6])== 2.23606797749979 assert sd_calc([1,2,3,4,5,6,7])==2.160246899469287 assert sd_calc([5,9,10,15,6,4])==4.070217029430577 [BEGIN] import ma...
You are an expert Python programmer, and here is your task: Write a function to create a list taking alternate elements from another given list. Your code should pass these tests: assert alternate_elements(["red", "black", "white", "green", "orange"])==['red', 'white', 'orange'] assert alternate_elements([2, 0, 3, 4, ...
You are an expert Python programmer, and here is your task: Write a function that matches a string that has an a followed by zero or more b's. Your code should pass these tests: assert text_match("ac")==('Found a match!') assert text_match("dc")==('Not matched!') assert text_match("abba")==('Found a match!') [BEGIN] i...
You are an expert Python programmer, and here is your task: Write a function to add a dictionary to the tuple. Your code should pass these tests: assert add_dict_to_tuple((4, 5, 6), {"MSAM" : 1, "is" : 2, "best" : 3} ) == (4, 5, 6, {'MSAM': 1, 'is': 2, 'best': 3}) assert add_dict_to_tuple((1, 2, 3), {"UTS" : 2, "is" :...
You are an expert Python programmer, and here is your task: Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n. Your code should pass these tests: assert maxAverageOfPath([[1, 2, 3], [6, 5, 4], [7, 3, 9]], 3) == 5.2 assert maxAverageOfPath([[2, 3, 4...
You are an expert Python programmer, and here is your task: Write a function to filter the height and width of students which are stored in a dictionary. Your code should pass these tests: assert filter_data({'Cierra Vega': (6.2, 70), 'Alden Cantrell': (5.9, 65), 'Kierra Gentry': (6.0, 68), 'Pierre Cox': (5.8, 66)},6....
You are an expert Python programmer, and here is your task: Write a function to count the same pair in two given lists using map function. Your code should pass these tests: assert count_same_pair([1, 2, 3, 4, 5, 6, 7, 8],[2, 2, 3, 1, 2, 6, 7, 9])==4 assert count_same_pair([0, 1, 2, -1, -5, 6, 0, -3, -2, 3, 4, 6, 8],[...
You are an expert Python programmer, and here is your task: Write a function to calculate the sum of all digits of the base to the specified power. Your code should pass these tests: assert power_base_sum(2,100)==115 assert power_base_sum(8,10)==37 assert power_base_sum(8,15)==62 [BEGIN] def power_base_sum(base, power...
You are an expert Python programmer, and here is your task: Write a function to extract values between quotation marks of the given string by using regex. Your code should pass these tests: assert extract_quotation('Cortex "A53" Based "multi" tasking "Processor"') == ['A53', 'multi', 'Processor'] assert extract_quotat...
You are an expert Python programmer, and here is your task: Write a function to multiply the adjacent elements of the given tuple. Your code should pass these tests: assert multiply_elements((1, 5, 7, 8, 10)) == (5, 35, 56, 80) assert multiply_elements((2, 4, 5, 6, 7)) == (8, 20, 30, 42) assert multiply_elements((12, ...
You are an expert Python programmer, and here is your task: Write a function to remove all characters except letters and numbers using regex Your code should pass these tests: assert remove_char("123abcjw:, .@! eiw") == '123abcjweiw' assert remove_char("Hello1234:, ! Howare33u") == 'Hello1234Howare33u' assert remove_c...
You are an expert Python programmer, and here is your task: Write a function to sum elements in two lists. Your code should pass these tests: assert sum_list([10,20,30],[15,25,35])==[25,45,65] assert sum_list([1,2,3],[5,6,7])==[6,8,10] assert sum_list([15,20,30],[15,45,75])==[30,65,105] [BEGIN] def sum_list(lst1,lst2)...
You are an expert Python programmer, and here is your task: Write a function to add two lists using map and lambda function. Your code should pass these tests: assert add_list([1, 2, 3],[4,5,6])==[5, 7, 9] assert add_list([1,2],[3,4])==[4,6] assert add_list([10,20],[50,70])==[60,90] [BEGIN] def add_list(nums1,nums2): ...
You are an expert Python programmer, and here is your task: Write a function to remove consecutive duplicates of a given list. Your code should pass these tests: assert consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4 ])==[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 4] assert consecutive_duplicates([10, 10, 15...
You are an expert Python programmer, and here is your task: Write a function to find the lateral surface area of a cone. Your code should pass these tests: assert lateralsurface_cone(5,12)==204.20352248333654 assert lateralsurface_cone(10,15)==566.3586699569488 assert lateralsurface_cone(19,17)==1521.8090132193388 [BE...
You are an expert Python programmer, and here is your task: Write a function to replace all occurrences of spaces, commas, or dots with a colon. Your code should pass these tests: assert replace_specialchar('Python language, Programming language.')==('Python:language::Programming:language:') assert replace_specialchar...
You are an expert Python programmer, and here is your task: Write a function to find the index of the first occurrence of a given number in a sorted array. Your code should pass these tests: assert find_first_occurrence([2, 5, 5, 5, 6, 6, 8, 9, 9, 9], 5) == 1 assert find_first_occurrence([2, 3, 5, 5, 6, 6, 8, 9, 9, 9]...
You are an expert Python programmer, and here is your task: Write a python function to find sum of products of all possible subarrays. Your code should pass these tests: assert sum_Of_Subarray_Prod([1,2,3],3) == 20 assert sum_Of_Subarray_Prod([1,2],2) == 5 assert sum_Of_Subarray_Prod([1,2,3,4],4) == 84 [BEGIN] def sum...
You are an expert Python programmer, and here is your task: Write a python function to toggle bits of the number except the first and the last bit. Your code should pass these tests: assert toggle_middle_bits(9) == 15 assert toggle_middle_bits(10) == 12 assert toggle_middle_bits(11) == 13 [BEGIN] def set_middle_bits(n...
You are an expert Python programmer, and here is your task: Write a function to locate the left insertion point for a specified value in sorted order. Your code should pass these tests: assert left_insertion([1,2,4,5],6)==4 assert left_insertion([1,2,4,5],3)==2 assert left_insertion([1,2,4,5],7)==4 [BEGIN] import bise...
You are an expert Python programmer, and here is your task: Write a function to check whether the given string is starting with a vowel or not using regex. Your code should pass these tests: assert check_str("annie") == 'Valid' assert check_str("dawood") == 'Invalid' assert check_str("Else") == 'Valid' [BEGIN] import ...
You are an expert Python programmer, and here is your task: Write a function to calculate the geometric sum of n-1. Your code should pass these tests: assert geometric_sum(7) == 1.9921875 assert geometric_sum(4) == 1.9375 assert geometric_sum(8) == 1.99609375 [BEGIN] def geometric_sum(n): if n < 0: return 0 ...
You are an expert Python programmer, and here is your task: Write a python function to find the index of smallest triangular number with n digits. Your code should pass these tests: assert find_Index(2) == 4 assert find_Index(3) == 14 assert find_Index(4) == 45 [BEGIN] import math def find_Index(n): x = math.s...
You are an expert Python programmer, and here is your task: Write a function to convert the given tuple to a key-value dictionary using adjacent elements. Your code should pass these tests: assert tuple_to_dict((1, 5, 7, 10, 13, 5)) == {1: 5, 7: 10, 13: 5} assert tuple_to_dict((1, 2, 3, 4, 5, 6)) == {1: 2, 3: 4, 5: 6}...
You are an expert Python programmer, and here is your task: Write a python function to check whether all the characters are same or not. Your code should pass these tests: assert all_Characters_Same("python") == False assert all_Characters_Same("aaa") == True assert all_Characters_Same("data") == False [BEGIN] def all...
You are an expert Python programmer, and here is your task: Write a function to caluclate the area of a tetrahedron. Your code should pass these tests: assert area_tetrahedron(3)==15.588457268119894 assert area_tetrahedron(20)==692.8203230275509 assert area_tetrahedron(10)==173.20508075688772 [BEGIN] import math def ...
You are an expert Python programmer, and here is your task: Write a function to rotate a given list by specified number of items to the right direction. Your code should pass these tests: assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8, 9, 10],3,4)==[8, 9, 10, 1, 2, 3, 4, 5, 6] assert rotate_right([1, 2, 3, 4, 5, 6, 7, 8,...
You are an expert Python programmer, and here is your task: Write a function to check if the given tuple has any none value or not. Your code should pass these tests: assert check_none((10, 4, 5, 6, None)) == True assert check_none((7, 8, 9, 11, 14)) == False assert check_none((1, 2, 3, 4, None)) == True [BEGIN] def c...
You are an expert Python programmer, and here is your task: Write a function to find numbers within a given range where every number is divisible by every digit it contains. Your code should pass these tests: assert divisible_by_digits(1,22)==[1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 12, 15, 22] assert divisible_by_digits(1,15)...
You are an expert Python programmer, and here is your task: Write a function to find area of a sector. Your code should pass these tests: assert sector_area(4,45)==6.285714285714286 assert sector_area(9,45)==31.82142857142857 assert sector_area(9,360)==None [BEGIN] def sector_area(r,a): pi=22/7 if a >= 360: ...
You are an expert Python programmer, and here is your task: Write a function to find the longest common subsequence for the given three string sequence. Your code should pass these tests: assert lcs_of_three('AGGT12', '12TXAYB', '12XBA', 6, 7, 5) == 2 assert lcs_of_three('Reels', 'Reelsfor', 'ReelsforReels', 5, 8, 13)...
You are an expert Python programmer, and here is your task: Write a function to put spaces between words starting with capital letters in a given string by using regex. Your code should pass these tests: assert capital_words_spaces("Python") == 'Python' assert capital_words_spaces("PythonProgrammingExamples") == 'Pyth...
You are an expert Python programmer, and here is your task: Write a function to sort a given list of strings of numbers numerically. Your code should pass these tests: assert sort_numeric_strings( ['4','12','45','7','0','100','200','-12','-500'])==[-500, -12, 0, 4, 7, 12, 45, 100, 200] assert sort_numeric_strings(['2'...
You are an expert Python programmer, and here is your task: Write a function to add the given tuple to the given list. Your code should pass these tests: assert add_tuple([5, 6, 7], (9, 10)) == [5, 6, 7, 9, 10] assert add_tuple([6, 7, 8], (10, 11)) == [6, 7, 8, 10, 11] assert add_tuple([7, 8, 9], (11, 12)) == [7, 8, 9...
You are an expert Python programmer, and here is your task: Write a function to check if the given array represents min heap or not. Your code should pass these tests: assert check_min_heap([1, 2, 3, 4, 5, 6], 0) == True assert check_min_heap([2, 3, 4, 5, 10, 15], 0) == True assert check_min_heap([2, 10, 4, 5, 3, 15],...
You are an expert Python programmer, and here is your task: Write a function to find the nth jacobsthal number. Your code should pass these tests: assert jacobsthal_num(5) == 11 assert jacobsthal_num(2) == 1 assert jacobsthal_num(4) == 5 [BEGIN] def jacobsthal_num(n): dp = [0] * (n + 1) dp[0] = 0 dp[1] = 1 f...
You are an expert Python programmer, and here is your task: Write a function to find minimum k records from tuple list. Your code should pass these tests: assert min_k([('Manjeet', 10), ('Akshat', 4), ('Akash', 2), ('Nikhil', 8)], 2) == [('Akash', 2), ('Akshat', 4)] assert min_k([('Sanjeev', 11), ('Angat', 5), ('Akash...
You are an expert Python programmer, and here is your task: Write a function to find common index elements from three lists. Your code should pass these tests: assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, 3, 4, 5, 7],[0, 1, 2, 3, 4, 5, 7])==[1, 7] assert extract_index_list([1, 1, 3, 4, 5, 6, 7],[0, 1, 2, ...
You are an expert Python programmer, and here is your task: Write a function to find the second smallest number in a list. Your code should pass these tests: assert second_smallest([1, 2, -8, -2, 0, -2])==-2 assert second_smallest([1, 1, -0.5, 0, 2, -2, -2])==-0.5 assert second_smallest([2,2])==None [BEGIN] def second...
You are an expert Python programmer, and here is your task: Write a function that matches a string that has an a followed by zero or one 'b'. Your code should pass these tests: assert text_match_zero_one("ac")==('Found a match!') assert text_match_zero_one("dc")==('Not matched!') assert text_match_zero_one("abbbba")==...
You are an expert Python programmer, and here is your task: Write a function to count the pairs of reverse strings in the given string list. Your code should pass these tests: assert count_reverse_pairs(["julia", "best", "tseb", "for", "ailuj"])== '2' assert count_reverse_pairs(["geeks", "best", "for", "skeeg"]) == '1...
You are an expert Python programmer, and here is your task: Write a function to count number of unique lists within a list. Your code should pass these tests: assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]] )=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1} assert unique_sublists([['...
You are an expert Python programmer, and here is your task: Write a function to check a decimal with a precision of 2. Your code should pass these tests: assert is_decimal('123.11')==True assert is_decimal('e666.86')==False assert is_decimal('3.124587')==False [BEGIN] def is_decimal(num): import re dnumre = ...
You are an expert Python programmer, and here is your task: Write a python function to check whether an array contains only one distinct element or not. Your code should pass these tests: assert unique_Element([1,1,1],3) == 'YES' assert unique_Element([1,2,1,2],4) == 'NO' assert unique_Element([1,2,3,4,5],5) == 'NO' [...
You are an expert Python programmer, and here is your task: Write a function to caluclate arc length of an angle. Your code should pass these tests: assert arc_length(9,45)==3.5357142857142856 assert arc_length(9,480)==None assert arc_length(5,270)==11.785714285714285 [BEGIN] def arc_length(d,a): pi=22/7 if ...
You are an expert Python programmer, and here is your task: Write a function to check whether the given month number contains 30 days or not. Your code should pass these tests: assert check_monthnumber_number(6)==True assert check_monthnumber_number(2)==False assert check_monthnumber_number(12)==False [BEGIN] def chec...
You are an expert Python programmer, and here is your task: Write a python function to find the minimum difference between any two elements in a given array. Your code should pass these tests: assert find_Min_Diff((1,5,3,19,18,25),6) == 1 assert find_Min_Diff((4,3,2,6),4) == 1 assert find_Min_Diff((30,5,20,9),4) == 4 ...
You are an expert Python programmer, and here is your task: Write a python function to count numeric values in a given string. Your code should pass these tests: assert number_ctr('program2bedone') == 1 assert number_ctr('3wonders') ==1 assert number_ctr('123') == 3 [BEGIN] def number_ctr(str): number_ctr= 0 ...
You are an expert Python programmer, and here is your task: Write a function to find nth polite number. Your code should pass these tests: assert is_polite(7) == 11 assert is_polite(4) == 7 assert is_polite(9) == 13 [BEGIN] import math def is_polite(n): n = n + 1 return (int)(n+(math.log((n + math.log(n, 2)), 2...
You are an expert Python programmer, and here is your task: Write a function to iterate over all pairs of consecutive items in a given list. Your code should pass these tests: assert pair_wise([1,1,2,3,3,4,4,5])==[(1, 1), (1, 2), (2, 3), (3, 3), (3, 4), (4, 4), (4, 5)] assert pair_wise([1,5,7,9,10])==[(1, 5), (5, 7), ...
You are an expert Python programmer, and here is your task: Write a python function to count the number of pairs whose sum is equal to ‘sum’. Your code should pass these tests: assert get_Pairs_Count([1,1,1,1],4,2) == 6 assert get_Pairs_Count([1,5,7,-1,5],5,6) == 3 assert get_Pairs_Count([1,-2,3],3,1) == 1 [BEGIN] def...
You are an expert Python programmer, and here is your task: Write a python function to check for odd parity of a given number. Your code should pass these tests: assert check_Odd_Parity(13) == True assert check_Odd_Parity(21) == True assert check_Odd_Parity(18) == False [BEGIN] def check_Odd_Parity(x): parity = ...
You are an expert Python programmer, and here is your task: Write a python function to get the difference between two lists. Your code should pass these tests: assert (Diff([10, 15, 20, 25, 30, 35, 40], [25, 40, 35])) == [10, 20, 30, 15] assert (Diff([1,2,3,4,5], [6,7,1])) == [2,3,4,5,6,7] assert (Diff([1,2,3], [6,7,1...
You are an expert Python programmer, and here is your task: Write a python function to find the sum of fourth power of first n odd natural numbers. Your code should pass these tests: assert odd_Num_Sum(2) == 82 assert odd_Num_Sum(3) == 707 assert odd_Num_Sum(4) == 3108 [BEGIN] def odd_Num_Sum(n) : j = 0 sm ...
You are an expert Python programmer, and here is your task: Write a function to check if the given expression is balanced or not. Your code should pass these tests: assert check_expression("{()}[{}]") == True assert check_expression("{()}[{]") == False assert check_expression("{()}[{}][]({})") == True [BEGIN] from col...
You are an expert Python programmer, and here is your task: Write a function to remove all the words with k length in the given string. Your code should pass these tests: assert remove_length('The person is most value tet', 3) == 'person is most value' assert remove_length('If you told me about this ok', 4) == 'If you...
You are an expert Python programmer, and here is your task: Write a function to find the occurrence and position of the substrings within a string. Your code should pass these tests: assert occurance_substring('python programming, python language','python')==('python', 0, 6) assert occurance_substring('python programm...
You are an expert Python programmer, and here is your task: Write a function to check if the string is a valid email address or not using regex. Your code should pass these tests: assert check_email("ankitrai326@gmail.com") == 'Valid Email' assert check_email("my.ownsite@ourearth.org") == 'Valid Email' assert check_em...
You are an expert Python programmer, and here is your task: Write a python function to check whether every odd index contains odd numbers of a given list. Your code should pass these tests: assert odd_position([2,1,4,3,6,7,6,3]) == True assert odd_position([4,1,2]) == True assert odd_position([1,2,3]) == False [BEGIN]...
You are an expert Python programmer, and here is your task: Write a function to count those characters which have vowels as their neighbors in the given string. Your code should pass these tests: assert count_vowels('bestinstareels') == 7 assert count_vowels('partofthejourneyistheend') == 12 assert count_vowels('amazo...
You are an expert Python programmer, and here is your task: Write a python function to find the sum of non-repeated elements in a given array. Your code should pass these tests: assert find_Sum([1,2,3,1,1,4,5,6],8) == 21 assert find_Sum([1,10,9,4,2,10,10,45,4],9) == 71 assert find_Sum([12,10,9,45,2,10,10,45,10],9) == ...
You are an expert Python programmer, and here is your task: Write a function to pack consecutive duplicates of a given list elements into sublists. Your code should pass these tests: assert pack_consecutive_duplicates([0, 0, 1, 2, 3, 4, 4, 5, 6, 6, 6, 7, 8, 9, 4, 4])==[[0, 0], [1], [2], [3], [4, 4], [5], [6, 6, 6], [7...
You are an expert Python programmer, and here is your task: Write a function to count the number of unique lists within a list. Your code should pass these tests: assert unique_sublists([[1, 3], [5, 7], [1, 3], [13, 15, 17], [5, 7], [9, 11]])=={(1, 3): 2, (5, 7): 2, (13, 15, 17): 1, (9, 11): 1} assert unique_sublists(...
You are an expert Python programmer, and here is your task: Write a function to find the combinations of sums with tuples in the given tuple list. Your code should pass these tests: assert find_combinations([(2, 4), (6, 7), (5, 1), (6, 10)]) == [(8, 11), (7, 5), (8, 14), (11, 8), (12, 17), (11, 11)] assert find_combin...
You are an expert Python programmer, and here is your task: Write a python function to check whether the count of divisors is even or odd. Your code should pass these tests: assert count_Divisors(10) == "Even" assert count_Divisors(100) == "Odd" assert count_Divisors(125) == "Even" [BEGIN] import math def count_Divi...
You are an expert Python programmer, and here is your task: Write a python function to find the sum of all odd length subarrays. Your code should pass these tests: assert Odd_Length_Sum([1,2,4]) == 14 assert Odd_Length_Sum([1,2,1,2]) == 15 assert Odd_Length_Sum([1,7]) == 8 [BEGIN] def Odd_Length_Sum(arr): Sum = 0...
You are an expert Python programmer, and here is your task: Write a function to convert rgb color to hsv color. Your code should pass these tests: assert rgb_to_hsv(255, 255, 255)==(0, 0.0, 100.0) assert rgb_to_hsv(0, 215, 0)==(120.0, 100.0, 84.31372549019608) assert rgb_to_hsv(10, 215, 110)==(149.26829268292684, 95.3...
You are an expert Python programmer, and here is your task: Write a function to find the product of first even and odd number of a given list. Your code should pass these tests: assert mul_even_odd([1,3,5,7,4,1,6,8])==4 assert mul_even_odd([1,2,3,4,5,6,7,8,9,10])==2 assert mul_even_odd([1,5,7,9,10])==10 [BEGIN] def mu...
You are an expert Python programmer, and here is your task: Write a function to convert tuple string to integer tuple. Your code should pass these tests: assert tuple_str_int("(7, 8, 9)") == (7, 8, 9) assert tuple_str_int("(1, 2, 3)") == (1, 2, 3) assert tuple_str_int("(4, 5, 6)") == (4, 5, 6) [BEGIN] def tuple_str_in...
You are an expert Python programmer, and here is your task: Write a function to locate the right insertion point for a specified value in sorted order. Your code should pass these tests: assert right_insertion([1,2,4,5],6)==4 assert right_insertion([1,2,4,5],3)==2 assert right_insertion([1,2,4,5],7)==4 [BEGIN] import ...
You are an expert Python programmer, and here is your task: Write a function that matches a string that has an a followed by three 'b'. Your code should pass these tests: assert text_match_three("ac")==('Not matched!') assert text_match_three("dc")==('Not matched!') assert text_match_three("abbbba")==('Found a match!'...
You are an expert Python programmer, and here is your task: Write a function to create a new tuple from the given string and list. Your code should pass these tests: assert new_tuple(["WEB", "is"], "best") == ('WEB', 'is', 'best') assert new_tuple(["We", "are"], "Developers") == ('We', 'are', 'Developers') assert new_...
You are an expert Python programmer, and here is your task: Write a function to calculate the perimeter of a regular polygon. Your code should pass these tests: assert perimeter_polygon(4,20)==80 assert perimeter_polygon(10,15)==150 assert perimeter_polygon(9,7)==63 [BEGIN] from math import tan, pi def perimeter_poly...
You are an expert Python programmer, and here is your task: Write a python function to check whether every even index contains even numbers of a given list. Your code should pass these tests: assert even_position([3,2,1]) == False assert even_position([1,2,3]) == False assert even_position([2,1,4]) == True [BEGIN] def...
You are an expert Python programmer, and here is your task: Write a function to remove the nested record from the given tuple. Your code should pass these tests: assert remove_nested((1, 5, 7, (4, 6), 10)) == (1, 5, 7, 10) assert remove_nested((2, 6, 8, (5, 7), 11)) == (2, 6, 8, 11) assert remove_nested((3, 7, 9, (6, ...
You are an expert Python programmer, and here is your task: Write a python function to count the number of lists in a given number of lists. Your code should pass these tests: assert count_list([[1, 3], [5, 7], [9, 11], [13, 15, 17]]) == 4 assert count_list([[1,2],[2,3],[4,5]]) == 3 assert count_list([[1,0],[2,0]]) ==...
You are an expert Python programmer, and here is your task: Write a python function to find the last position of an element in a sorted array. Your code should pass these tests: assert last([1,2,3],1,3) == 0 assert last([1,1,1,2,3,4],1,6) == 2 assert last([2,3,2,3,6,8,9],3,8) == 3 [BEGIN] def last(arr,x,n): low =...
You are an expert Python programmer, and here is your task: Write a function that matches a string that has an 'a' followed by anything, ending in 'b'. Your code should pass these tests: assert text_starta_endb("aabbbb")==('Found a match!') assert text_starta_endb("aabAbbbc")==('Not matched!') assert text_starta_endb(...
You are an expert Python programmer, and here is your task: Write a function to find the n - cheap price items from a given dataset using heap queue algorithm. Your code should pass these tests: assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price':...
You are an expert Python programmer, and here is your task: Write function to find the sum of all items in the given dictionary. Your code should pass these tests: assert return_sum({'a': 100, 'b':200, 'c':300}) == 600 assert return_sum({'a': 25, 'b':18, 'c':45}) == 88 assert return_sum({'a': 36, 'b':39, 'c':49}) == 1...
You are an expert Python programmer, and here is your task: Write a python function to find the sum of all odd natural numbers within the range l and r. Your code should pass these tests: assert sum_in_Range(2,5) == 8 assert sum_in_Range(5,7) == 12 assert sum_in_Range(7,13) == 40 [BEGIN] def sum_Odd(n): terms = ...
You are an expert Python programmer, and here is your task: Write a python function to find the sum of an array. Your code should pass these tests: assert _sum([1, 2, 3]) == 6 assert _sum([15, 12, 13, 10]) == 50 assert _sum([0, 1, 2]) == 3 [BEGIN] def _sum(arr): sum=0 for i in arr: sum = sum + i ...
You are an expert Python programmer, and here is your task: Write a python function to left rotate the bits of a given number. Your code should pass these tests: assert left_Rotate(16,2) == 64 assert left_Rotate(10,2) == 40 assert left_Rotate(99,3) == 792 [BEGIN] INT_BITS = 32 def left_Rotate(n,d): return (n ...
You are an expert Python programmer, and here is your task: Write a function to remove all whitespaces from a string. Your code should pass these tests: assert remove_all_spaces('python program')==('pythonprogram') assert remove_all_spaces('python programming language')==('pythonprogramminglanguage') assert remo...