Write a function to convert the given tuple to a key-value dictionary using adjacent elements.

def tuple_to_dict(test_tup):
  res = dict(test_tup[idx : idx + 2] for idx in range(0, len(test_tup), 2))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN VAR


Write a python function to check whether all the characters are same or not.

def all_Characters_Same(s) :
    n = len(s)
    for i in range(1,n) :
        if s[i] != s[0] :
            return False
    return True

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a function to caluclate the area of a tetrahedron.

import math
def area_tetrahedron(side):
  area = math.sqrt(3)*(side*side)
  return area

IMPORT FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR NUMBER BIN_OP VAR VAR RETURN VAR


Write a function to rotate a given list by specified number of items to the right direction.

def rotate_right(list1,m,n):
  result =  list1[-(m):]+list1[:-(n)]
  return result

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN VAR


Write a function to check if the given tuple has any none value or not.

def check_none(test_tup):
  res = any(map(lambda ele: ele is None, test_tup))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NONE VAR RETURN VAR


Write a function to find numbers within a given range where every number is divisible by every digit it contains.

def divisible_by_digits(startnum, endnum):
    return [n for n in range(startnum, endnum+1) \
                if not any(map(lambda x: int(x) == 0 or n%int(x) != 0, str(n)))]

FUNC_DEF RETURN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER BIN_OP VAR FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR


Write a function to find area of a sector.

def sector_area(r,a):
    pi=22/7
    if a >= 360:
        return None
    sectorarea = (pi*r**2) * (a/360)
    return sectorarea

FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER RETURN NONE ASSIGN VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN VAR


Write a function to find the longest common subsequence for the given three string sequence.

def lcs_of_three(X, Y, Z, m, n, o):
	L = [[[0 for i in range(o+1)] for j in range(n+1)]
		for k in range(m+1)]
	for i in range(m+1):
		for j in range(n+1):
			for k in range(o+1):
				if (i == 0 or j == 0 or k == 0):
					L[i][j][k] = 0
				elif (X[i-1] == Y[j-1] and
					X[i-1] == Z[k-1]):
					L[i][j][k] = L[i-1][j-1][k-1] + 1
				else:
					L[i][j][k] = max(max(L[i-1][j][k],
					L[i][j-1][k]),
									L[i][j][k-1])
	return L[m][n][o]

FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR VAR


Write a function to put spaces between words starting with capital letters in a given string by using regex.

import re
def capital_words_spaces(str1):
  return re.sub(r"(\w)([A-Z])", r"\1 \2", str1)

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


Write a function to sort a given list of strings of numbers numerically.

def sort_numeric_strings(nums_str):
    result = [int(x) for x in nums_str]
    result.sort()
    return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR EXPR FUNC_CALL VAR RETURN VAR


Write a function to add the given tuple to the given list.

def add_tuple(test_list, test_tup):
  test_list += test_tup
  return (test_list)


Write a function to check if the given array represents min heap or not.

def check_min_heap(arr, i):
    if 2 * i + 2 > len(arr):
        return True
    left_child = (arr[i] <= arr[2 * i + 1]) and check_min_heap(arr, 2 * i + 1)
    right_child = (2 * i + 2 == len(arr)) or (arr[i] <= arr[2 * i + 2]
                                      and check_min_heap(arr, 2 * i + 2))
    return left_child and right_child

FUNC_DEF IF BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR RETURN NUMBER ASSIGN VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR VAR VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR VAR BIN_OP BIN_OP NUMBER VAR NUMBER RETURN VAR VAR


Write a function to find the nth jacobsthal number.

def jacobsthal_num(n):
	dp = [0] * (n + 1)
	dp[0] = 0
	dp[1] = 1
	for i in range(2, n+1):
		dp[i] = dp[i - 1] + 2 * dp[i - 2]
	return dp[n]

FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN_OP VAR NUMBER RETURN VAR VAR


Write a function to find minimum k records from tuple list.

def min_k(test_list, K):
  res = sorted(test_list, key = lambda x: x[1])[:K]
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER VAR RETURN VAR


Write a function to find common index elements from three lists.

def extract_index_list(l1, l2, l3):
    result = []
    for m, n, o in zip(l1, l2, l3):
        if (m == n == o):
            result.append(m)
    return result

FUNC_DEF ASSIGN VAR LIST FOR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR IF VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR


Write a function to find the second smallest number in a list.

def second_smallest(numbers):
  if (len(numbers)<2):
    return
  if ((len(numbers)==2)  and (numbers[0] == numbers[1]) ):
    return
  dup_items = set()
  uniq_items = []
  for x in numbers:
    if x not in dup_items:
      uniq_items.append(x)
      dup_items.add(x)
  uniq_items.sort()
  return  uniq_items[1]

FUNC_DEF IF FUNC_CALL VAR VAR NUMBER RETURN IF FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR NUMBER RETURN ASSIGN VAR FUNC_CALL VAR ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR RETURN VAR NUMBER


Write a function that matches a string that has an a followed by zero or one 'b'.

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

IMPORT FUNC_DEF ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR RETURN STRING RETURN STRING


Write a function to count the pairs of reverse strings in the given string list.

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)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR


Write a function to count number of unique lists within a list.

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

FUNC_DEF ASSIGN VAR DICT FOR VAR VAR EXPR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to check a decimal with a precision of 2.

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

FUNC_DEF IMPORT ASSIGN VAR FUNC_CALL VAR STRING ASSIGN VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR


Write a python function to check whether an array contains only one distinct element or not.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN STRING RETURN STRING


Write a function to caluclate arc length of an angle.

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

FUNC_DEF ASSIGN VAR BIN_OP NUMBER NUMBER IF VAR NUMBER RETURN NONE ASSIGN VAR BIN_OP BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN VAR


Write a function to check whether the given month number contains 30 days or not.

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

FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a python function to find the minimum difference between any two elements in a given array.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP NUMBER NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF BIN_OP VAR BIN_OP VAR NUMBER VAR VAR VAR ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR


Write a python function to count numeric values in a given string.

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

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER RETURN VAR


Write a function to find nth polite number.

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

IMPORT FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR BIN_OP VAR FUNC_CALL VAR VAR NUMBER NUMBER


Write a function to iterate over all pairs of consecutive items in a given list.

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

FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR


Write a python function to count the number of pairs whose sum is equal to ‘sum’.

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

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR


Write a python function to check for odd parity of a given number.

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

FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER


Write a python function to get the difference between two lists.

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

FUNC_DEF RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR


Write a python function to find the sum of fourth power of first n odd natural numbers.

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

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP BIN_OP NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP BIN_OP BIN_OP VAR VAR VAR VAR RETURN VAR


Write a function to check if the given expression is balanced or not.

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

FUNC_DEF IF BIN_OP FUNC_CALL VAR VAR NUMBER RETURN NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR VAR IF VAR STRING VAR STRING VAR STRING EXPR FUNC_CALL VAR VAR IF VAR STRING VAR STRING VAR STRING IF VAR RETURN NUMBER ASSIGN VAR FUNC_CALL VAR IF VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING RETURN NUMBER RETURN VAR


Write a function to remove all the words with k length in the given string.

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)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL STRING VAR RETURN VAR


Write a function to find the occurrence and position of the substrings within a string.

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)

IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR RETURN VAR VAR VAR VAR VAR


Write a function to check if the string is a valid email address or not using regex.

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")

IMPORT ASSIGN VAR STRING FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN STRING RETURN STRING


Write a python function to check whether every odd index contains odd numbers of a given list.

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

FUNC_DEF RETURN FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR NUMBER VAR FUNC_CALL VAR FUNC_CALL VAR VAR


Write a function to count those characters which have vowels as their neighbors in the given string.

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)

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER IF VAR NUMBER VAR VAR NUMBER VAR VAR NUMBER RETURN VAR


Write a python function to find the sum of non-repeated elements in a given array.

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

FUNC_DEF EXPR FUNC_CALL VAR ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR NUMBER RETURN VAR


Write a function to pack consecutive duplicates of a given list elements into sublists.

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

FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR


Write a function to count the number of unique lists within a list.

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

FUNC_DEF ASSIGN VAR DICT FOR VAR VAR EXPR FUNC_CALL FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR NUMBER FOR VAR VAR FUNC_CALL VAR ASSIGN VAR VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to find the combinations of sums with tuples in the given tuple list.

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)

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR BIN_OP VAR VAR VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER RETURN VAR


Write a python function to check whether the count of divisors is even or odd.

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")

IMPORT FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER IF BIN_OP VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN STRING RETURN STRING


Write a python function to find the sum of all odd length subarrays.

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

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP BIN_OP VAR NUMBER BIN_OP VAR VAR NUMBER NUMBER VAR VAR RETURN VAR


