mr44/mbsearch huggingface dataset:
Task: Write a function that matches a string that has an a followed by zero or one 'b'.

Solution:
import re
def text_match_zero_one(text):
        patterns = 'ab?'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return('Not matched!')


Tests:
assert text_match_zero_one("ac")==('Found a match!')
assert text_match_zero_one("dc")==('Not matched!')
assert text_match_zero_one("abbbba")==('Found a match!')
Task: Write a function to count the pairs of reverse strings in the given string list.

Solution:
def count_reverse_pairs(test_list):
  res = sum([1 for idx in range(0, len(test_list)) for idxn in range(idx, len( 
	test_list)) if test_list[idxn] == str(''.join(list(reversed(test_list[idx]))))]) 
  return str(res)


Tests:
assert count_reverse_pairs(["julia", "best", "tseb", "for", "ailuj"])== '2'
assert count_reverse_pairs(["geeks", "best", "for", "skeeg"]) == '1'
assert count_reverse_pairs(["makes", "best", "sekam", "for", "rof"]) == '2'
Task: Write a function to count number of unique lists within a list.

Solution:
def unique_sublists(list1):
    result ={}
    for l in  list1: 
        result.setdefault(tuple(l), list()).append(1) 
    for a, b in result.items(): 
        result[a] = sum(b)
    return result


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([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}
assert unique_sublists([[10, 20, 30, 40], [60, 70, 50, 50], [90, 100, 200]])=={(10, 20, 30, 40): 1, (60, 70, 50, 50): 1, (90, 100, 200): 1}
Task: Write a function to check a decimal with a precision of 2.

Solution:
def is_decimal(num):
    import re
    dnumre = re.compile(r"""^[0-9]+(\.[0-9]{1,2})?$""")
    result = dnumre.search(num)
    return bool(result)


Tests:
assert is_decimal('123.11')==True
assert is_decimal('e666.86')==False
assert is_decimal('3.124587')==False
Task: Write a python function to check whether an array contains only one distinct element or not.

Solution:
def unique_Element(arr,n):
    s = set(arr)
    if (len(s) == 1):
        return ('YES')
    else:
        return ('NO')


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'
Task: Write a function to caluclate arc length of an angle.

Solution:
def arc_length(d,a):
    pi=22/7
    if a >= 360:
        return None
    arclength = (pi*d) * (a/360)
    return arclength


Tests:
assert arc_length(9,45)==3.5357142857142856
assert arc_length(9,480)==None
assert arc_length(5,270)==11.785714285714285
Task: Write a function to check whether the given month number contains 30 days or not.

Solution:
def check_monthnumber_number(monthnum3):
  if(monthnum3==4 or monthnum3==6 or monthnum3==9 or monthnum3==11):
    return True
  else:
    return False


Tests:
assert check_monthnumber_number(6)==True
assert check_monthnumber_number(2)==False
assert check_monthnumber_number(12)==False
Task: Write a python function to find the minimum difference between any two elements in a given array.

Solution:
def find_Min_Diff(arr,n): 
    arr = sorted(arr) 
    diff = 10**20 
    for i in range(n-1): 
        if arr[i+1] - arr[i] < diff: 
            diff = arr[i+1] - arr[i]  
    return diff 


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
Task: Write a python function to count numeric values in a given string.

Solution:
def number_ctr(str):
      number_ctr= 0
      for i in range(len(str)):
          if str[i] >= '0' and str[i] <= '9': number_ctr += 1     
      return  number_ctr


Tests:
assert number_ctr('program2bedone') == 1
assert number_ctr('3wonders') ==1
assert number_ctr('123') == 3
Task: Write a function to find nth polite number.

Solution:
import math 
def is_polite(n): 
	n = n + 1
	return (int)(n+(math.log((n + math.log(n, 2)), 2))) 


Tests:
assert is_polite(7) == 11
assert is_polite(4) == 7
assert is_polite(9) == 13
Task: Write a function to iterate over all pairs of consecutive items in a given list.

Solution:
def pair_wise(l1):
    temp = []
    for i in range(len(l1) - 1):
        current_element, next_element = l1[i], l1[i + 1]
        x = (current_element, next_element)
        temp.append(x)
    return temp


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), (7, 9), (9, 10)]
assert pair_wise([1,2,3,4,5,6,7,8,9,10])==[(1, 2), (2, 3), (3, 4), (4, 5), (5, 6), (6, 7), (7, 8), (8, 9), (9, 10)]
Task: Write a python function to count the number of pairs whose sum is equal to ‘sum’.

Solution:
def get_Pairs_Count(arr,n,sum):
    count = 0  
    for i in range(0,n):
        for j in range(i + 1,n):
            if arr[i] + arr[j] == sum:
                count += 1
    return count


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
Task: Write a python function to check for odd parity of a given number.

Solution:
def check_Odd_Parity(x): 
    parity = 0
    while (x != 0): 
        x = x & (x - 1) 
        parity += 1
    if (parity % 2 == 1): 
        return True
    else: 
        return False


Tests:
assert check_Odd_Parity(13) == True
assert check_Odd_Parity(21) == True
assert check_Odd_Parity(18) == False
Task: Write a python function to get the difference between two lists.

Solution:
def Diff(li1,li2):
    return (list(list(set(li1)-set(li2)) + list(set(li2)-set(li1))))
 


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])) == [2,3,6,7]
Task: Write a python function to find the sum of fourth power of first n odd natural numbers.

Solution:
def odd_Num_Sum(n) : 
    j = 0
    sm = 0
    for i in range(1,n + 1) : 
        j = (2*i-1) 
        sm = sm + (j*j*j*j)   
    return sm 


Tests:
assert odd_Num_Sum(2) == 82
assert odd_Num_Sum(3) == 707
assert odd_Num_Sum(4) == 3108
Task: Write a function to check if the given expression is balanced or not.

Solution:
from collections import deque
def check_expression(exp):
    if len(exp) & 1:
        return False
    stack = deque()
    for ch in exp:
        if ch == '(' or ch == '{' or ch == '[':
            stack.append(ch)
        if ch == ')' or ch == '}' or ch == ']':
            if not stack:
                return False
            top = stack.pop()
            if (top == '(' and ch != ')') or (top == '{' and ch != '}' or (top == '[' and ch != ']')):
                return False
    return not stack


Tests:
assert check_expression("{()}[{}]") == True
assert check_expression("{()}[{]") == False
assert check_expression("{()}[{}][]({})") == True
Task: Write a function to remove all the words with k length in the given string.

Solution:
def remove_length(test_str, K):
  temp = test_str.split()
  res = [ele for ele in temp if len(ele) != K]
  res = ' '.join(res)
  return (res) 


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 me about ok'
assert remove_length('Forces of darkeness is come into the play', 4) == 'Forces of darkeness is the'
Task: Write a function to find the occurrence and position of the substrings within a string.

Solution:
import re
def occurance_substring(text,pattern):
 for match in re.finditer(pattern, text):
    s = match.start()
    e = match.end()
    return (text[s:e], s, e)


Tests:
assert occurance_substring('python programming, python language','python')==('python', 0, 6)
assert occurance_substring('python programming,programming language','programming')==('programming', 7, 18)
assert occurance_substring('python programming,programming language','language')==('language', 31, 39)
Task: Write a function to check if the string is a valid email address or not using regex.

Solution:
import re 
regex = '^[a-z0-9]+[\._]?[a-z0-9]+[@]\w+[.]\w{2,3}$'
def check_email(email): 
	if(re.search(regex,email)): 
		return ("Valid Email") 
	else: 
		return ("Invalid Email") 


Tests:
assert check_email("ankitrai326@gmail.com") == 'Valid Email'
assert check_email("my.ownsite@ourearth.org") == 'Valid Email'
assert check_email("ankitaoie326.com") == 'Invalid Email'
Task: Write a python function to check whether every odd index contains odd numbers of a given list.

Solution:
def odd_position(nums):
	return all(nums[i]%2==i%2 for i in range(len(nums)))


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
Task: Write a function to count those characters which have vowels as their neighbors in the given string.

Solution:
def count_vowels(test_str):
  res = 0
  vow_list = ['a', 'e', 'i', 'o', 'u']
  for idx in range(1, len(test_str) - 1):
    if test_str[idx] not in vow_list and (test_str[idx - 1] in vow_list or test_str[idx + 1] in vow_list):
      res += 1
  if test_str[0] not in vow_list and test_str[1] in vow_list:
    res += 1
  if test_str[-1] not in vow_list and test_str[-2] in vow_list:
    res += 1
  return (res) 