Write a function to convert rgb color to hsv color.

FUNC_DEF ASSIGN VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR VAR ASSIGN VAR NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER IF VAR VAR ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER NUMBER IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR


Write a function to find the product of first even and odd number of a given list.

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)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER RETURN BIN_OP VAR VAR


Write a function to convert tuple string to integer tuple.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR FUNC_CALL FUNC_CALL FUNC_CALL FUNC_CALL VAR STRING STRING STRING STRING STRING STRING STRING RETURN VAR


Write a function to locate the right insertion point for a specified value in sorted order.

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

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function that matches a string that has an a followed by three 'b'.

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

IMPORT FUNC_DEF ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR RETURN STRING RETURN STRING


Write a function to create a new tuple from the given string and list.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR LIST VAR RETURN VAR


Write a function to calculate the perimeter of a regular polygon.

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

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a python function to check whether every even index contains even numbers of a given list.

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


Write a function to remove the nested record from the given tuple.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FOR VAR VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a python function to count the number of lists in a given number of lists.

def count_list(input_list):
    return len(input_list)


Write a python function to find the last position of an element in a sorted array.

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

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR


Write a function that matches a string that has an 'a' followed by anything, ending in 'b'.

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


Write a function to find the n - cheap price items from a given dataset using heap queue algorithm.

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

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR STRING RETURN VAR


Write function to find the sum of all items in the given dictionary.

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

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a python function to find the sum of all odd natural numbers within the range l and r.

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)

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR RETURN VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER


Write a python function to find the sum of an array.

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

FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a python function to left rotate the bits of a given number.

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

ASSIGN VAR NUMBER FUNC_DEF RETURN BIN_OP BIN_OP VAR VAR BIN_OP VAR BIN_OP VAR VAR


Write a function to remove all whitespaces from a string.

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

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


Write a python function to count the number of equal numbers from three given integers.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR LIST VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR


Write a python function to count the number of rotations required to generate a sorted array.

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

FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR RETURN NUMBER


Write a python function to check whether the given number is a perfect square or not.

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

FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR VAR IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN NUMBER


Write a python function to check whether the product of numbers is even or not.

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

FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER


Write a function to find the list in a list of lists whose sum of elements is the highest.

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


Write a function to find maximum run of uppercase characters in the given string.

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)

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR VAR NUMBER ASSIGN VAR VAR ASSIGN VAR NUMBER IF FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR VAR RETURN VAR


Write a python function to find the first odd number in a given list of numbers.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER RETURN VAR


Write a function to check if the given tuples contain the k or not.

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

FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER RETURN VAR


Write a function to check if each element of second tuple is smaller than its corresponding index in first tuple.

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

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to iterate over elements repeating each as many times as its count.

from collections import Counter
def count_variable(a,b,c,d):
  c = Counter(p=a, q=b, r=c, s=d)
  return list(c.elements())

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN FUNC_CALL VAR FUNC_CALL VAR


Write a function to check if two lists of tuples are identical or not.

def check_identical(test_list1, test_list2):
  res = test_list1 == test_list2
  return (res)


Write a function to abbreviate 'road' as 'rd.' in a given string.

import re
def road_rd(street):
  return (re.sub('Road$', 'Rd.', street))


Write a function to find length of the string.

def string_length(str1):
    count = 0
    for char in str1:
        count += 1
    return count

FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR NUMBER RETURN VAR


Write a function to find the area of a rombus.

def rombus_area(p,q):
  area=(p*q)/2
  return area

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR NUMBER RETURN VAR


Write a function to sort the given array without using any sorting algorithm. the given array consists of only 0, 1, and 2.

def sort_by_dnf(arr, n):
  low=0
  mid=0
  high=n-1
  while mid <= high:
    if arr[mid] == 0:
      arr[low], arr[mid] = arr[mid], arr[low]
      low = low + 1
      mid = mid + 1
    elif arr[mid] == 1:
      mid = mid + 1
    else:
      arr[mid], arr[high] = arr[high], arr[mid]
      high = high - 1
  return arr

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER WHILE VAR VAR IF VAR VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR


Write a function to clear the values of the given tuples.

def clear_tuple(test_tup):
  temp = list(test_tup)
  temp.clear()
  test_tup = tuple(temp)
  return (test_tup)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to find numbers divisible by m or n from a list of numbers using lambda function.

def div_of_nums(nums,m,n):
 result = list(filter(lambda x: (x % m == 0 or x % n == 0), nums))
 return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR RETURN VAR


Write a python function to count lower case letters in a given string.

def lower_ctr(str):
      lower_ctr= 0
      for i in range(len(str)):
          if str[i] >= 'a' and str[i] <= 'z': lower_ctr += 1
      return  lower_ctr

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER RETURN VAR


Write a function to count the frequency of consecutive duplicate elements in a given list of numbers.

def count_duplic(lists):
    element = []
    frequency = []
    if not lists:
        return element
    running_count = 1
    for i in range(len(lists)-1):
        if lists[i] == lists[i+1]:
            running_count += 1
        else:
            frequency.append(running_count)
            element.append(lists[i])
            running_count = 1
    frequency.append(running_count)
    element.append(lists[i+1])
    return element,frequency

FUNC_DEF ASSIGN VAR LIST ASSIGN VAR LIST IF VAR RETURN VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR VAR ASSIGN VAR NUMBER EXPR FUNC_CALL VAR VAR EXPR FUNC_CALL VAR VAR BIN_OP VAR NUMBER RETURN VAR VAR


Write a function to check whether the given month number contains 28 days or not.

def check_monthnum_number(monthnum1):
  if monthnum1 == 2:
    return True
  else:
    return False

FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a function to merge two dictionaries into a single expression.

import collections as ct
def merge_dictionaries(dict1,dict2):
    merged_dict = dict(ct.ChainMap({}, dict1, dict2))
    return merged_dict

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR DICT VAR VAR RETURN VAR


Write a function to return true if the password is valid.

import re
def pass_validity(p):
 x = True
 while x:
    if (len(p)<6 or len(p)>12):
        break
    elif not re.search("[a-z]",p):
        break
    elif not re.search("[0-9]",p):
        break
    elif not re.search("[A-Z]",p):
        break
    elif not re.search("[$#@]",p):
        break
    elif re.search("\s",p):
        break
    else:
        return True
        x=False
        break

 if x:
    return False

IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE VAR IF FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR NUMBER IF FUNC_CALL VAR STRING VAR IF FUNC_CALL VAR STRING VAR IF FUNC_CALL VAR STRING VAR IF FUNC_CALL VAR STRING VAR IF FUNC_CALL VAR STRING VAR RETURN NUMBER ASSIGN VAR NUMBER IF VAR RETURN NUMBER


Write a function to check if the given string starts with a substring using regex.

import re
def check_substring(string, sample) :
  if (sample in string):
      y = "\A" + sample
      x = re.search(y, string)
      if x :
          return ("string starts with the given substring")
      else :
          return ("string doesnt start with the given substring")
  else :
      return ("entered string isnt a substring")

IMPORT FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR IF VAR RETURN STRING RETURN STRING RETURN STRING


Write a python function to remove even numbers from a given list.

def remove_even(l):
    for i in l:
        if i % 2 == 0:
            l.remove(i)
    return l

FUNC_DEF FOR VAR VAR IF BIN_OP VAR NUMBER NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR


Write a python function to access multiple elements of specified index from a given list.

def access_elements(nums, list_index):
    result = [nums[i] for i in list_index]
    return result

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR RETURN VAR


Write a python function to find the type of triangle from the given sides.

def check_Type_Of_Triangle(a,b,c):
    sqa = pow(a,2)
    sqb = pow(b,2)
    sqc = pow(c,2)
    if (sqa == sqa + sqb or sqb == sqa + sqc or sqc == sqa + sqb):
        return ("Right-angled Triangle")
    elif (sqa > sqc + sqb or sqb > sqa + sqc or sqc > sqa + sqb):
        return ("Obtuse-angled Triangle")
    else:
        return ("Acute-angled Triangle")

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR NUMBER IF VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN STRING IF VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR RETURN STRING RETURN STRING


Write a function to sum a specific column of a list in a given list of lists.

def sum_column(list1, C):
    result = sum(row[C] for row in list1)
    return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR


Write a function to count alphabets,digits and special charactes in a given string.

def count_alpha_dig_spl(string):
  alphabets=digits = special = 0
  for i in range(len(string)):
    if(string[i].isalpha()):
        alphabets = alphabets + 1
    elif(string[i].isdigit()):
        digits = digits + 1
    else:
        special = special + 1
  return (alphabets,digits,special)

FUNC_DEF ASSIGN VAR VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR


Write a function to find out the second most repeated (or frequent) string in the given sequence.

from collections import Counter