Tests:
assert count_vowels('bestinstareels') == 7
assert count_vowels('partofthejourneyistheend') == 12
assert count_vowels('amazonprime') == 5
Task: Write a python function to find the sum of non-repeated elements in a given array.

Solution:
def find_Sum(arr,n): 
    arr.sort() 
    sum = arr[0] 
    for i in range(0,n-1): 
        if (arr[i] != arr[i+1]): 
            sum = sum + arr[i+1]   
    return sum


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) == 78
Task: Write a function to pack consecutive duplicates of a given list elements into sublists.

Solution:
from itertools import groupby
def pack_consecutive_duplicates(list1):
    return [list(group) for key, group in groupby(list1)]


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], [8], [9], [4, 4]]
assert pack_consecutive_duplicates([10, 10, 15, 19, 18, 18, 17, 26, 26, 17, 18, 10])==[[10, 10], [15], [19], [18, 18], [17], [26, 26], [17], [18], [10]]
assert pack_consecutive_duplicates(['a', 'a', 'b', 'c', 'd', 'd'])==[['a', 'a'], ['b'], ['c'], ['d', 'd']]
Task: Write a function to count the number of unique lists within a list.

Solution:
def unique_sublists(list1):
    result ={}
    for l in list1: 
        result.setdefault(tuple(l), list()).append(1) 
    for a, b in result.items(): 
        result[a] = sum(b)
    return result


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([['green', 'orange'], ['black'], ['green', 'orange'], ['white']])=={('green', 'orange'): 2, ('black',): 1, ('white',): 1}
assert unique_sublists([[1, 2], [3, 4], [4, 5], [6, 7]])=={(1, 2): 1, (3, 4): 1, (4, 5): 1, (6, 7): 1}
Task: Write a function to find the combinations of sums with tuples in the given tuple list.

Solution:
from itertools import combinations 
def find_combinations(test_list):
  res = [(b1 + a1, b2 + a2) for (a1, a2), (b1, b2) in combinations(test_list, 2)]
  return (res) 


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_combinations([(3, 5), (7, 8), (6, 2), (7, 11)]) == [(10, 13), (9, 7), (10, 16), (13, 10), (14, 19), (13, 13)]
assert find_combinations([(4, 6), (8, 9), (7, 3), (8, 12)]) == [(12, 15), (11, 9), (12, 18), (15, 12), (16, 21), (15, 15)]
Task: Write a python function to check whether the count of divisors is even or odd.

Solution:
import math 
def count_Divisors(n) : 
    count = 0
    for i in range(1, (int)(math.sqrt(n)) + 2) : 
        if (n % i == 0) : 
            if( n // i == i) : 
                count = count + 1
            else : 
                count = count + 2
    if (count % 2 == 0) : 
        return ("Even") 
    else : 
        return ("Odd") 


Tests:
assert count_Divisors(10) == "Even"
assert count_Divisors(100) == "Odd"
assert count_Divisors(125) == "Even"
Task: Write a python function to find the sum of all odd length subarrays.

Solution:
def Odd_Length_Sum(arr):
    Sum = 0
    l = len(arr)
    for i in range(l):
        Sum += ((((i + 1) *(l - i) + 1) // 2) * arr[i])
    return Sum


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
Task: Write a function to convert rgb color to hsv color.

Solution:
def rgb_to_hsv(r, g, b):
    r, g, b = r/255.0, g/255.0, b/255.0
    mx = max(r, g, b)
    mn = min(r, g, b)
    df = mx-mn
    if mx == mn:
        h = 0
    elif mx == r:
        h = (60 * ((g-b)/df) + 360) % 360
    elif mx == g:
        h = (60 * ((b-r)/df) + 120) % 360
    elif mx == b:
        h = (60 * ((r-g)/df) + 240) % 360
    if mx == 0:
        s = 0
    else:
        s = (df/mx)*100
    v = mx*100
    return h, s, v


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.34883720930233, 84.31372549019608)
Task: Write a function to find the product of first even and odd number of a given list.

Solution:
def mul_even_odd(list1):
    first_even = next((el for el in list1 if el%2==0),-1)
    first_odd = next((el for el in list1 if el%2!=0),-1)
    return (first_even*first_odd)


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
Task: Write a function to convert tuple string to integer tuple.

Solution:
def tuple_str_int(test_str):
  res = tuple(int(num) for num in test_str.replace('(', '').replace(')', '').replace('...', '').split(', '))
  return (res) 


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)
Task: Write a function to locate the right insertion point for a specified value in sorted order.

Solution:
import bisect
def right_insertion(a, x):
    i = bisect.bisect_right(a, x)
    return i


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
Task: Write a function that matches a string that has an a followed by three 'b'.

Solution:
import re
def text_match_three(text):
        patterns = 'ab{3}?'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return('Not matched!')


Tests:
assert text_match_three("ac")==('Not matched!')
assert text_match_three("dc")==('Not matched!')
assert text_match_three("abbbba")==('Found a match!')
Task: Write a function to create a new tuple from the given string and list.

Solution:
def new_tuple(test_list, test_str):
  res = tuple(test_list + [test_str])
  return (res) 


Tests:
assert new_tuple(["WEB", "is"], "best") == ('WEB', 'is', 'best')
assert new_tuple(["We", "are"], "Developers") == ('We', 'are', 'Developers')
assert new_tuple(["Part", "is"], "Wrong") == ('Part', 'is', 'Wrong')
Task: Write a function to calculate the perimeter of a regular polygon.

Solution:
from math import tan, pi
def perimeter_polygon(s,l):
  perimeter = s*l
  return perimeter


Tests:
assert perimeter_polygon(4,20)==80
assert perimeter_polygon(10,15)==150
assert perimeter_polygon(9,7)==63
Task: Write a python function to check whether every even index contains even numbers of a given list.

Solution:
def even_position(nums):
	return all(nums[i]%2==i%2 for i in range(len(nums)))


Tests:
assert even_position([3,2,1]) == False
assert even_position([1,2,3]) == False
assert even_position([2,1,4]) == True
Task: Write a function to remove the nested record from the given tuple.

Solution:
def remove_nested(test_tup):
  res = tuple()
  for count, ele in enumerate(test_tup):
    if not isinstance(ele, tuple):
      res = res + (ele, )
  return (res) 


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, 8), 12)) == (3, 7, 9, 12)
Task: Write a python function to count the number of lists in a given number of lists.