def second_frequent(input):
	dict = Counter(input)
	value = sorted(dict.values(), reverse=True)
	second_large = value[1]
	for (key, val) in dict.items():
		if val == second_large:
			return (key)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR VAR FUNC_CALL VAR IF VAR VAR RETURN VAR


Write a function to round up a number to specific digits.

import math
def round_up(a, digits):
    n = 10**-digits
    return round(math.ceil(a / n) * n, digits)

IMPORT FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR VAR VAR VAR


Write a python function to count equal element pairs from the given array.

def count_Pairs(arr,n):
    cnt = 0;
    for i in range(n):
        for j in range(i + 1,n):
            if (arr[i] == arr[j]):
                cnt += 1;
    return cnt;

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER RETURN VAR


Write a function to extract the maximum numeric value from a string by using regex.

import re
def extract_max(input):
	numbers = re.findall('\d+',input)
	numbers = map(int,numbers)
	return max(numbers)

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR


Write a function to get dictionary keys as a list.

def get_key(dict):
    list = []
    for key in dict.keys():
        list.append(key)
    return list

FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR RETURN VAR


Write a function to generate a square matrix filled with elements from 1 to n raised to the power of 2 in spiral order.

def generate_matrix(n):
        if n<=0:
            return []
        matrix=[row[:] for row in [[0]*n]*n]
        row_st=0
        row_ed=n-1
        col_st=0
        col_ed=n-1
        current=1
        while (True):
            if current>n*n:
                break
            for c in range (col_st, col_ed+1):
                matrix[row_st][c]=current
                current+=1
            row_st+=1
            for r in range (row_st, row_ed+1):
                matrix[r][col_ed]=current
                current+=1
            col_ed-=1
            for c in range (col_ed, col_st-1, -1):
                matrix[row_ed][c]=current
                current+=1
            row_ed-=1
            for r in range (row_ed, row_st-1, -1):
                matrix[r][col_st]=current
                current+=1
            col_st+=1
        return matrix

FUNC_DEF IF VAR NUMBER RETURN LIST ASSIGN VAR VAR VAR BIN_OP LIST BIN_OP LIST NUMBER VAR VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER WHILE NUMBER IF VAR BIN_OP VAR VAR FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR


Write a python function to find the slope of a line.

def slope(x1,y1,x2,y2):
    return (float)(y2-y1)/(x2-x1)

FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR BIN_OP VAR VAR


Write a function to find length of the subarray having maximum sum.

from sys import maxsize
def max_sub_array_sum(a,size):
	max_so_far = -maxsize - 1
	max_ending_here = 0
	start = 0
	end = 0
	s = 0
	for i in range(0,size):
		max_ending_here += a[i]
		if max_so_far < max_ending_here:
			max_so_far = max_ending_here
			start = s
			end = i
		if max_ending_here < 0:
			max_ending_here = 0
			s = i+1
	return (end - start + 1)

FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR VAR VAR IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR IF VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN BIN_OP BIN_OP VAR VAR NUMBER


Write a python function to find the cube sum of first n odd natural numbers.

def cube_Sum(n):
    sum = 0
    for i in range(0,n) :
        sum += (2*i+1)*(2*i+1)*(2*i+1)
    return sum

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR VAR BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER RETURN VAR


Write a python function to find minimum number swaps required to make two binary strings equal.

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING VAR VAR STRING VAR NUMBER IF VAR VAR STRING VAR VAR STRING VAR NUMBER ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP VAR NUMBER IF BIN_OP VAR NUMBER NUMBER BIN_OP VAR NUMBER NUMBER RETURN VAR IF BIN_OP BIN_OP VAR VAR NUMBER NUMBER RETURN BIN_OP VAR NUMBER RETURN NUMBER


Write a function to sort the tuples alphabetically by the first item of each tuple.

def sort_tuple(tup):
	n = len(tup)
	for i in range(n):
		for j in range(n-i-1):
			if tup[j][0] > tup[j + 1][0]:
				tup[j], tup[j + 1] = tup[j + 1], tup[j]
	return tup

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR VAR FOR VAR FUNC_CALL VAR BIN_OP BIN_OP VAR VAR NUMBER IF VAR VAR NUMBER VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR


Write a python function to check whether the roots of a quadratic equation are numerically equal but opposite in sign or not.

def Check_Solution(a,b,c):
    if b == 0:
        return ("Yes")
    else:
        return ("No")

FUNC_DEF IF VAR NUMBER RETURN STRING RETURN STRING


Write a function to count the number of inversions in the given array.

def get_inv_count(arr, n):
	inv_count = 0
	for i in range(n):
		for j in range(i + 1, n):
			if (arr[i] > arr[j]):
				inv_count += 1
	return inv_count


Write a function to find the number which occurs for odd number of times in the given array.

def get_odd_occurence(arr, arr_size):
  for i in range(0, arr_size):
    count = 0
    for j in range(0, arr_size):
      if arr[i] == arr[j]:
        count += 1
    if (count % 2 != 0):
      return arr[i]
  return -1

FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN VAR VAR RETURN NUMBER


Write a function to find the nth super ugly number from a given prime list of size k using heap queue algorithm.

import heapq
def nth_super_ugly_number(n, primes):
    uglies = [1]
    def gen(prime):
        for ugly in uglies:
            yield ugly * prime
    merged = heapq.merge(*map(gen, primes))
    while len(uglies) < n:
        ugly = next(merged)
        if ugly != uglies[-1]:
            uglies.append(ugly)
    return uglies[-1]

IMPORT FUNC_DEF ASSIGN VAR LIST NUMBER FUNC_DEF FOR VAR VAR EXPR BIN_OP VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR WHILE FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR NUMBER


Write a python function to find the kth element in an array containing odd elements first and then even elements.

def get_Number(n, k):
    arr = [0] * n;
    i = 0;
    odd = 1;
    while (odd <= n):
        arr[i] = odd;
        i += 1;
        odd += 2;
    even = 2;
    while (even <= n):
        arr[i] = even;
        i += 1;
        even += 2;
    return arr[k - 1];

FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR VAR VAR VAR NUMBER VAR NUMBER RETURN VAR BIN_OP VAR NUMBER


Write a python function to count the number of digits in factorial of a given number.

import math
def find_Digits(n):
    if (n < 0):
        return 0;
    if (n <= 1):
        return 1;
    x = ((n * math.log10(n / math.e) + math.log10(2 * math.pi * n) /2.0));
    return math.floor(x) + 1;

IMPORT FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER ASSIGN VAR BIN_OP BIN_OP VAR FUNC_CALL VAR BIN_OP VAR VAR BIN_OP FUNC_CALL VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER RETURN BIN_OP FUNC_CALL VAR VAR NUMBER


Write a function to find the minimum number of platforms required for a railway/bus station.

def find_platform(arr, dep, n):
    arr.sort()
    dep.sort()
    plat_needed = 1
    result = 1
    i = 1
    j = 0
    while (i < n and j < n):
        if (arr[i] <= dep[j]):
            plat_needed+= 1
            i+= 1
        elif (arr[i] > dep[j]):
            plat_needed-= 1
            j+= 1
        if (plat_needed > result):
            result = plat_needed
    return result

FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR NUMBER VAR NUMBER IF VAR VAR ASSIGN VAR VAR RETURN VAR


Write a python function to copy a list from a singleton tuple.


Write a function to find the area of a trapezium.

def area_trapezium(base1,base2,height):
 area = 0.5 * (base1 + base2) * height
 return area

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER BIN_OP VAR VAR VAR RETURN VAR


Write a python function to find sum of all prime divisors of a given number.

def Sum(N):
    SumOfPrimeDivisors = [0]*(N + 1)
    for i in range(2,N + 1) :
        if (SumOfPrimeDivisors[i] == 0) :
            for j in range(i,N + 1,i) :
                SumOfPrimeDivisors[j] += i
    return SumOfPrimeDivisors[N]

FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER IF VAR VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR RETURN VAR VAR


Write a function to check if a triangle of positive area is possible with the given angles.

def is_triangleexists(a,b,c):
    if(a != 0 and b != 0 and c != 0 and (a + b + c)== 180):
        if((a + b)>= c or (b + c)>= a or (a + c)>= b):
            return True
        else:
            return False
    else:
        return False

FUNC_DEF IF VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR VAR VAR NUMBER IF BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR BIN_OP VAR VAR VAR RETURN NUMBER RETURN NUMBER RETURN NUMBER


Write a python function to find sum of inverse of divisors.

def Sum_of_Inverse_Divisors(N,Sum):
    ans = float(Sum)*1.0 /float(N);
    return round(ans,2);

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP FUNC_CALL VAR VAR NUMBER FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR NUMBER


Write a python function to remove negative numbers from a list.

def remove_negs(num_list):
    for item in num_list:
        if item < 0:
           num_list.remove(item)
    return num_list

FUNC_DEF FOR VAR VAR IF VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR


Write a python function to find sum of odd factors of a number.

import math
def sum_of_odd_Factors(n):
    res = 1
    while n % 2 == 0:
        n = n // 2
    for i in range(3,int(math.sqrt(n) + 1)):
        count = 0
        curr_sum = 1
        curr_term = 1
        while n % i == 0:
            count+=1
            n = n // i
            curr_term *= i
            curr_sum += curr_term
        res *= curr_sum
    if n >= 2:
        res *= (1 + n)
    return res

IMPORT FUNC_DEF ASSIGN VAR NUMBER WHILE BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE BIN_OP VAR VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR IF VAR NUMBER VAR BIN_OP NUMBER VAR RETURN VAR


Write a function which accepts an arbitrary list and converts it to a heap using heap queue algorithm.

import heapq as hq
def raw_heap(rawheap):
  hq.heapify(rawheap)
  return rawheap

IMPORT FUNC_DEF EXPR FUNC_CALL VAR VAR RETURN VAR


Write a python function to check for even parity of a given number.

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

FUNC_DEF ASSIGN VAR NUMBER WHILE VAR NUMBER ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER


Write a python function to find minimum adjacent swaps required to sort binary array.

def find_Min_Swaps(arr,n) :
    noOfZeroes = [0] * n
    count = 0
    noOfZeroes[n - 1] = 1 - arr[n - 1]
    for i in range(n-2,-1,-1) :
        noOfZeroes[i] = noOfZeroes[i + 1]
        if (arr[i] == 0) :
            noOfZeroes[i] = noOfZeroes[i] + 1
    for i in range(0,n) :
        if (arr[i] == 1) :
            count = count + noOfZeroes[i]
    return count

FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER VAR ASSIGN VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR NUMBER IF VAR VAR NUMBER ASSIGN VAR VAR BIN_OP VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER ASSIGN VAR BIN_OP VAR VAR VAR RETURN VAR


Write a function to list out the list of given strings individually using map function.

def listify_list(list1):
  result = list(map(list,list1))
  return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to count number of lists in a given list of lists and square the count.

def count_list(input_list):
    return (len(input_list))**2

FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR NUMBER


Write a function to generate all sublists of a given list.

from itertools import combinations
def sub_lists(my_list):
	subs = []
	for i in range(0, len(my_list)+1):
	  temp = [list(x) for x in combinations(my_list, i)]
	  if len(temp)>0:
	    subs.extend(temp)
	return subs

FUNC_DEF ASSIGN VAR LIST FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR IF FUNC_CALL VAR VAR NUMBER EXPR FUNC_CALL VAR VAR RETURN VAR


Write a function to check whether the given string is ending with only alphanumeric characters or not using regex.

import re
regex = '[a-zA-z0-9]$'
def check_alphanumeric(string):
	if(re.search(regex, string)):
		return ("Accept")
	else:
		return ("Discard")

IMPORT ASSIGN VAR STRING FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN STRING RETURN STRING


Write a function to find all anagrams of a string in a given list of strings using lambda function.

from collections import Counter
def anagram_lambda(texts,str):
  result = list(filter(lambda x: (Counter(str) == Counter(x)), texts))
  return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find the occurrences of n most common words in a given text.

from collections import Counter
import re
def n_common_words(text,n):
  words = re.findall('\w+',text)
  n_common_words= Counter(words).most_common(n)
  return list(n_common_words)

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR VAR RETURN FUNC_CALL VAR VAR


Write a function to find the length of the longest sub-sequence such that elements in the subsequences are consecutive integers.

def find_longest_conseq_subseq(arr, n):
	ans = 0
	count = 0
	arr.sort()
	v = []
	v.append(arr[0])
	for i in range(1, n):
		if (arr[i] != arr[i - 1]):
			v.append(arr[i])
	for i in range(len(v)):
		if (i > 0 and v[i] == v[i - 1] + 1):
			count += 1
		else:
			count = 1
		ans = max(ans, count)
	return ans

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR NUMBER EXPR FUNC_CALL VAR ASSIGN VAR LIST EXPR FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR BIN_OP VAR NUMBER EXPR FUNC_CALL VAR VAR VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find palindromes in a given list of strings using lambda function.

def palindrome_lambda(texts):
  result = list(filter(lambda x: (x == "".join(reversed(x))), texts))
  return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL STRING FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to print n-times a list using map function.

def ntimes_list(nums,n):
    result = map(lambda x:n*x, nums)
    return list(result)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR RETURN FUNC_CALL VAR VAR


Write a function to check whether the given month name contains 31 days or not.

def check_monthnumb(monthname2):
  if(monthname2=="January" or monthname2=="March"or monthname2=="May" or monthname2=="July" or monthname2=="Augest" or monthname2=="October" or monthname2=="December"):
    return True
  else:
    return False

FUNC_DEF IF VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING VAR STRING RETURN NUMBER RETURN NUMBER


Write a python function to add a minimum number such that the sum of array becomes even.

def min_Num(arr,n):
    odd = 0
    for i in range(n):
        if (arr[i] % 2):
            odd += 1
    if (odd % 2):
        return 1
    return 2

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER VAR NUMBER IF BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a python function to find the length of the last word in a given string.

def length_Of_Last_Word(a):
    l = 0
    x = a.strip()
    for i in range(len(x)):
        if x[i] == " ":
            l = 0
        else:
            l += 1
    return l

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR VAR STRING ASSIGN VAR NUMBER VAR NUMBER RETURN VAR


Write a function to remove sublists from a given list of lists, which are outside a given range.

def remove_list_range(list1, leftrange, rigthrange):
   result = [i for i in list1 if (min(i)>=leftrange and max(i)<=rigthrange)]
   return result

FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to calculate the sum of the positive numbers of a given list of numbers using lambda function.

def sum_positivenum(nums):
  sum_positivenum = list(filter(lambda nums:nums>0,nums))
  return sum(sum_positivenum)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER VAR RETURN FUNC_CALL VAR VAR


Write a python function to check whether the given strings are rotations of each other or not.

def are_Rotations(string1,string2):
    size1 = len(string1)
    size2 = len(string2)
    temp = ''
    if size1 != size2:
        return False
    temp = string1 + string1
    if (temp.count(string2)> 0):
        return True
    else:
        return False

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR STRING IF VAR VAR RETURN NUMBER ASSIGN VAR BIN_OP VAR VAR IF FUNC_CALL VAR VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a function to check if a nested list is a subset of another nested list.

def check_subset(list1,list2):
    return all(map(list1.__contains__,list2))

FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR


Write a function to solve the fibonacci sequence using recursion.

def fibonacci(n):
  if n == 1 or n == 2:
    return 1
  else:
    return (fibonacci(n - 1) + (fibonacci(n - 2)))

FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER


Write a python function to check if the string is a concatenation of another string.

def check_Concat(str1,str2):
    N = len(str1)
    M = len(str2)
    if (N % M != 0):
        return False
    for i in range(N):
        if (str1[i] != str2[i % M]):
            return False
    return True

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF BIN_OP VAR VAR NUMBER RETURN NUMBER FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR BIN_OP VAR VAR RETURN NUMBER RETURN NUMBER


Write a function to find the minimum difference in the tuple pairs of given tuples.

def min_difference(test_list):
  temp = [abs(b - a) for a, b in test_list]
  res = min(temp)
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR


Write a python function to find lcm of two positive integers.

def lcm(x, y):
   if x > y:
       z = x
   else:
       z = y
   while(True):
       if((z % x == 0) and (z % y == 0)):
           lcm = z
           break
       z += 1
   return lcm

FUNC_DEF IF VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR WHILE NUMBER IF BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER ASSIGN VAR VAR VAR NUMBER RETURN VAR


Write a python function to sort the given string.

def sort_String(str) :
    str = ''.join(sorted(str))
    return (str)

FUNC_DEF ASSIGN VAR FUNC_CALL STRING FUNC_CALL VAR VAR RETURN VAR


Write a function to check if the given tuple contains only k elements.

def check_tuples(test_tuple, K):
  res = all(ele in K for ele in test_tuple)
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR


Write a function that matches a string that has an 'a' followed by anything, ending in 'b' by using regex.

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

IMPORT FUNC_DEF ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR RETURN STRING RETURN STRING


Write a python function to find number of solutions in quadratic equation.

def Check_Solution(a,b,c) :
    if ((b*b) - (4*a*c)) > 0 :
        return ("2 solutions")
    elif ((b*b) - (4*a*c)) == 0 :
        return ("1 solution")
    else :
        return ("No solutions")