Solution:
def count_list(input_list): 
    return len(input_list)


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]]) == 2
Task: Write a python function to find the last position of an element in a sorted array.

Solution:
def last(arr,x,n):
    low = 0
    high = n - 1
    res = -1  
    while (low <= high):
        mid = (low + high) // 2 
        if arr[mid] > x:
            high = mid - 1
        elif arr[mid] < x:
            low = mid + 1
        else:
            res = mid
            low = mid + 1
    return res


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
Task: Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.

Solution:
import re
def text_starta_endb(text):
        patterns = 'a.*?b$'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return('Not matched!')


Tests:
assert text_starta_endb("aabbbb")==('Found a match!')
assert text_starta_endb("aabAbbbc")==('Not matched!')
assert text_starta_endb("accddbbjjj")==('Not matched!')
Task: Write a function to find the n - cheap price items from a given dataset using heap queue algorithm.

Solution:
import heapq
def cheap_items(items,n):
  cheap_items = heapq.nsmallest(n, items, key=lambda s: s['price'])
  return cheap_items


Tests:
assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],1)==[{'name': 'Item-1', 'price': 101.1}]
assert cheap_items([{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}],2)==[{'name': 'Item-1', 'price': 101.1},{'name': 'Item-2', 'price': 555.22}]
assert cheap_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-4', 'price': 22.75}]
Task: Write function to find the sum of all items in the given dictionary.

Solution:
def return_sum(dict):
  sum = 0
  for i in dict.values():
    sum = sum + i
  return sum


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}) == 124
Task: Write a python function to find the sum of all odd natural numbers within the range l and r.

Solution:
def sum_Odd(n): 
    terms = (n + 1)//2
    sum1 = terms * terms 
    return sum1  
def sum_in_Range(l,r): 
    return sum_Odd(r) - sum_Odd(l - 1)


Tests:
assert sum_in_Range(2,5) == 8
assert sum_in_Range(5,7) == 12
assert sum_in_Range(7,13) == 40
Task: Write a python function to find the sum of an array.

Solution:
def _sum(arr):  
    sum=0
    for i in arr: 
        sum = sum + i      
    return(sum)  


Tests:
assert _sum([1, 2, 3]) == 6
assert _sum([15, 12, 13, 10]) == 50
assert _sum([0, 1, 2]) == 3
Task: Write a python function to left rotate the bits of a given number.

Solution:
INT_BITS = 32
def left_Rotate(n,d):   
    return (n << d)|(n >> (INT_BITS - d))  