FUNC_DEF IF BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER RETURN STRING IF BIN_OP BIN_OP VAR VAR BIN_OP BIN_OP NUMBER VAR VAR NUMBER RETURN STRING RETURN STRING


Write a function to find the sum of first even and odd number of a given list.

def sum_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)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER NUMBER NUMBER RETURN BIN_OP VAR VAR


Write a function to caluclate perimeter of a parallelogram.

def parallelogram_perimeter(b,h):
  perimeter=2*(b*h)
  return perimeter

FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR RETURN VAR


Write a function to find numbers divisible by m and n from a list of numbers using lambda function.

def div_of_nums(nums,m,n):
 result = list(filter(lambda x: (x % m == 0 and x % n == 0), nums))
 return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER BIN_OP VAR VAR NUMBER VAR RETURN VAR


Write a python function to check whether all the bits are within a given range or not.

def all_Bits_Set_In_The_Given_Range(n,l,r):
    num = ((1 << r) - 1) ^ ((1 << (l - 1)) - 1)
    new_num = n & num
    if (num == new_num):
        return True
    return False

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER BIN_OP BIN_OP NUMBER BIN_OP VAR NUMBER NUMBER ASSIGN VAR BIN_OP VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER


Write a python function to check whether the two given strings are isomorphic to each other or not.

def is_Isomorphic(str1,str2):
    dict_str1 = {}
    dict_str2 = {}
    for i, value in enumerate(str1):
        dict_str1[value] = dict_str1.get(value,[]) + [i]
    for j, value in enumerate(str2):
        dict_str2[value] = dict_str2.get(value,[]) + [j]
    if sorted(dict_str1.values()) == sorted(dict_str2.values()):
        return True
    else:
        return False

FUNC_DEF ASSIGN VAR DICT ASSIGN VAR DICT FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR LIST LIST VAR FOR VAR VAR FUNC_CALL VAR VAR ASSIGN VAR VAR BIN_OP FUNC_CALL VAR VAR LIST LIST VAR IF FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR RETURN NUMBER RETURN NUMBER


Write a function to add all the numbers in a list and divide it with the length of the list.

def sum_num(numbers):
    total = 0
    for x in numbers:
        total += x
    return total/len(numbers)

FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN BIN_OP VAR FUNC_CALL VAR VAR


Write a python function to check whether the given number is odd or not using bitwise operator.

def is_odd(n) :
    if (n^1 == n-1) :
        return True;
    else :
        return False;

FUNC_DEF IF BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a function to substract the elements of the given nested tuples.

def substract_elements(test_tup1, test_tup2):
  res = tuple(tuple(a - b for a, b in zip(tup1, tup2))
   for tup1, tup2 in zip(test_tup1, test_tup2))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to reverse each list in a given list of lists.

def reverse_list_lists(lists):
    for l in lists:
        l.sort(reverse = True)
    return lists

FUNC_DEF FOR VAR VAR EXPR FUNC_CALL VAR NUMBER RETURN VAR


Write a python function to find the index of an extra element present in one sorted array.

def find_Extra(arr1,arr2,n) :
    for i in range(0, n) :
        if (arr1[i] != arr2[i]) :
            return i
    return n

FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR VAR VAR RETURN VAR RETURN VAR


Write a python function to check whether the given two numbers have same number of digits or not.

def same_Length(A,B):
    while (A > 0 and B > 0):
        A = A / 10;
        B = B / 10;
    if (A == 0 and B == 0):
        return True;
    return False;

FUNC_DEF WHILE VAR NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a function to remove multiple spaces in a string.

import re
def remove_spaces(text):
 return (re.sub(' +',' ',text))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


Write a python function to get the last element of each sublist.

def Extract(lst):
    return [item[-1] for item in lst]


Write a function to convert the given string of float type into tuple.

def float_to_tuple(test_str):
  res = tuple(map(float, test_str.split(', ')))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR FUNC_CALL VAR STRING RETURN VAR


Write a function to find the maximum sum of subsequences of given array with no adjacent elements.

def max_sum_subseq(A):
    n = len(A)
    if n == 1:
        return A[0]
    look_up = [None] * n
    look_up[0] = A[0]
    look_up[1] = max(A[0], A[1])
    for i in range(2, n):
        look_up[i] = max(look_up[i - 1], look_up[i - 2] + A[i])
        look_up[i] = max(look_up[i], A[i])
    return look_up[n - 1]

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN VAR NUMBER ASSIGN VAR BIN_OP LIST NONE VAR ASSIGN VAR NUMBER VAR NUMBER ASSIGN VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER BIN_OP VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR BIN_OP VAR NUMBER


Write a function to sort a list in increasing order by the last element in each tuple from a given list of non-empty tuples.

def last(n):
   return n[-1]
def sort_list_last(tuples):
  return sorted(tuples, key=last)

FUNC_DEF RETURN VAR NUMBER FUNC_DEF RETURN FUNC_CALL VAR VAR VAR


Write a python function to check whether the word is present in a given sentence or not.

def is_Word_Present(sentence,word):
    s = sentence.split(" ")
    for i in s:
        if (i == word):
            return True
    return False

FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR IF VAR VAR RETURN NUMBER RETURN NUMBER


Write a function to extract specified number of elements from a given list, which follow each other continuously.

from itertools import groupby
def extract_elements(numbers, n):
    result = [i for i, j in groupby(numbers) if len(list(j)) == n]
    return result

FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a python function to check whether an array can be sorted or not by picking only the corner elements.

def check(arr,n):
    g = 0
    for i in range(1,n):
        if (arr[i] - arr[i - 1] > 0 and g == 1):
            return False
        if (arr[i] - arr[i] < 0):
            g = 1
    return True

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF BIN_OP VAR VAR VAR BIN_OP VAR NUMBER NUMBER VAR NUMBER RETURN NUMBER IF BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR NUMBER RETURN NUMBER


Write a function where a string will start with a specific number.

import re
def match_num(string):
    text = re.compile(r"^5")
    if text.match(string):
        return True
    else:
        return False

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING IF FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER


Write a function to find the smallest multiple of the first n numbers.

def smallest_multiple(n):
    if (n<=2):
      return n
    i = n * 2
    factors = [number  for number in range(n, 1, -1) if number * 2 > n]
    while True:
        for a in factors:
            if i % a != 0:
                i += n
                break
            if (a == factors[-1] and i % a == 0):
                return i

FUNC_DEF IF VAR NUMBER RETURN VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR NUMBER NUMBER BIN_OP VAR NUMBER VAR WHILE NUMBER FOR VAR VAR IF BIN_OP VAR VAR NUMBER VAR VAR IF VAR VAR NUMBER BIN_OP VAR VAR NUMBER RETURN VAR


Write a function to combine two dictionaries by adding values for common keys.

from collections import Counter
def add_dict(d1,d2):
   add_dict = Counter(d1) + Counter(d2)
   return add_dict

FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR


Write a python function to count the total unset bits from 1 to n.

def count_Unset_Bits(n) :
    cnt = 0;
    for i in range(1,n + 1) :
        temp = i;
        while (temp) :
            if (temp % 2 == 0) :
                cnt += 1;
            temp = temp // 2;
    return cnt;

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR WHILE VAR IF BIN_OP VAR NUMBER NUMBER VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR


Write a function to return true if the given number is even else return false.

def even_num(x):
  if x%2==0:
     return True
  else:
    return False

FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER


Write a python function to find the sum of squares of binomial co-efficients.

def factorial(start,end):
    res = 1
    for i in range(start,end + 1):
        res *= i
    return res
def sum_of_square(n):
   return int(factorial(n + 1, 2 * n)  /factorial(1, n))

FUNC_DEF ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR VAR BIN_OP VAR NUMBER VAR VAR RETURN VAR FUNC_DEF RETURN FUNC_CALL VAR BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP NUMBER VAR FUNC_CALL VAR NUMBER VAR


Write a function to extract year, month and date from a url by using regex.

import re
def extract_date(url):
        return re.findall(r'/(\d{4})/(\d{1,2})/(\d{1,2})/', url)

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


Write a function to print the first n lucky numbers.

def lucky_num(n):
 List=range(-1,n*n+9,2)
 i=2
 while List[i:]:List=sorted(set(List)-set(List[List[i]::List[i]]));i+=1
 return List[1:n+1]

FUNC_DEF ASSIGN VAR FUNC_CALL VAR NUMBER BIN_OP BIN_OP VAR VAR NUMBER NUMBER ASSIGN VAR NUMBER WHILE VAR VAR ASSIGN VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR NUMBER BIN_OP VAR NUMBER


Write a function to find the fixed point in the given array.

def find_fixed_point(arr, n):
	for i in range(n):
		if arr[i] is i:
			return i
	return -1

FUNC_DEF FOR VAR FUNC_CALL VAR VAR IF VAR VAR VAR RETURN VAR RETURN NUMBER


Write a function to find the previous palindrome of a specified number.

def previous_palindrome(num):
    for x in range(num-1,0,-1):
        if str(x) == str(x)[::-1]:
            return x

FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER NUMBER IF FUNC_CALL VAR VAR FUNC_CALL VAR VAR NUMBER RETURN VAR


Write a function to validate a gregorian date.

import datetime
def check_date(m, d, y):
    try:
        m, d, y = map(int, (m, d, y))
        datetime.date(y, m, d)
        return True
    except ValueError:
        return False

IMPORT FUNC_DEF ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR EXPR FUNC_CALL VAR VAR VAR VAR RETURN NUMBER VAR RETURN NUMBER


Write a function to compute maximum product of three numbers of a given array of integers using heap queue algorithm.

def maximum_product(nums):
    import heapq
    a, b = heapq.nlargest(3, nums), heapq.nsmallest(2, nums)
    return max(a[0] * a[1] * a[2], a[0] * b[0] * b[1])

FUNC_DEF IMPORT ASSIGN VAR VAR FUNC_CALL VAR NUMBER VAR FUNC_CALL VAR NUMBER VAR RETURN FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER BIN_OP BIN_OP VAR NUMBER VAR NUMBER VAR NUMBER


Write a function to find ln, m lobb number.

def binomial_coeff(n, k):
	C = [[0 for j in range(k + 1)]
			for i in range(n + 1)]
	for i in range(0, n + 1):
		for j in range(0, min(i, k) + 1):
			if (j == 0 or j == i):
				C[i][j] = 1
			else:
				C[i][j] = (C[i - 1][j - 1]
							+ C[i - 1][j])
	return C[n][k]
def lobb_num(n, m):
	return (((2 * m + 1) *
		binomial_coeff(2 * n, m + n))
					/ (m + n + 1))

FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP FUNC_CALL VAR VAR VAR NUMBER IF VAR NUMBER VAR VAR ASSIGN VAR VAR VAR NUMBER ASSIGN VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN VAR VAR VAR FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP BIN_OP NUMBER VAR NUMBER FUNC_CALL VAR BIN_OP NUMBER VAR BIN_OP VAR VAR BIN_OP BIN_OP VAR VAR NUMBER


Write a function to check for a number at the end of a string.

import re
def end_num(string):
    text = re.compile(r".*[0-9]$")
    if text.match(string):
        return True
    else:
        return False


Write a python function to check whether the given string is made up of two alternating characters or not.

def is_Two_Alter(s):
    for i in range (len( s) - 2) :
        if (s[i] != s[i + 2]) :
            return False
    if (s[0] == s[1]):
        return False
    return True

FUNC_DEF FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN NUMBER


Write a function to rearrange positive and negative numbers in a given array using lambda function.

def rearrange_numbs(array_nums):
  result = sorted(array_nums, key = lambda i: 0 if i == 0 else -1 / i)
  return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER BIN_OP NUMBER VAR RETURN VAR


Write a function to find if there is a triplet in the array whose sum is equal to a given value.

def find_triplet_array(A, arr_size, sum):
	for i in range( 0, arr_size-2):
		for j in range(i + 1, arr_size-1):
			for k in range(j + 1, arr_size):
				if A[i] + A[j] + A[k] == sum:
					return  A[i],A[j],A[k]
					return True
	return False

FUNC_DEF FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP BIN_OP VAR VAR VAR VAR VAR VAR VAR RETURN VAR VAR VAR VAR VAR VAR RETURN NUMBER RETURN NUMBER


Write a function to find the sequences of one upper case letter followed by lower case letters.

import re
def text_uppercase_lowercase(text):
        patterns = '[A-Z]+[a-z]+$'
        if re.search(patterns, text):
                return 'Found a match!'
        else:
                return ('Not matched!')

IMPORT FUNC_DEF ASSIGN VAR STRING IF FUNC_CALL VAR VAR VAR RETURN STRING RETURN STRING


Write a function to count coin change.

def coin_change(S, m, n):
    table = [[0 for x in range(m)] for x in range(n+1)]
    for i in range(m):
        table[0][i] = 1
    for i in range(1, n+1):
        for j in range(m):
            x = table[i - S[j]][j] if i-S[j] >= 0 else 0
            y = table[i][j-1] if j >= 1 else 0
            table[i][j] = x + y
    return table[n][m-1]

FUNC_DEF ASSIGN VAR NUMBER VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR BIN_OP VAR VAR VAR VAR NUMBER ASSIGN VAR VAR NUMBER VAR VAR BIN_OP VAR NUMBER NUMBER ASSIGN VAR VAR VAR BIN_OP VAR VAR RETURN VAR VAR BIN_OP VAR NUMBER


Write a python function to multiply all items in the list.

def multiply_list(items):
    tot = 1
    for x in items:
        tot *= x
    return tot

FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR


Write a function to remove all tuples with all none values in the given tuple list.

def remove_tuple(test_list):
  res = [sub for sub in test_list if not all(ele == None for ele in sub)]
  return (str(res))

FUNC_DEF ASSIGN VAR VAR VAR VAR FUNC_CALL VAR VAR NONE VAR VAR RETURN FUNC_CALL VAR VAR


Write a function to perform chunking of tuples each of size n.

def chunk_tuples(test_tup, N):
  res = [test_tup[i : i + N] for i in range(0, len(test_tup), N)]
  return (res)

FUNC_DEF ASSIGN VAR VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR NUMBER FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find a pair with the highest product from a given array of integers.

def max_product(arr):
    arr_len = len(arr)
    if (arr_len < 2):
        return None
    x = arr[0]; y = arr[1]
    for i in range(0, arr_len):
        for j in range(i + 1, arr_len):
            if (arr[i] * arr[j] > x * y):
                x = arr[i]; y = arr[j]
    return x,y

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR IF VAR NUMBER RETURN NONE ASSIGN VAR VAR NUMBER ASSIGN VAR VAR NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR IF BIN_OP VAR VAR VAR VAR BIN_OP VAR VAR ASSIGN VAR VAR VAR ASSIGN VAR VAR VAR RETURN VAR VAR


Write a function to find the length of the shortest string that has both str1 and str2 as subsequences.

def super_seq(X, Y, m, n):
	if (not m):
		return n
	if (not n):
		return m
	if (X[m - 1] == Y[n - 1]):
		return 1 + super_seq(X, Y, m - 1, n - 1)
	return 1 + min(super_seq(X, Y, m - 1, n),	super_seq(X, Y, m, n - 1))

FUNC_DEF IF VAR RETURN VAR IF VAR RETURN VAR IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN BIN_OP NUMBER FUNC_CALL VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER


Write a function to find maximum of two numbers.

def max_of_two( x, y ):
    if x > y:
        return x
    return y

FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR


Write a python function to calculate the product of all the numbers of a given tuple.

def mutiple_tuple(nums):
    temp = list(nums)
    product = 1
    for x in temp:
        product *= x
    return product

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR NUMBER FOR VAR VAR VAR VAR RETURN VAR


Write a function to find n-th rencontres number.

def binomial_coeffi(n, k):
	if (k == 0 or k == n):
		return 1
	return (binomial_coeffi(n - 1, k - 1)
		+ binomial_coeffi(n - 1, k))
def rencontres_number(n, m):
	if (n == 0 and m == 0):
		return 1
	if (n == 1 and m == 0):
		return 0
	if (m == 0):
		return ((n - 1) * (rencontres_number(n - 1, 0)+ rencontres_number(n - 2, 0)))
	return (binomial_coeffi(n, m) * rencontres_number(n - m, 0))

FUNC_DEF IF VAR NUMBER VAR VAR RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN BIN_OP BIN_OP VAR NUMBER BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER NUMBER RETURN BIN_OP FUNC_CALL VAR VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER


Write a function to calculate the height of the given binary tree.

class Node:
	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None
def max_height(node):
	if node is None:
		return 0 ;
	else :
		left_height = max_height(node.left)
		right_height = max_height(node.right)
		if (left_height > right_height):
			return left_height+1
		else:
			return right_height+1

CLASS_DEF FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NONE ASSIGN VAR NONE FUNC_DEF IF VAR NONE RETURN NUMBER ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR IF VAR VAR RETURN BIN_OP VAR NUMBER RETURN BIN_OP VAR NUMBER


Write a function to convert a date of yyyy-mm-dd format to dd-mm-yyyy format.

import re
def change_date_format(dt):
        return re.sub(r'(\d{4})-(\d{1,2})-(\d{1,2})', '\\3-\\2-\\1', dt)
        return change_date_format(dt)

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR RETURN FUNC_CALL VAR VAR


Write a function to count repeated items of a tuple.