Tests:
assert left_Rotate(16,2) == 64
assert left_Rotate(10,2) == 40
assert left_Rotate(99,3) == 792
Task: Write a function to remove all whitespaces from a string.

Solution:
import re
def remove_all_spaces(text):
 return (re.sub(r'\s+', '',text))


Tests:
assert remove_all_spaces('python  program')==('pythonprogram')
assert remove_all_spaces('python   programming    language')==('pythonprogramminglanguage')
assert remove_all_spaces('python                     program')==('pythonprogram')
Task: Write a python function to count the number of equal numbers from three given integers.

Solution:
def test_three_equal(x,y,z):
  result= set([x,y,z])
  if len(result)==3:
    return 0
  else:
    return (4-len(result))


Tests:
assert test_three_equal(1,1,1) == 3
assert test_three_equal(-1,-2,-3) == 0
assert test_three_equal(1,2,2) == 2
Task: Write a python function to count the number of rotations required to generate a sorted array.

Solution:
def count_Rotation(arr,n):   
    for i in range (1,n): 
        if (arr[i] < arr[i - 1]): 
            return i  
    return 0


Tests:
assert count_Rotation([3,2,1],3) == 1
assert count_Rotation([4,5,1,2,3],5) == 2
assert count_Rotation([7,8,9,1,2,3],6) == 3
Task: Write a python function to check whether the given number is a perfect square or not.

Solution:
def is_Perfect_Square(n) :
    i = 1
    while (i * i<= n):
        if ((n % i == 0) and (n / i == i)):
            return True     
        i = i + 1
    return False


Tests:
assert is_Perfect_Square(10) == False
assert is_Perfect_Square(36) == True
assert is_Perfect_Square(14) == False
Task: Write a python function to check whether the product of numbers is even or not.

Solution:
def is_Product_Even(arr,n): 
    for i in range(0,n): 
        if ((arr[i] & 1) == 0): 
            return True
    return False


Tests:
assert is_Product_Even([1,2,3],3) == True
assert is_Product_Even([1,2,1,4],4) == True
assert is_Product_Even([1,1],2) == False
Task: Write a function to find the list in a list of lists whose sum of elements is the highest.

Solution:
def max_sum_list(lists):
 return max(lists, key=sum)


Tests:
assert max_sum_list([[1,2,3], [4,5,6], [10,11,12], [7,8,9]])==[10, 11, 12] 
assert max_sum_list([[3,2,1], [6,5,4], [12,11,10]])==[12,11,10] 
assert max_sum_list([[2,3,1]])==[2,3,1]
Task: Write a function to find maximum run of uppercase characters in the given string.

Solution:
def max_run_uppercase(test_str):
  cnt = 0
  res = 0
  for idx in range(0, len(test_str)):
    if test_str[idx].isupper():
      cnt += 1
    else:
      res = cnt
      cnt = 0
  if test_str[len(test_str) - 1].isupper():
    res = cnt
  return (res)


Tests:
assert max_run_uppercase('GeMKSForGERksISBESt') == 5
assert max_run_uppercase('PrECIOusMOVemENTSYT') == 6
assert max_run_uppercase('GooGLEFluTTER') == 4
Task: Write a python function to find the first odd number in a given list of numbers.

Solution:
def first_odd(nums):
  first_odd = next((el for el in nums if el%2!=0),-1)
  return first_odd


Tests:
assert first_odd([1,3,5]) == 1
assert first_odd([2,4,1,3]) == 1
assert first_odd ([8,9,1]) == 9
Task: Write a function to check if the given tuples contain the k or not.

Solution:
def check_K(test_tup, K):
  res = False
  for ele in test_tup:
    if ele == K:
      res = True
      break
  return (res) 


Tests:
assert check_K((10, 4, 5, 6, 8), 6) == True
assert check_K((1, 2, 3, 4, 5, 6), 7) == False
assert check_K((7, 8, 9, 44, 11, 12), 11) == True
Task: Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.

Solution:
def check_smaller(test_tup1, test_tup2):
  res = all(x > y for x, y in zip(test_tup1, test_tup2))
  return (res) 


Tests:
assert check_smaller((1, 2, 3), (2, 3, 4)) == False
assert check_smaller((4, 5, 6), (3, 4, 5)) == True
assert check_smaller((11, 12, 13), (10, 11, 12)) == True