def count_tuplex(tuplex,value):
  count = tuplex.count(value)
  return count

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR


Write a function that matches a string that has an a followed by zero or more b's by using regex.

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


Write a function to calculate the sum of series 1³+2³+3³+….+n³.

import math
def sum_series(number):
 total = 0
 total = math.pow((number * (number + 1)) /2, 2)
 return total

IMPORT FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR FUNC_CALL VAR BIN_OP BIN_OP VAR BIN_OP VAR NUMBER NUMBER NUMBER RETURN VAR


Write a function to remove duplicate words from a given list of strings.

def remove_duplic_list(l):
    temp = []
    for x in l:
        if x not in temp:
            temp.append(x)
    return temp

FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR EXPR FUNC_CALL VAR VAR RETURN VAR


Write a function to convert camel case string to snake case string by using regex.

import re
def camel_to_snake(text):
  str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
  return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING STRING VAR RETURN FUNC_CALL FUNC_CALL VAR STRING STRING VAR


Write a function to find the nth delannoy number.

def dealnnoy_num(n, m):
	if (m == 0 or n == 0) :
		return 1
	return dealnnoy_num(m - 1, n) + dealnnoy_num(m - 1, n - 1) + dealnnoy_num(m, n - 1)

FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER RETURN BIN_OP BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER FUNC_CALL VAR VAR BIN_OP VAR NUMBER


Write a function to calculate the sum of series 1²+2²+3²+….+n².

def series_sum(number):
 total = 0
 total = (number * (number + 1) * (2 * number + 1)) / 6
 return total

FUNC_DEF ASSIGN VAR NUMBER ASSIGN VAR BIN_OP BIN_OP BIN_OP VAR BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR NUMBER NUMBER RETURN VAR


Write a function to re-arrange the given tuples based on the given ordered list.

def re_arrange_tuples(test_list, ord_list):
  temp = dict(test_list)
  res = [(key, temp[key]) for key in ord_list]
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR RETURN VAR


Write a function to count the most common character in a given string.

from collections import Counter
def max_char(str1):
    temp = Counter(str1)
    max_char = max(temp, key = temp.get)
    return max_char

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find three closest elements from three sorted arrays.

import sys

def find_closet(A, B, C, p, q, r):
	diff = sys.maxsize
	res_i = 0
	res_j = 0
	res_k = 0
	i = 0
	j = 0
	k = 0
	while(i < p and j < q and k < r):
		minimum = min(A[i], min(B[j], C[k]))
		maximum = max(A[i], max(B[j], C[k]));
		if maximum-minimum < diff:
			res_i = i
			res_j = j
			res_k = k
			diff = maximum - minimum;
		if diff == 0:
			break
		if A[i] == minimum:
			i = i+1
		elif B[j] == minimum:
			j = j+1
		else:
			k = k+1
	return A[res_i],B[res_j],C[res_k]

IMPORT FUNC_DEF ASSIGN VAR VAR ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER ASSIGN VAR NUMBER WHILE VAR VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR VAR VAR VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR ASSIGN VAR BIN_OP VAR VAR IF VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER IF VAR VAR VAR ASSIGN VAR BIN_OP VAR NUMBER ASSIGN VAR BIN_OP VAR NUMBER RETURN VAR VAR VAR VAR VAR VAR


Write a function to sort a list of dictionaries using lambda function.

def sorted_models(models):
 sorted_models = sorted(models, key = lambda x: x['color'])
 return sorted_models

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR STRING RETURN VAR


Write a function to sort the given array by using heap sort.

def heap_sort(arr):
    heapify(arr)
    end = len(arr) - 1
    while end > 0:
        arr[end], arr[0] = arr[0], arr[end]
        shift_down(arr, 0, end - 1)
        end -= 1
    return arr

def heapify(arr):
    start = len(arr) // 2
    while start >= 0:
        shift_down(arr, start, len(arr) - 1)
        start -= 1
def shift_down(arr, start, end):
    root = start
    while root * 2 + 1 <= end:
        child = root * 2 + 1
        if child + 1 <= end and arr[child] < arr[child + 1]:
            child += 1
        if child <= end and arr[root] < arr[child]:
            arr[root], arr[child] = arr[child], arr[root]
            root = child
        else:
            return

FUNC_DEF EXPR FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER ASSIGN VAR VAR VAR NUMBER VAR NUMBER VAR VAR EXPR FUNC_CALL VAR VAR NUMBER BIN_OP VAR NUMBER VAR NUMBER RETURN VAR FUNC_DEF ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER WHILE VAR NUMBER EXPR FUNC_CALL VAR VAR VAR BIN_OP FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_DEF ASSIGN VAR VAR WHILE BIN_OP BIN_OP VAR NUMBER NUMBER VAR ASSIGN VAR BIN_OP BIN_OP VAR NUMBER NUMBER IF BIN_OP VAR NUMBER VAR VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER IF VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR VAR VAR VAR ASSIGN VAR VAR RETURN


Write a function to count the elements in a list until an element is a tuple.

def count_elim(num):
  count_elim = 0
  for n in num:
    if isinstance(n, tuple):
        break
    count_elim += 1
  return count_elim

FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR VAR NUMBER RETURN VAR


Write a function to check if any list element is present in the given list.

def check_element(test_tup, check_list):
  res = False
  for ele in check_list:
    if ele in test_tup:
      res = True
      break
  return (res)

FUNC_DEF ASSIGN VAR NUMBER FOR VAR VAR IF VAR VAR ASSIGN VAR NUMBER RETURN VAR


Write a function to combine two given sorted lists using heapq module.

from heapq import merge
def combine_lists(num1,num2):
  combine_lists=list(merge(num1, num2))
  return combine_lists

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to separate and print the numbers and their position of a given string.

import re
def num_position(text):
 for m in re.finditer("\d+", text):
    return m.start()

IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR STRING VAR RETURN FUNC_CALL VAR


Write a function to convert the given tuples into set.

def tuple_to_set(t):
  s = set(t)
  return (s)


Write a function to find the most common elements and their counts of a specified text.

from collections import Counter
def most_common_elem(s,a):
  most_common_elem=Counter(s).most_common(a)
  return most_common_elem

FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR VAR RETURN VAR


Write a python function to find the length of the shortest word.

def len_log(list1):
    min=len(list1[0])
    for i in list1:
        if len(i)<min:
            min=len(i)
    return min

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER FOR VAR VAR IF FUNC_CALL VAR VAR VAR ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to get an item of a tuple.

def get_item(tup1,index):
  item = tup1[index]
  return item


Write a function to sort the given tuple list basis the total digits in tuple.

def count_digs(tup):
  return sum([len(str(ele)) for ele in tup ])
def sort_list(test_list):
  test_list.sort(key = count_digs)
  return (str(test_list))

FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR FUNC_DEF EXPR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR


Write a function to display sign of the chinese zodiac for given year.

def chinese_zodiac(year):
 if (year - 2000) % 12 == 0:
     sign = 'Dragon'
 elif (year - 2000) % 12 == 1:
     sign = 'Snake'
 elif (year - 2000) % 12 == 2:
     sign = 'Horse'
 elif (year - 2000) % 12 == 3:
     sign = 'sheep'
 elif (year - 2000) % 12 == 4:
     sign = 'Monkey'
 elif (year - 2000) % 12 == 5:
     sign = 'Rooster'
 elif (year - 2000) % 12 == 6:
     sign = 'Dog'
 elif (year - 2000) % 12 == 7:
     sign = 'Pig'
 elif (year - 2000) % 12 == 8:
     sign = 'Rat'
 elif (year - 2000) % 12 == 9:
     sign = 'Ox'
 elif (year - 2000) % 12 == 10:
     sign = 'Tiger'
 else:
     sign = 'Hare'
 return sign

FUNC_DEF IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING IF BIN_OP BIN_OP VAR NUMBER NUMBER NUMBER ASSIGN VAR STRING ASSIGN VAR STRING RETURN VAR


Write a function to find the maximum of similar indices in two lists of tuples.

def max_similar_indices(test_list1, test_list2):
  res = [(max(x[0], y[0]), max(x[1], y[1]))
   for x, y in zip(test_list1, test_list2)]
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER VAR NUMBER FUNC_CALL VAR VAR NUMBER VAR NUMBER VAR VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to compute the value of ncr mod p.

def nCr_mod_p(n, r, p):
	if (r > n- r):
		r = n - r
	C = [0 for i in range(r + 1)]
	C[0] = 1
	for i in range(1, n + 1):
		for j in range(min(i, r), 0, -1):
			C[j] = (C[j] + C[j-1]) % p
	return C[r]

FUNC_DEF IF VAR BIN_OP VAR VAR ASSIGN VAR BIN_OP VAR VAR ASSIGN VAR NUMBER VAR FUNC_CALL VAR BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR NUMBER NUMBER ASSIGN VAR VAR BIN_OP BIN_OP VAR VAR VAR BIN_OP VAR NUMBER VAR RETURN VAR VAR


Write a python function to find the minimun number of subsets with distinct elements.

def subset(ar, n):
    res = 0
    ar.sort()
    for i in range(0, n) :
        count = 1
        for i in range(n - 1):
            if ar[i] == ar[i + 1]:
                count+=1
            else:
                break
        res = max(res, count)
    return res

FUNC_DEF ASSIGN VAR NUMBER EXPR FUNC_CALL VAR FOR VAR FUNC_CALL VAR NUMBER VAR ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR VAR VAR BIN_OP VAR NUMBER VAR NUMBER ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function that gives profit amount if the given amount has profit else return none.

def profit_amount(actual_cost,sale_amount):
 if(actual_cost > sale_amount):
    amount = actual_cost - sale_amount
    return amount
 else:
    return None

FUNC_DEF IF VAR VAR ASSIGN VAR BIN_OP VAR VAR RETURN VAR RETURN NONE


Write a function to find out, if the given number is abundant.

def is_abundant(n):
    fctrsum = sum([fctr for fctr in range(1, n) if n % fctr == 0])
    return fctrsum > n

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR FUNC_CALL VAR NUMBER VAR BIN_OP VAR VAR NUMBER RETURN VAR VAR


Write a function to split the given string at uppercase letters by using regex.

import re
def split_list(text):
  return (re.findall('[A-Z][^A-Z]*', text))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


Write a python function to get the position of rightmost set bit.

import math
def get_First_Set_Bit_Pos(n):
     return math.log2(n&-n)+1

IMPORT FUNC_DEF RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR VAR NUMBER


Write a function to convert an integer into a roman numeral.

FUNC_DEF ASSIGN VAR LIST NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR LIST STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING STRING ASSIGN VAR STRING ASSIGN VAR NUMBER WHILE VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR VAR VAR VAR VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR


Write a python function to find the average of a list.

def Average(lst):
    return sum(lst) / len(lst)

FUNC_DEF RETURN BIN_OP FUNC_CALL VAR VAR FUNC_CALL VAR VAR


Write a function to solve tiling problem.

def get_noOfways(n):
    if (n == 0):
        return 0;
    if (n == 1):
        return 1;
    return get_noOfways(n - 1) + get_noOfways(n - 2);

FUNC_DEF IF VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER


Write a function to convert a roman numeral to an integer.

def roman_to_int(s):
        rom_val = {'I': 1, 'V': 5, 'X': 10, 'L': 50, 'C': 100, 'D': 500, 'M': 1000}
        int_val = 0
        for i in range(len(s)):
            if i > 0 and rom_val[s[i]] > rom_val[s[i - 1]]:
                int_val += rom_val[s[i]] - 2 * rom_val[s[i - 1]]
            else:
                int_val += rom_val[s[i]]
        return int_val

FUNC_DEF ASSIGN VAR DICT STRING STRING STRING STRING STRING STRING STRING NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER NUMBER ASSIGN VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR IF VAR NUMBER VAR VAR VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR VAR VAR BIN_OP NUMBER VAR VAR BIN_OP VAR NUMBER VAR VAR VAR VAR RETURN VAR


Write a python function to find the sum of all even natural numbers within the range l and r.

def sum_Natural(n):
    sum = (n * (n + 1))
    return int(sum)
def sum_Even(l,r):
    return (sum_Natural(int(r / 2)) - sum_Natural(int((l - 1) / 2)))

FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN FUNC_CALL VAR VAR FUNC_DEF RETURN BIN_OP FUNC_CALL VAR FUNC_CALL VAR BIN_OP VAR NUMBER FUNC_CALL VAR FUNC_CALL VAR BIN_OP BIN_OP VAR NUMBER NUMBER


Write a function to calculate the discriminant value.

def discriminant_value(x,y,z):
    discriminant = (y**2) - (4*x*z)
    if discriminant > 0:
        return ("Two solutions",discriminant)
    elif discriminant == 0:
        return ("one solution",discriminant)
    elif discriminant < 0:
        return ("no real solution",discriminant)

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR NUMBER BIN_OP BIN_OP NUMBER VAR VAR IF VAR NUMBER RETURN STRING VAR IF VAR NUMBER RETURN STRING VAR IF VAR NUMBER RETURN STRING VAR


Write a python function to check whether the length of the word is even or not.

def word_len(s):
    s = s.split(' ')
    for word in s:
        if len(word)%2==0:
            return True
        else:
          return False

FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING FOR VAR VAR IF BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER


Write a function to convert camel case string to snake case string.

def camel_to_snake(text):
        import re
        str1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
        return re.sub('([a-z0-9])([A-Z])', r'\1_\2', str1).lower()

FUNC_DEF IMPORT ASSIGN VAR FUNC_CALL VAR STRING STRING VAR RETURN FUNC_CALL FUNC_CALL VAR STRING STRING VAR


Write a function to remove an empty tuple from a list of tuples.

def remove_empty(tuple1): #L = [(), (), ('',), ('a', 'b'), ('a', 'b', 'c'), ('d')]
   tuple1 = [t for t in tuple1 if t]
   return tuple1

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR RETURN VAR


Write a python function to accept the strings which contains all vowels.

def check(string):
  if len(set(string).intersection("AEIOUaeiou"))>=5:
    return ('accepted')
  else:
    return ("not accepted")

FUNC_DEF IF FUNC_CALL VAR FUNC_CALL FUNC_CALL VAR VAR STRING NUMBER RETURN STRING RETURN STRING


Write a python function to find maximum possible value for the given periodic function.

def floor_Max(A,B,N):
    x = min(B - 1,N)
    return (A*x) // B

FUNC_DEF ASSIGN VAR FUNC_CALL VAR BIN_OP VAR NUMBER VAR RETURN BIN_OP BIN_OP VAR VAR VAR


Write a function to join the tuples if they have similar initial elements.

def join_tuples(test_list):
  res = []
  for sub in test_list:
    if res and res[-1][0] == sub[0]:
      res[-1].extend(sub[1:])
    else:
      res.append([ele for ele in sub])
  res = list(map(tuple, res))
  return (res)

FUNC_DEF ASSIGN VAR LIST FOR VAR VAR IF VAR VAR NUMBER NUMBER VAR NUMBER EXPR FUNC_CALL VAR NUMBER VAR NUMBER EXPR FUNC_CALL VAR VAR VAR VAR ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find minimum of two numbers.

def min_of_two( x, y ):
    if x < y:
        return x
    return y

FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR


Write a function to find the maximum number of segments of lengths a, b and c that can be formed from n.

def maximum_segments(n, a, b, c) :
	dp = [-1] * (n + 10)
	dp[0] = 0
	for i in range(0, n) :
		if (dp[i] != -1) :
			if(i + a <= n ):
				dp[i + a] = max(dp[i] + 1,
							dp[i + a])
			if(i + b <= n ):
				dp[i + b] = max(dp[i] + 1,
							dp[i + b])
			if(i + c <= n ):
				dp[i + c] = max(dp[i] + 1,
							dp[i + c])
	return dp[n]

FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER FOR VAR FUNC_CALL VAR NUMBER VAR IF VAR VAR NUMBER IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR IF BIN_OP VAR VAR VAR ASSIGN VAR BIN_OP VAR VAR FUNC_CALL VAR BIN_OP VAR VAR NUMBER VAR BIN_OP VAR VAR RETURN VAR VAR


Write a function to concatenate the given two tuples to a nested tuple.

def concatenate_nested(test_tup1, test_tup2):
  res = test_tup1 + test_tup2
  return (res)

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a python function to left rotate the string.

def left_rotate(s,d):
    tmp = s[d : ] + s[0 : d]
    return tmp

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR NUMBER VAR RETURN VAR


Write a function to find the minimum total path sum in the given triangle.

def min_sum_path(A):
	memo = [None] * len(A)
	n = len(A) - 1
	for i in range(len(A[n])):
		memo[i] = A[n][i]
	for i in range(len(A) - 2, -1,-1):
		for j in range( len(A[i])):
			memo[j] = A[i][j] + min(memo[j],
									memo[j + 1])
	return memo[0]

FUNC_DEF ASSIGN VAR BIN_OP LIST NONE FUNC_CALL VAR VAR ASSIGN VAR BIN_OP FUNC_CALL VAR VAR NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR VAR VAR VAR FOR VAR FUNC_CALL VAR BIN_OP FUNC_CALL VAR VAR NUMBER NUMBER NUMBER FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR ASSIGN VAR VAR BIN_OP VAR VAR VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER RETURN VAR NUMBER