Write a function to find the minimum cost path to reach (m, n) from (0, 0) for the given cost matrix cost[][] and a position (m, n) in cost[][].

R = 3
C = 3
def min_cost(cost, m, n):
	tc = [[0 for x in range(C)] for x in range(R)]
	tc[0][0] = cost[0][0]
	for i in range(1, m+1):
		tc[i][0] = tc[i-1][0] + cost[i][0]
	for j in range(1, n+1):
		tc[0][j] = tc[0][j-1] + cost[0][j]
	for i in range(1, m+1):
		for j in range(1, n+1):
			tc[i][j] = min(tc[i-1][j-1], tc[i-1][j], tc[i][j-1]) + cost[i][j]
	return tc[m][n]

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


Write a function to find the similar elements from the given two tuple lists.

def similar_elements(test_tup1, test_tup2):
  res = tuple(set(test_tup1) & set(test_tup2))
  return (res)

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


Write a python function to identify non-prime numbers.

import math
def is_not_prime(n):
    result = False
    for i in range(2,int(math.sqrt(n)) + 1):
        if n % i == 0:
            result = True
    return result

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 ASSIGN VAR NUMBER RETURN VAR


Write a function to find the largest integers from a given list of numbers using heap queue algorithm.

import heapq as hq
def heap_queue_largest(nums,n):
  largest_nums = hq.nlargest(n, nums)
  return largest_nums

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find the number of ways to fill it with 2 x 1 dominoes for the given 3 x n board.

FUNC_DEF ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR BIN_OP LIST NUMBER BIN_OP VAR NUMBER ASSIGN VAR NUMBER NUMBER ASSIGN VAR NUMBER 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 ASSIGN VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER RETURN VAR VAR


Write a python function to check whether the two numbers differ at one bit position only or not.

def is_Power_Of_Two (x):
    return x and (not(x & (x - 1)))
def differ_At_One_Bit_Pos(a,b):
    return is_Power_Of_Two(a ^ b)

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


Write a function to find all words which are at least 4 characters long in a string by using regex.

import re
def find_char_long(text):
  return (re.findall(r"\b\w{4,}\b", text))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


Write a function to find squares of individual elements in a list using lambda function.

def square_nums(nums):
 square_nums = list(map(lambda x: x ** 2, nums))
 return square_nums

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


Write a python function to find the minimum number of rotations required to get the same string.

def find_Rotations(str):
    tmp = str + str
    n = len(str)
    for i in range(1,n + 1):
        substring = tmp[i: i+n]
        if (str == substring):
            return i
    return n

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


Write a function to get the n smallest items from a dataset.

import heapq
def small_nnum(list1,n):
  smallest=heapq.nsmallest(n,list1)
  return smallest


Write a python function to remove first and last occurrence of a given character from the string.

def remove_Occ(s,ch):
    for i in range(len(s)):
        if (s[i] == ch):
            s = s[0 : i] + s[i + 1:]
            break
    for i in range(len(s) - 1,-1,-1):
        if (s[i] == ch):
            s = s[0 : i] + s[i + 1:]
            break
    return s

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


Write a function to sort a given matrix in ascending order according to the sum of its rows.

def sort_matrix(M):
    result = sorted(M, key=sum)
    return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to count the most common words in a dictionary.

from collections import Counter
def count_common(words):
  word_counts = Counter(words)
  top_four = word_counts.most_common(4)
  return (top_four)

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


Write a python function to find the volume of a triangular prism.

def find_Volume(l,b,h) :
    return ((l * b * h) / 2)

FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP VAR VAR VAR NUMBER


Write a function to split a string at lowercase letters.

import re
def split_lowerstring(text):
 return (re.findall('[a-z][^a-z]*', text))


Write a function to find sequences of lowercase letters joined with an underscore.

import re
def text_lowercase_underscore(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 find the perimeter of a square.

def square_perimeter(a):
  perimeter=4*a
  return perimeter

FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN VAR


Write a function to remove characters from the first string which are present in the second string.

NO_OF_CHARS = 256
def str_to_list(string):
	temp = []
	for x in string:
		temp.append(x)
	return temp
def lst_to_string(List):
	return ''.join(List)
def get_char_count_array(string):
	count = [0] * NO_OF_CHARS
	for i in string:
		count[ord(i)] += 1
	return count
def remove_dirty_chars(string, second_string):
	count = get_char_count_array(second_string)
	ip_ind = 0
	res_ind = 0
	temp = ''
	str_list = str_to_list(string)
	while ip_ind != len(str_list):
		temp = str_list[ip_ind]
		if count[ord(temp)] == 0:
			str_list[res_ind] = str_list[ip_ind]
			res_ind += 1
		ip_ind+=1
	return lst_to_string(str_list[0:res_ind])

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


Write a function to find whether a given array of integers contains any duplicate element.

def test_duplicate(arraynums):
    nums_set = set(arraynums)
    return len(arraynums) != len(nums_set)

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


Write a function to check if the given number is woodball or not.

def is_woodall(x):
	if (x % 2 == 0):
		return False
	if (x == 1):
		return True
	x = x + 1
	p = 0
	while (x % 2 == 0):
		x = x/2
		p = p + 1
		if (p == x):
			return True
	return False

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


Write a function to find m number of multiples of n.

def multiples_of_num(m,n):
    multiples_of_num= list(range(n,(m+1)*n, n))
    return list(multiples_of_num)

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


Write a function to find the first duplicate element in a given array of integers.

def find_first_duplicate(nums):
    num_set = set()
    no_duplicate = -1

    for i in range(len(nums)):

        if nums[i] in num_set:
            return nums[i]
        else:
            num_set.add(nums[i])

    return no_duplicate

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


Write a python function to find the maximum sum of elements of list in a list of lists.

def maximum_Sum(list1):
    maxi = -100000
    for x in list1:
        sum = 0
        for y in x:
            sum+= y
        maxi = max(sum,maxi)
    return maxi

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


Write a function to convert the given binary number to its decimal equivalent.

def binary_to_decimal(binary):
    binary1 = binary
    decimal, i, n = 0, 0, 0
    while(binary != 0):
        dec = binary % 10
        decimal = decimal + dec * pow(2, i)
        binary = binary//10
        i += 1
    return (decimal)

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


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

def find_Product(arr,n):
    arr.sort()
    prod = 1
    for i in range(0,n,1):
        if (arr[i - 1] != arr[i]):
            prod = prod * arr[i]
    return prod;

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


Write a function to check if the given tuple list has all k elements.

def check_k_elements(test_list, K):
  res = True
  for tup in test_list:
    for ele in tup:
      if ele != K:
        res = False
  return (res)

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


Write a python function to remove all digits from a list of strings.

import re
def remove(list):
    pattern = '[0-9]'
    list = [re.sub(pattern, '', i) for i in list]
    return list

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


Write a python function to find binomial co-efficient.

def binomial_Coeff(n,k):
    if k > n :
       return 0
    if k==0 or k ==n :
        return 1
    return binomial_Coeff(n-1,k-1) + binomial_Coeff(n-1,k)

FUNC_DEF IF VAR VAR RETURN NUMBER 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


Write a python function to find the element occurring odd number of times.

def get_Odd_Occurrence(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 python function to count all the substrings starting and ending with same characters.

def check_Equality(s):
    return (ord(s[0]) == ord(s[len(s) - 1]));
def count_Substring_With_Equal_Ends(s):
    result = 0;
    n = len(s);
    for i in range(n):
        for j in range(1,n-i+1):
            if (check_Equality(s[i:i+j])):
                result+=1;
    return result;

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


Write a function to find the top k integers that occur most frequently from given lists of sorted and distinct integers using heap queue algorithm.

def func(nums, k):
    import collections
    d = collections.defaultdict(int)
    for row in nums:
        for i in row:
            d[i] += 1
    temp = []
    import heapq
    for key, v in d.items():
        if len(temp) < k:
            temp.append((v, key))
            if len(temp) == k:
                heapq.heapify(temp)
        else:
            if v > temp[0][0]:
                heapq.heappop(temp)
                heapq.heappush(temp, (v, key))
    result = []
    while temp:
        v, key = heapq.heappop(temp)
        result.append(key)
    return result

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


Write a python function to find the largest prime factor of a given number.

import math
def max_Prime_Factors (n):
    maxPrime = -1
    while n%2 == 0:
        maxPrime = 2
        n >>= 1
    for i in range(3,int(math.sqrt(n))+1,2):
        while n % i == 0:
            maxPrime = i
            n = n / i
    if n > 2:
        maxPrime = n
    return int(maxPrime)

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


Write a python function to convert a decimal number to binary number.

def decimal_To_Binary(N):
    B_Number = 0
    cnt = 0
    while (N != 0):
        rem = N % 2
        c = pow(10,cnt)
        B_Number += rem*c
        N //= 2
        cnt += 1
    return B_Number

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


Write a python function to find the missing number in a sorted array.

def find_missing(ar,N):
    l = 0
    r = N - 1
    while (l <= r):
        mid = (l + r) / 2
        mid= int (mid)
        if (ar[mid] != mid + 1 and ar[mid - 1] == mid):
            return (mid + 1)
        elif (ar[mid] != mid + 1):
            r = mid - 1
        else:
            l = mid + 1
    return (-1)

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


Write a function to find the n-th rectangular number.

def find_rect_num(n):
  return n*(n + 1)

FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER


Write a python function to find the nth digit in the proper fraction of two given numbers.

def find_Nth_Digit(p,q,N) :
    while (N > 0) :
        N -= 1;
        p *= 10;
        res = p // q;
        p %= q;
    return res;

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


Write a function to sort a given mixed list of integers and strings.

def sort_mixed_list(mixed_list):
    int_part = sorted([i for i in mixed_list if type(i) is int])
    str_part = sorted([i for i in mixed_list if type(i) is str])
    return int_part + str_part

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


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

def div_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 check if the letters of a given string can be rearranged so that two characters that are adjacent to each other are different.

import heapq
from collections import Counter
def rearange_string(S):
    ctr = Counter(S)
    heap = [(-value, key) for key, value in ctr.items()]
    heapq.heapify(heap)
    if (-heap[0][0]) * 2 > len(S) + 1:
        return ""
    ans = []
    while len(heap) >= 2:
        nct1, char1 = heapq.heappop(heap)
        nct2, char2 = heapq.heappop(heap)
        ans.extend([char1, char2])
        if nct1 + 1: heapq.heappush(heap, (nct1 + 1, char1))
        if nct2 + 1: heapq.heappush(heap, (nct2 + 1, char2))
    return "".join(ans) + (heap[0][1] if heap else "")

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


Write a function to find frequency of the elements in a given list of lists using collections module.

from collections import Counter
from itertools import chain
def freq_element(nums):
  result = Counter(chain.from_iterable(nums))
  return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to filter even numbers using lambda function.

def filter_evennumbers(nums):
 even_nums = list(filter(lambda x: x%2 == 0, nums))
 return even_nums

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


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

def find_Sum(arr,n):
    return sum([x for x in arr if arr.count(x) > 1])

FUNC_DEF RETURN FUNC_CALL VAR VAR VAR VAR FUNC_CALL VAR VAR NUMBER


Write a function to find sequences of lowercase letters joined with an underscore using regex.

import re
def text_match(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 that matches a word at the beginning of a string.

import re
def text_match_string(text):
        patterns = '^\w+'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return 'Not matched!'


Write a function to find the gcd of the given array elements.

def find_gcd(x, y):
	while(y):
		x, y = y, x % y
	return x
def get_gcd(l):
  num1 = l[0]
  num2 = l[1]
  gcd = find_gcd(num1, num2)
  for i in range(2, len(l)):
    gcd = find_gcd(gcd, l[i])
  return gcd

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


Write a python function to determine whether all the numbers are different from each other are not.

def test_distinct(data):
  if len(data) == len(set(data)):
    return True
  else:
    return False;

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


Write a python function to find the last digit when factorial of a divides factorial of b.

def compute_Last_Digit(A,B):
    variable = 1
    if (A == B):
        return 1
    elif ((B - A) >= 5):
        return 0
    else:
        for i in range(A + 1,B + 1):
            variable = (variable * (i % 10)) % 10
        return variable % 10

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


Write a python function to set all odd bits of a given number.

def odd_bit_set_number(n):
    count = 0;res = 0;temp = n
    while temp > 0:
        if count % 2 == 0:
            res |= (1 << count)
        count += 1
        temp >>= 1
    return (n | res)

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


Write a function to extract every first or specified element from a given two-dimensional list.

def specified_element(nums, N):
    result = [i[N] for i in nums]
    return result

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR RETURN VAR


Write a function to find the list with minimum length using lambda function.

def min_length_list(input_list):
    min_length = min(len(x) for x in input_list )
    min_list = min(input_list, key = lambda i: len(i))
    return(min_length, min_list)

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


Write a function to print check if the triangle is equilateral or not.

def check_equilateral(x,y,z):
  if x == y == z:
	   return True
  else:
     return False

FUNC_DEF IF VAR VAR VAR RETURN NUMBER RETURN NUMBER


Write a function to caluclate area of a parallelogram.

def parallelogram_area(b,h):
  area=b*h
  return area

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a python function to check whether the first and last characters of a given string are equal or not.

def check_Equality(str):
  if (str[0] == str[-1]):
    return ("Equal")
  else:
    return ("Not Equal")

FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN STRING RETURN STRING


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

def counting_sort(my_list):
    max_value = 0
    for i in range(len(my_list)):
        if my_list[i] > max_value:
            max_value = my_list[i]
    buckets = [0] * (max_value + 1)
    for i in my_list:
        buckets[i] += 1
    i = 0
    for j in range(max_value + 1):
         for a in range(buckets[j]):
             my_list[i] = j
             i += 1
    return my_list

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


Write a function to find t-nth term of geometric series.

import math
def tn_gp(a,n,r):
  tn = a * (math.pow(r, n - 1))
  return tn

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


Write a python function to check if a given number is one less than twice its reverse.

def rev(num):
    rev_num = 0
    while (num > 0):
        rev_num = (rev_num * 10 + num % 10)
        num = num // 10
    return rev_num
def check(n):
    return (2 * rev(n) == n + 1)

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


Write a python function to find the largest number that can be formed with the given digits.

def find_Max_Num(arr,n) :
    arr.sort(reverse = True)
    num = arr[0]
    for i in range(1,n) :
        num = num * 10 + arr[i]
    return num

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


Write a python function to check whether the given two integers have opposite sign or not.

def opposite_Signs(x,y):
    return ((x ^ y) < 0);


Write a function to find the nth octagonal number.

def is_octagonal(n):
	return 3 * n * n - 2 * n

FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR


Write a function to find the maximum length of the subsequence with difference between adjacent elements for the given array.

def max_len_sub( arr, n):
	mls=[]
	max = 0
	for i in range(n):
		mls.append(1)
	for i in range(n):
		for j in range(i):
			if (abs(arr[i] - arr[j]) <= 1 and mls[i] < mls[j] + 1):
				mls[i] = mls[j] + 1
	for i in range(n):
		if (max < mls[i]):
			max = mls[i]
	return max

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


Write a python function to count number of substrings with the sum of digits equal to their length.

from collections import defaultdict
def count_Substrings(s,n):
    count,sum = 0,0
    mp = defaultdict(lambda : 0)
    mp[0] += 1
    for i in range(n):
        sum += ord(s[i]) - ord('0')
        count += mp[sum - (i + 1)]
        mp[sum - (i + 1)] += 1
    return count

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


Write a python function to find smallest number in a list.


Write a function to find the maximum difference between available pairs in the given tuple list.

def max_difference(test_list):
  temp = [abs(b - a) for a, b in test_list]
  res = max(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 function to sort a list of tuples using lambda.

def subject_marks(subjectmarks):
#subject_marks = [('English', 88), ('Science', 90), ('Maths', 97), ('Social sciences', 82)])
 subjectmarks.sort(key = lambda x: x[1])
 return subjectmarks

FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER RETURN VAR


Write a function of recursion list sum.

def recursive_list_sum(data_list):
	total = 0
	for element in data_list:
		if type(element) == type([]):
			total = total + recursive_list_sum(element)
		else:
			total = total + element
	return total

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


Write a python function to count positive numbers in a list.

def pos_count(list):
  pos_count= 0
  for num in list:
    if num >= 0:
      pos_count += 1
  return pos_count

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


Write a function to find the number of ways to partition a set of bell numbers.

def bell_number(n):
    bell = [[0 for i in range(n+1)] for j in range(n+1)]
    bell[0][0] = 1
    for i in range(1, n+1):
        bell[i][0] = bell[i-1][i-1]
        for j in range(1, i+1):
            bell[i][j] = bell[i-1][j-1] + bell[i][j-1]
    return bell[n][0]

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


Write a python function to check whether the given array is monotonic or not.

def is_Monotonic(A):
    return (all(A[i] <= A[i + 1] for i in range(len(A) - 1)) or
            all(A[i] >= A[i + 1] for i in range(len(A) - 1)))

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


Write a function to check whether a list contains the given sublist or not.

def is_sublist(l, s):
	sub_set = False
	if s == []:
		sub_set = True
	elif s == l:
		sub_set = True
	elif len(s) > len(l):
		sub_set = False
	else:
		for i in range(len(l)):
			if l[i] == s[0]:
				n = 1
				while (n < len(s)) and (l[i+n] == s[n]):
					n += 1
				if n == len(s):
					sub_set = True
	return sub_set

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


Write a function to find whether all the given tuples have equal length or not.

def find_equal_tuple(Input, k):
  flag = 1
  for tuple in Input:
    if len(tuple) != k:
      flag = 0
      break
  return flag
def get_equal(Input, k):
  if find_equal_tuple(Input, k) == 1:
    return ("All tuples have same length")
  else:
    return ("All tuples do not have same length")

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


Write a function to sort a list of elements using comb sort.

def comb_sort(nums):
    shrink_fact = 1.3
    gaps = len(nums)
    swapped = True
    i = 0
    while gaps > 1 or swapped:
        gaps = int(float(gaps) / shrink_fact)
        swapped = False
        i = 0
        while gaps + i < len(nums):
            if nums[i] > nums[i+gaps]:
                nums[i], nums[i+gaps] = nums[i+gaps], nums[i]
                swapped = True
            i += 1
    return nums

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


Write a python function to check whether the given number can be represented as difference of two squares or not.

def dif_Square(n):
    if (n % 4 != 2):
        return True
    return False

FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER


Write a function to split the given string with multiple delimiters by using regex.

import re
def multiple_split(text):
  return (re.split('; |, |\*|\n',text))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


Write a function to check whether it follows the sequence given in the patterns array.

def is_samepatterns(colors, patterns):
    if len(colors) != len(patterns):
        return False
    sdict = {}
    pset = set()
    sset = set()
    for i in range(len(patterns)):
        pset.add(patterns[i])
        sset.add(colors[i])
        if patterns[i] not in sdict.keys():
            sdict[patterns[i]] = []

        keys = sdict[patterns[i]]
        keys.append(colors[i])
        sdict[patterns[i]] = keys

    if len(pset) != len(sset):
        return False

    for values in sdict.values():

        for i in range(len(values) - 1):
            if values[i] != values[i+1]:
                return False

    return True

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


Write a function to find tuples which have all elements divisible by k from the given list of tuples.

def find_tuples(test_list, K):
  res = [sub for sub in test_list if all(ele % K == 0 for ele in sub)]
  return (str(res))

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


Write a python function to count the number of squares in a rectangle.

def count_Squares(m,n):
    if(n < m):
        temp = m
        m = n
        n = temp
    return ((m * (m + 1) * (2 * m + 1) / 6 + (n - m) * m * (m + 1) / 2))

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


Write a python function to find the difference between sum of even and odd digits.

def is_Diff(n):
    return (n % 11 == 0)

FUNC_DEF RETURN BIN_OP VAR NUMBER NUMBER


Write a python function to find number of integers with odd number of set bits.

def count_With_Odd_SetBits(n):
    if (n % 2 != 0):
        return (n + 1) / 2
    count = bin(n).count('1')
    ans = n / 2
    if (count % 2 != 0):
        ans += 1
    return ans

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


Write a python function to check whether the length of the word is odd 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 find the nth tetrahedral number.

def tetrahedral_number(n):
	return (n * (n + 1) * (n + 2)) / 6

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


Write a function to zip the two given tuples.

def zip_tuples(test_tup1, test_tup2):
  res = []
  for i, j in enumerate(test_tup1):
    res.append((j, test_tup2[i % len(test_tup2)]))
  return (res)

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


Write a function to find the volume of a sphere.

import math
def volume_sphere(r):
  volume=(4/3)*math.pi*r*r*r
  return volume

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


Write a python function to find the character made by adding all the characters of the given string.

def get_Char(strr):
    summ = 0
    for i in range(len(strr)):
        summ += (ord(strr[i]) - ord('a') + 1)
    if (summ % 26 == 0):
        return ord('z')
    else:
        summ = summ % 26
        return chr(ord('a') + summ - 1)

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


Write a function to find the n-th number in newman conway sequence.

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

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


Write a function to find the surface area of a sphere.

import math
def surfacearea_sphere(r):
  surfacearea=4*math.pi*r*r
  return surfacearea

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


Write a function to find nth centered hexagonal number.

def centered_hexagonal_number(n):
  return 3 * n * (n - 1) + 1

FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER


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

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

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


Write a function to get the frequency of the elements in a list.

import collections
def freq_count(list1):
  freq_count= collections.Counter(list1)
  return freq_count

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to find the closest smaller number than n.


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

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

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 check if a substring is present in a given list of string values.

def find_substring(str1, sub_str):
   if any(sub_str in s for s in str1):
       return True
   return False

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


Write a function to check whether the given number is undulating or not.

def is_undulating(n):
	if (len(n) <= 2):
		return False
	for i in range(2, len(n)):
		if (n[i - 2] != n[i]):
			return False
	return True

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


Write a function to calculate the value of 'a' to the power 'b'.

def power(a,b):
	if b==0:
		return 1
	elif a==0:
		return 0
	elif b==1:
		return a
	else:
		return a*power(a,b-1)

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


Write a function to extract the index minimum value record from the given tuples.

from operator import itemgetter
def index_minimum(test_list):
  res = min(test_list, key = itemgetter(1))[0]
  return (res)

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


Write a python function to find the minimum length of sublist.

def Find_Min_Length(lst):
    minLength = min(len(x) for x in lst )
    return minLength

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


Write a python function to find the number of divisors of a given integer.

def divisor(n):
  for i in range(n):
    x = len([i for i in range(1,n+1) if not n % i])
  return x

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


Write a function to find frequency count of list of lists.

def frequency_lists(list1):
    list1 = [item for sublist in list1 for item in sublist]
    dic_data = {}
    for num in list1:
        if num in dic_data.keys():
            dic_data[num] += 1
        else:
            key = num
            value = 1
            dic_data[key] = value
    return dic_data

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


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

def multiply_num(numbers):
    total = 1
    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 function to convert the given decimal number to its binary equivalent.

def decimal_to_binary(n):
    return bin(n).replace("0b","")

FUNC_DEF RETURN FUNC_CALL FUNC_CALL VAR VAR STRING STRING


Write a function to find the next smallest palindrome of a specified number.

import sys
def next_smallest_palindrome(num):
    numstr = str(num)
    for i in range(num+1,sys.maxsize):
        if str(i) == str(i)[::-1]:
            return i

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


Write a function to find the kth element in the given array.

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

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


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

def snake_to_camel(word):
        import re
        return ''.join(x.capitalize() or '_' for x in word.split('_'))

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


Write a function to find eulerian number a(n, m).

def eulerian_num(n, m):
	if (m >= n or n == 0):
		return 0
	if (m == 0):
		return 1
	return ((n - m) * eulerian_num(n - 1, m - 1) +(m + 1) * eulerian_num(n - 1, m))

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


Write a function to sort each sublist of strings in a given list of lists using lambda function.

def sort_sublists(input_list):
    result = [sorted(x, key = lambda x:x[0]) for x in input_list]
    return result

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


Write a python function to count true booleans in the given list.


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

def add_lists(test_list, test_tup):
  res = tuple(list(test_tup) + test_list)
  return (res)

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


Write a python function to count hexadecimal numbers for a given range.

def count_Hexadecimal(L,R) :
    count = 0;
    for i in range(L,R + 1) :
        if (i >= 10 and i <= 15) :
            count += 1;
        elif (i > 15) :
            k = i;
            while (k != 0) :
                if (k % 16 >= 10) :
                    count += 1;
                k = k // 16;
    return count;

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


Write a function to merge multiple sorted inputs into a single sorted iterator using heap queue algorithm.

import heapq
def merge_sorted_list(num1,num2,num3):
  num1=sorted(num1)
  num2=sorted(num2)
  num3=sorted(num3)
  result = heapq.merge(num1,num2,num3)
  return list(result)

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


Write a python function to find the count of rotations of a binary string with odd value.

def odd_Equivalent(s,n):
    count=0
    for i in range(0,n):
        if (s[i] == '1'):
            count = count + 1
    return count

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


Write a function to extract the ranges that are missing from the given list with the given start range and end range values.

def extract_missing(test_list, strt_val, stop_val):
  res = []
  for sub in test_list:
    if sub[0] > strt_val:
      res.append((strt_val, sub[0]))
      strt_val = sub[1]
    if strt_val < stop_val:
      res.append((strt_val, stop_val))
  return (res)

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


Write a function to find common elements in given nested lists. * list item * list item * list item * list item

def common_in_nested_lists(nestedlist):
    result = list(set.intersection(*map(set, nestedlist)))
    return result

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


Write a python function to find the perimeter of a cylinder.

def perimeter(diameter,height) :
    return 2*(diameter+height)

FUNC_DEF RETURN BIN_OP NUMBER BIN_OP VAR VAR


Write a function to check if a string represents an integer or not.

def check_integer(text):
 text = text.strip()
 if len(text) < 1:
    return None
 else:
     if all(text[i] in "0123456789" for i in range(len(text))):
          return True
     elif (text[0] in "+-") and \
         all(text[i] in "0123456789" for i in range(1,len(text))):
         return True
     else:
        return False

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


Write a function to assign frequency to each tuple in the given tuple list.

from collections import Counter
def assign_freq(test_list):
  res = [(*key, val) for key, val in Counter(test_list).items()]
  return (str(res))

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


Write a function to check whether all dictionaries in a list are empty or not.

def empty_dit(list1):
 empty_dit=all(not d for d in list1)
 return empty_dit

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR


Write a function to convert a given tuple of positive integers into an integer.

def tuple_to_int(nums):
    result = int(''.join(map(str,nums)))
    return result

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


Write a function to convert all possible convertible elements in the list to float.

def list_to_float(test_list):
  res = []
  for tup in test_list:
    temp = []
    for ele in tup:
      if ele.isalpha():
        temp.append(ele)
      else:
        temp.append(float(ele))
    res.append((temp[0],temp[1]))
  return (str(res))

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


[link text](https:// [link text](https:// [link text](https://)))write a function to convert a string to a list.

def string_to_list(string):
    lst = list(string.split(" "))
    return lst

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING RETURN VAR


Write a python function to find the element that appears only once in a sorted array.

def search(arr,n) :
    XOR = 0
    for i in range(n) :
        XOR = XOR ^ arr[i]
    return (XOR)

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


Write a function to find the maximum product from the pairs of tuples within a given list.

def max_product_tuple(list1):
    result_max = max([abs(x * y) for x, y in list1] )
    return result_max

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


Write a function to find the triplet with sum of the given array

def check_triplet(A, n, sum, count):
    if count == 3 and sum == 0:
        return True
    if count == 3 or n == 0 or sum < 0:
        return False
    return check_triplet(A, n - 1, sum - A[n - 1], count + 1) or\
           check_triplet(A, n - 1, sum, count)

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


Write a function to find n’th smart number.

MAX = 3000
def smartNumber(n):
	primes = [0] * MAX
	result = []
	for i in range(2, MAX):
		if (primes[i] == 0):
			primes[i] = 1
			j = i * 2
			while (j < MAX):
				primes[j] -= 1
				if ( (primes[j] + 3) == 0):
					result.append(j)
				j = j + i
	result.sort()
	return result[n - 1]

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


Write a function to sum all amicable numbers from 1 to a specified number.

def amicable_numbers_sum(limit):
    if not isinstance(limit, int):
        return "Input is not an integer!"
    if limit < 1:
        return "Input must be bigger than 0!"
    amicables = set()
    for num in range(2, limit+1):
        if num in amicables:
            continue
        sum_fact = sum([fact for fact in range(1, num) if num % fact == 0])
        sum_fact2 = sum([fact for fact in range(1, sum_fact) if sum_fact % fact == 0])
        if num == sum_fact2 and num != sum_fact:
            amicables.add(num)
            amicables.add(sum_fact2)
    return sum(amicables)

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


Write a function to get the angle of a complex number.

import cmath
def angle_complex(a,b):
  cn=complex(a,b)
  angle=cmath.phase(a+b)
  return angle

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


Write a function to find the maximum difference between the number of 0s and number of 1s in any sub-string of the given binary string.

def find_length(string, n):
	current_sum = 0
	max_sum = 0
	for i in range(n):
		current_sum += (1 if string[i] == '0' else -1)
		if current_sum < 0:
			current_sum = 0
		max_sum = max(current_sum, max_sum)
	return max_sum if max_sum else 0

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


Write a python function to find the sum of common divisors of two given numbers.

def sum(a,b):
    sum = 0
    for i in range (1,min(a,b)):
        if (a % i == 0 and b % i == 0):
            sum += i
    return sum

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


Write a function to multiply two integers without using the * operator in python.

def multiply_int(x, y):
    if y < 0:
        return -multiply_int(x, -y)
    elif y == 0:
        return 0
    elif y == 1:
        return x
    else:
        return x + multiply_int(x, y - 1)

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


Write a function to shortlist words that are longer than n from a given list of words.

def long_words(n, str):
    word_len = []
    txt = str.split(" ")
    for x in txt:
        if len(x) > n:
            word_len.append(x)
    return word_len

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


Write a function to calculate magic square.

def magic_square_test(my_matrix):
    iSize = len(my_matrix[0])
    sum_list = []
    sum_list.extend([sum (lines) for lines in my_matrix])
    for col in range(iSize):
        sum_list.append(sum(row[col] for row in my_matrix))
    result1 = 0
    for i in range(0,iSize):
        result1 +=my_matrix[i][i]
    sum_list.append(result1)
    result2 = 0
    for i in range(iSize-1,-1,-1):
        result2 +=my_matrix[i][i]
    sum_list.append(result2)
    if len(set(sum_list))>1:
        return False
    return True

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


Write a function to find the item with maximum frequency in a given list.

from collections import defaultdict
def max_occurrences(nums):
    dict = defaultdict(int)
    for i in nums:
        dict[i] += 1
    result = max(dict.items(), key=lambda x: x[1])
    return result

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


Write a python function to reverse only the vowels of a given string.

def reverse_vowels(str1):
	vowels = ""
	for char in str1:
		if char in "aeiouAEIOU":
			vowels += char
	result_string = ""
	for char in str1:
		if char in "aeiouAEIOU":
			result_string += vowels[-1]
			vowels = vowels[:-1]
		else:
			result_string += char
	return result_string

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


Write a function to convert tuple to a string.

def tup_string(tup1):
  str =  ''.join(tup1)
  return str

FUNC_DEF ASSIGN VAR FUNC_CALL STRING VAR RETURN VAR


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

def sum_negativenum(nums):
  sum_negativenum = list(filter(lambda nums:nums<0,nums))
  return sum(sum_negativenum)

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 last element of given array is even or odd after performing an operation p times.

def check_last (arr,n,p):
    _sum = 0
    for i in range(n):
        _sum = _sum + arr[i]
    if p == 1:
        if _sum % 2 == 0:
            return "ODD"
        else:
            return "EVEN"
    return "EVEN"

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


Write a function to find the nth hexagonal number.

def hexagonal_num(n):
	return n*(2*n - 1)

FUNC_DEF RETURN BIN_OP VAR BIN_OP BIN_OP NUMBER VAR NUMBER


Write a function to calculate electricity bill.

def cal_electbill(units):
 if(units < 50):
    amount = units * 2.60
    surcharge = 25
 elif(units <= 100):
    amount = 130 + ((units - 50) * 3.25)
    surcharge = 35
 elif(units <= 200):
    amount = 130 + 162.50 + ((units - 100) * 5.26)
    surcharge = 45
 else:
    amount = 130 + 162.50 + 526 + ((units - 200) * 8.45)
    surcharge = 75
 total = amount + surcharge
 return total

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


Write a function to find the ration of zeroes in an array of integers.

from array import array
def zero_count(nums):
    n = len(nums)
    n1 = 0
    for x in nums:
        if x == 0:
            n1 += 1
        else:
          None
    return round(n1/n,2)

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


Write a python function to check whether the given number can be represented as sum of non-zero powers of 2 or not.

def is_Sum_Of_Powers_Of_Two(n):
    if (n % 2 == 1):
        return False
    else:
        return True

FUNC_DEF IF BIN_OP VAR NUMBER NUMBER RETURN NUMBER RETURN NUMBER


Write a function to find the circumference of a circle.

def circle_circumference(r):
  perimeter=2*3.1415*r
  return perimeter

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER NUMBER VAR RETURN VAR


Write a function to extract elements that occur singly in the given tuple list.

def extract_singly(test_list):
  res = []
  temp = set()
  for inner in test_list:
    for ele in inner:
      if not ele in temp:
        temp.add(ele)
        res.append(ele)
  return (res)

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


Write a function to sort a list of elements using pancake sort.

def pancake_sort(nums):
    arr_len = len(nums)
    while arr_len > 1:
        mi = nums.index(max(nums[0:arr_len]))
        nums = nums[mi::-1] + nums[mi+1:len(nums)]
        nums = nums[arr_len-1::-1] + nums[arr_len:len(nums)]
        arr_len -= 1
    return nums

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


Write a function to count the same pair in three given lists.

def count_samepair(list1,list2,list3):
    result = sum(m == n == o for m, n, o in zip(list1,list2,list3))
    return result

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


Write a function to find number of lists present in the given tuple.

def find_lists(Input):
	if isinstance(Input, list):
		return 1
	else:
		return len(Input)

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


Write a python function to find the sum of absolute differences in all pairs of the given array.

def sum_Pairs(arr,n):
    sum = 0
    for i in range(n - 1,-1,-1):
        sum += i*arr[i] - (n-1-i) * arr[i]
    return sum

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


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

def max_Abs_Diff(arr,n):
    minEle = arr[0]
    maxEle = arr[0]
    for i in range(1, n):
        minEle = min(minEle,arr[i])
        maxEle = max(maxEle,arr[i])
    return (maxEle - minEle)

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


Write a function to find the ascii value of total characters in a string.

def ascii_value_string(str1):
  for i in range(len(str1)):
   return ord(str1[i])

FUNC_DEF FOR VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN FUNC_CALL VAR VAR VAR


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

def max_path_sum(tri, m, n):
	for i in range(m-1, -1, -1):
		for j in range(i+1):
			if (tri[i+1][j] > tri[i+1][j+1]):
				tri[i][j] += tri[i+1][j]
			else:
				tri[i][j] += tri[i+1][j+1]
	return tri[0][0]

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


Write a function to divide a number into two parts such that the sum of digits is maximum.

def sum_digits_single(x) :
    ans = 0
    while x :
        ans += x % 10
        x //= 10
    return ans
def closest(x) :
    ans = 0
    while (ans * 10 + 9 <= x) :
        ans = ans * 10 + 9
    return ans
def sum_digits_twoparts(N) :
    A = closest(N)
    return sum_digits_single(A) + sum_digits_single(N - A)

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


Write a function to find the longest subsequence such that the difference between adjacents is one for the given array.

def longest_subseq_with_diff_one(arr, n):
	dp = [1 for i in range(n)]
	for i in range(n):
		for j in range(i):
			if ((arr[i] == arr[j]+1) or (arr[i] == arr[j]-1)):
				dp[i] = max(dp[i], dp[j]+1)
	result = 1
	for i in range(n):
		if (result < dp[i]):
			result = dp[i]
	return result

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


Write a python function to find whether the given number is present in the infinite sequence or not.

def does_Contain_B(a,b,c):
    if (a == b):
        return True
    if ((b - a) * c > 0 and (b - a) % c == 0):
        return True
    return False

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


Write a python function to check whether the given number is co-prime or not.

def gcd(p,q):
    while q != 0:
        p, q = q,p%q
    return p
def is_coprime(x,y):
    return gcd(x,y) == 1

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


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

def merge(a,b):
    c = []
    while len(a) != 0 and len(b) != 0:
        if a[0] < b[0]:
            c.append(a[0])
            a.remove(a[0])
        else:
            c.append(b[0])
            b.remove(b[0])
    if len(a) == 0:
        c += b
    else:
        c += a
    return c
def merge_sort(x):
    if len(x) == 0 or len(x) == 1:
        return x
    else:
        middle = len(x)//2
        a = merge_sort(x[:middle])
        b = merge_sort(x[middle:])
        return merge(a,b)

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


Write a function to find the vertex of a parabola.

def parabola_vertex(a, b, c):
  vertex=(((-b / (2 * a)),(((4 * a * c) - (b * b)) / (4 * a))))
  return vertex

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


Write a function to extract every specified element from a given two dimensional list.

def specified_element(nums, N):
    result = [i[N] for i in nums]
    return result

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR RETURN VAR


Write a python function to toggle all even bits of a given number.

def even_bit_toggle_number(n) :
    res = 0; count = 0; temp = n
    while (temp > 0) :
        if (count % 2 == 1) :
            res = res | (1 << count)
        count = count + 1
        temp >>= 1
    return n ^ res

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


Write a function to convert a tuple of string values to a tuple of integer values.

def tuple_int_str(tuple_str):
    result = tuple((int(x[0]), int(x[1])) for x in tuple_str)
    return result

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


Write a function to reflect the run-length encoding from a list.

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

FUNC_DEF RETURN LIST FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR VAR FUNC_CALL VAR VAR


Write a python function to find k number of operations required to make all elements equal.

def min_Ops(arr,n,k):
    max1 = max(arr)
    res = 0
    for i in range(0,n):
        if ((max1 - arr[i]) % k != 0):
            return -1
        else:
            res += (max1 - arr[i]) / k
    return int(res)

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


Write a function to print the season for the given month and day.

def month_season(month,days):
 if month in ('January', 'February', 'March'):
	 season = 'winter'
 elif month in ('April', 'May', 'June'):
	 season = 'spring'
 elif month in ('July', 'August', 'September'):
	 season = 'summer'
 else:
	 season = 'autumn'
 if (month == 'March') and (days > 19):
	 season = 'spring'
 elif (month == 'June') and (days > 20):
	 season = 'summer'
 elif (month == 'September') and (days > 21):
	 season = 'autumn'
 elif (month == 'October') and (days > 21):
	 season = 'autumn'
 elif (month == 'November') and (days > 21):
	 season = 'autumn'
 elif (month == 'December') and (days > 20):
	 season = 'winter'
 return season

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


Write a function to find x and y that satisfies ax + by = n.

def solution (a, b, n):
	i = 0
	while i * a <= n:
		if (n - (i * a)) % b == 0:
			return ("x = ",i ,", y = ",
			int((n - (i * a)) / b))
			return 0
		i = i + 1
	return ("No solution")

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


Write a function to remove all elements from a given list present in another list.

def remove_elements(list1, list2):
    result = [x for x in list1 if x not in list2]
    return result

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR RETURN VAR


Write a function to calculate the sum of the positive integers of n+(n-2)+(n-4)... (until n-x =< 0).

def sum_series(n):
  if n < 1:
    return 0
  else:
    return n + sum_series(n - 2)

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


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

from math import tan, pi
def area_polygon(s,l):
  area = s * (l ** 2) / (4 * tan(pi / s))
  return area

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


Write a python function to check whether the sum of divisors are same or not.

import math
def divSum(n):
    sum = 1;
    i = 2;
    while(i * i <= n):
        if (n % i == 0):
            sum = (sum + i +math.floor(n / i));
        i += 1;
    return sum;
def areEquivalent(num1,num2):
    return divSum(num1) == divSum(num2);

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


Write a python function to count characters at same position in a given string (lower and uppercase characters) as in english alphabet.

def count_char_position(str1):
    count_chars = 0
    for i in range(len(str1)):
        if ((i == ord(str1[i]) - ord('A')) or
            (i == ord(str1[i]) - ord('a'))):
            count_chars += 1
    return count_chars

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


Write a python function to count the pairs with xor as an even number.

def find_even_Pair(A,N):
    evenPair = 0
    for i in range(0,N):
        for j in range(i+1,N):
            if ((A[i] ^ A[j]) % 2 == 0):
                evenPair+=1
    return evenPair;

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 BIN_OP VAR VAR VAR VAR NUMBER NUMBER VAR NUMBER RETURN VAR


Write a python function to find smallest power of 2 greater than or equal to n.

def next_Power_Of_2(n):
    count = 0;
    if (n and not(n & (n - 1))):
        return n
    while( n != 0):
        n >>= 1
        count += 1
    return 1 << count;

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


Write a python function to find the frequency of a number in a given array.

def frequency(a,x):
    count = 0
    for i in a:
        if i == x: count += 1
    return count

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


Write a function to calculate the nth pell number.

def get_pell(n):
	if (n <= 2):
		return n
	a = 1
	b = 2
	for i in range(3, n+1):
		c = 2 * b + a
		a = b
		b = c
	return b

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


Write a function to find sum of the numbers in a list between the indices of a specified range.

def sum_range_list(list1, m, n):
    sum_range = 0
    for i in range(m, n+1, 1):
        sum_range += list1[i]
    return sum_range

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


Write a function to find the perimeter of a pentagon.

import math
def perimeter_pentagon(a):
  perimeter=(5*a)
  return perimeter

IMPORT FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN VAR


Write a function to find the occurence of characters 'std' in the given string 1. list item 1. list item 1. list item 2. list item 2. list item 2. list item

def count_occurance(s):
  count=0
  for i in range(len(s)):
    if (s[i]== 's' and s[i+1]=='t' and s[i+2]== 'd'):
      count = count + 1
  return count

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


Write a function to remove everything except alphanumeric characters from a string.

import re
def remove_splchar(text):
 pattern = re.compile('[\W_]+')
 return (pattern.sub('', text))

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


Write a function to group a sequence of key-value pairs into a dictionary of lists.

def group_keyvalue(l):
    result = {}
    for k, v in l:
         result.setdefault(k, []).append(v)
    return result

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


Write a function to verify validity of a string of parentheses.

def is_valid_parenthese( str1):
        stack, pchar = [], {"(": ")", "{": "}", "[": "]"}
        for parenthese in str1:
            if parenthese in pchar:
                stack.append(parenthese)
            elif len(stack) == 0 or pchar[stack.pop()] != parenthese:
                return False
        return len(stack) == 0

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


Write a function to find the perimeter of a triangle.

def perimeter_triangle(a,b,c):
  perimeter=a+b+c
  return perimeter

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR


Write a python function to find two distinct numbers such that their lcm lies within the given range.

def answer(L,R):
    if (2 * L <= R):
        return (L ,2*L)
    else:
        return (-1)

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


Write a function to search some literals strings in a string.

import re
def string_literals(patterns,text):
  for pattern in patterns:
     if re.search(pattern,  text):
       return ('Matched!')
     else:
       return ('Not Matched!')

IMPORT FUNC_DEF FOR VAR VAR IF FUNC_CALL VAR VAR VAR RETURN STRING RETURN STRING


Write a function to find if the given number is a keith number or not.

def is_num_keith(x):
	terms = []
	temp = x
	n = 0
	while (temp > 0):
		terms.append(temp % 10)
		temp = int(temp / 10)
		n+=1
	terms.reverse()
	next_term = 0
	i = n
	while (next_term < x):
		next_term = 0
		for j in range(1,n+1):
			next_term += terms[i - j]
		terms.append(next_term)
		i+=1
	return (next_term == x)

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


Write a function to calculate distance between two points using latitude and longitude.

from math import radians, sin, cos, acos
def distance_lat_long(slat,slon,elat,elon):
 dist = 6371.01 * acos(sin(slat)*sin(elat) + cos(slat)*cos(elat)*cos(slon - elon))
 return dist

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


Write a function to find the longest common prefix in the given set of strings.

def common_prefix_util(str1, str2):
	result = "";
	n1 = len(str1)
	n2 = len(str2)
	i = 0
	j = 0
	while i <= n1 - 1 and j <= n2 - 1:
		if (str1[i] != str2[j]):
			break
		result += str1[i]
		i += 1
		j += 1
	return (result)
def common_prefix (arr, n):
	prefix = arr[0]
	for i in range (1, n):
		prefix = common_prefix_util(prefix, arr[i])
	return (prefix)

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


Write a function to find uppercase, lowercase, special character and numeric values using regex.

import re
def find_character(string):
  uppercase_characters = re.findall(r"[A-Z]", string)
  lowercase_characters = re.findall(r"[a-z]", string)
  numerical_characters = re.findall(r"[0-9]", string)
  special_characters = re.findall(r"[, .!?]", string)
  return uppercase_characters, lowercase_characters, numerical_characters, special_characters

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


Write a function to count all the distinct pairs having a difference of k in any array.

def count_pairs(arr, n, k):
  count=0;
  for i in range(0,n):
    for j in range(i+1, n):
      if arr[i] - arr[j] == k or arr[j] - arr[i] == k:
        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 BIN_OP VAR VAR VAR VAR VAR VAR NUMBER RETURN VAR


Write a function to find all the values in a list that are greater than a specified number.

def greater_specificnum(list,num):
 greater_specificnum=all(x >= num for x in list)
 return greater_specificnum

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR


Write a function to find the focus of a parabola.

def parabola_focus(a, b, c):
  focus= (((-b / (2 * a)),(((4 * a * c) - (b * b) + 1) / (4 * a))))
  return focus

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


Write a function to search some literals strings in a string by using regex.

import re
def check_literals(text, patterns):
  for pattern in patterns:
    if re.search(pattern,  text):
        return ('Matched!')
    else:
        return ('Not Matched!')


Write a function to find the longest common subsequence for the given two sequences.

def longest_common_subsequence(X, Y, m, n):
    if m == 0 or n == 0:
       return 0
    elif X[m-1] == Y[n-1]:
       return 1 + longest_common_subsequence(X, Y, m-1, n-1)
    else:
       return max(longest_common_subsequence(X, Y, m, n-1), longest_common_subsequence(X, Y, m-1, n))

FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER 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 FUNC_CALL VAR FUNC_CALL VAR VAR VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR


Write a python function to check whether the given number can be represented by product of two squares or not.

def prod_Square(n):
    for i in range(2,(n) + 1):
        if (i*i < (n+1)):
            for j in range(2,n + 1):
                if ((i*i*j*j) == n):
                    return True;
    return False;

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


Write a python function to find the first missing positive number.

def first_Missing_Positive(arr,n):
    ptr = 0
    for i in range(n):
        if arr[i] == 1:
            ptr = 1
            break
    if ptr == 0:
        return(1)
    for i in range(n):
        if arr[i] <= 0 or arr[i] > n:
            arr[i] = 1
    for i in range(n):
        arr[(arr[i] - 1) % n] += n
    for i in range(n):
        if arr[i] <= n:
            return(i + 1)
    return(n + 1)

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


Write a python function to count the number of integral co-ordinates that lie inside a square.

def count_Intgral_Points(x1,y1,x2,y2):
    return ((y2 - y1 - 1) * (x2 - x1 - 1))

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


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

def check_monthnumber(monthname3):
  if monthname3 =="April" or monthname3== "June" or monthname3== "September" or monthname3== "November":
    return True
  else:
    return False

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


Write a python function to check whether a string has atleast one letter and one number.

def check_String(str):
    flag_l = False
    flag_n = False
    for i in str:
        if i.isalpha():
            flag_l = True
        if i.isdigit():
            flag_n = True
    return flag_l and flag_n

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


Write a function to remove the duplicates from the given tuple.

def remove_tuple(test_tup):
  res = tuple(set(test_tup))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR


Write a python function to convert octal number to decimal number.

def octal_To_Decimal(n):
    num = n;
    dec_value = 0;
    base = 1;
    temp = num;
    while (temp):
        last_digit = temp % 10;
        temp = int(temp / 10);
        dec_value += last_digit*base;
        base = base * 8;
    return dec_value;

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


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

def first(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
            high = 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 to remove all the tuples with length k.

def remove_tuples(test_list, K):
  res = [ele for ele in test_list if len(ele) != K]
  return (res)

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


Write a function to perform the exponentiation of the given two tuples.

def find_exponentio(test_tup1, test_tup2):
  res = tuple(ele1 ** ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
  return (res)

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


Write a function to find the largest triangle that can be inscribed in an ellipse.

import math
def largest_triangle(a,b):
    if (a < 0 or b < 0):
        return -1
    area = (3 * math.sqrt(3) * pow(a, 2)) / (4 * b);
    return area

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


Write a python function to find highest power of 2 less than or equal to given number.

def highest_Power_of_2(n):
    res = 0;
    for i in range(n, 0, -1):
        if ((i & (i - 1)) == 0):
            res = i;
            break;
    return res;

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


Write a function to find all index positions of the maximum values in a given list.

def position_max(list1):
    max_val = max(list1)
    max_result = [i for i, j in enumerate(list1) if j == max_val]
    return max_result

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


Write a python function to check whether the elements in a list are same or not.

def chkList(lst):
    return len(set(lst)) == 1

FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR NUMBER


Write a function to remove even characters in a string.

def remove_even(str1):
 str2 = ''
 for i in range(1, len(str1) + 1):
    if(i % 2 != 0):
        str2 = str2 + str1[i - 1]
 return str2

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


Write a python function to find the hamming distance between given two integers.

def hamming_Distance(n1,n2) :
    x = n1 ^ n2
    setBits = 0
    while (x > 0) :
        setBits += x & 1
        x >>= 1
    return setBits

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


Write a python function to count the occurrence of a given character in a string.

def count(s,c) :
    res = 0
    for i in range(len(s)) :
        if (s[i] == c):
            res = res + 1
    return res

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


Write a function to find the inversions of tuple elements in the given tuple list.

def inversion_elements(test_tup):
  res = tuple(list(map(lambda x: ~x, list(test_tup))))
  return (res)

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


Write a function to perform the adjacent element concatenation in the given tuples.

def concatenate_elements(test_tup):
  res = tuple(i + j for i, j in zip(test_tup, test_tup[1:]))
  return (res)

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


Write a function to count the longest repeating subsequences such that the two subsequences don’t have same string characters at same positions.

def find_longest_repeating_subseq(str):
	n = len(str)
	dp = [[0 for k in range(n+1)] for l in range(n+1)]
	for i in range(1, n+1):
		for j in range(1, n+1):
			if (str[i-1] == str[j-1] and i != j):
				dp[i][j] = 1 + dp[i-1][j-1]
			else:
				dp[i][j] = max(dp[i][j-1], dp[i-1][j])
	return dp[n][n]

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR 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 VAR NUMBER IF VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR VAR ASSIGN VAR VAR VAR BIN_OP NUMBER VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER ASSIGN VAR VAR VAR FUNC_CALL VAR VAR VAR BIN_OP VAR NUMBER VAR BIN_OP VAR NUMBER VAR RETURN VAR VAR VAR


Write a function to check the given decimal with a precision of 2 by using regex.

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

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


Write a function to delete the smallest element from the given heap and then insert a new item.

import heapq as hq
def heap_replace(heap,a):
  hq.heapify(heap)
  hq.heapreplace(heap, a)
  return heap

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


Write a function to check that the given string contains only a certain set of characters(in this case a-z, a-z and 0-9) by using regex.

import re
def is_allowed_specific_char(string):
    get_char = re.compile(r'[^a-zA-Z0-9.]')
    string = get_char.search(string)
    return not bool(string)


Write a python function to count numbers whose oth and nth bits are set.

def count_Num(n):
    if (n == 1):
        return 1
    count = pow(2,n - 2)
    return count

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


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

import math
def fourth_Power_Sum(n):
    sum = 0
    for i in range(1,n+1) :
        sum = sum + (i*i*i*i)
    return sum

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


Write a function to perform the concatenation of two string tuples.

def concatenate_strings(test_tup1, test_tup2):
  res = tuple(ele1 + ele2 for ele1, ele2 in zip(test_tup1, test_tup2))
  return (res)


Write a function to convert radians to degrees.

import math
def degree_radian(radian):
 degree = radian*(180/math.pi)
 return degree

IMPORT FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP NUMBER VAR RETURN VAR


Write a function to decode a run-length encoded given list.

def decode_list(alist):
    def aux(g):
        if isinstance(g, list):
            return [(g[1], range(g[0]))]
        else:
            return [(g, [0])]
    return [x for g in alist for x, R in aux(g) for i in R]

FUNC_DEF FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN LIST VAR NUMBER FUNC_CALL VAR VAR NUMBER RETURN LIST VAR LIST NUMBER RETURN VAR VAR VAR VAR VAR FUNC_CALL VAR VAR VAR VAR


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

def check_subset_list(list1, list2):
    l1, l2 = list1[0], list2[0]
    exist = True
    for i in list2:
        if i not in list1:
            exist = False
    return exist

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


Write a python function to find the first repeated character in a given string.

def first_Repeated_Char(str):
    h = {}
    for ch in str:
        if ch in h:
            return ch;
        else:
            h[ch] = 0
    return '\0'

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


Write a python function to find the minimum operations required to make two numbers equal.

import math
def min_Operations(A,B):
    if (A > B):
        swap(A,B)
    B = B // math.gcd(A,B);
    return B - 1

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


Write a function to extract maximum and minimum k elements in the given tuple.

def extract_min_max(test_tup, K):
  res = []
  test_tup = list(test_tup)
  temp = sorted(test_tup)
  for idx, val in enumerate(temp):
    if idx < K or idx >= len(temp) - K:
      res.append(val)
  res = tuple(res)
  return (res)

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


Write a function to replace maximum n occurrences of spaces, commas, or dots with a colon.

import re
def replace_max_specialchar(text,n):
 return (re.sub("[ ,.]", ":", text, n))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR VAR


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

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

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


Write a function to check if all the elements in tuple have same data type or not.

def check_type(test_tuple):
  res = True
  for ele in test_tuple:
    if not isinstance(ele, type(test_tuple[0])):
      res = False
      break
  return (res)

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


Write a function to check for majority element in the given sorted array.

def is_majority(arr, n, x):
	i = binary_search(arr, 0, n-1, x)
	if i == -1:
		return False
	if ((i + n//2) <= (n -1)) and arr[i + n//2] == x:
		return True
	else:
		return False
def binary_search(arr, low, high, x):
	if high >= low:
		mid = (low + high)//2
		if (mid == 0 or x > arr[mid-1]) and (arr[mid] == x):
			return mid
		elif x > arr[mid]:
			return binary_search(arr, (mid + 1), high, x)
		else:
			return binary_search(arr, low, (mid -1), x)
	return -1

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


Write a python function to count set bits of a given number.

def count_Set_Bits(n):
    count = 0
    while (n):
        count += n & 1
        n >>= 1
    return count

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


Write a python function to find the minimum element in a sorted and rotated array.

def find_Min(arr,low,high):
    while (low < high):
        mid = low + (high - low) // 2;
        if (arr[mid] == arr[high]):
            high -= 1;
        elif (arr[mid] > arr[high]):
            low = mid + 1;
        else:
            high = mid;
    return arr[high];

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


Write a python function to remove the characters which have odd index values of a given string.

def odd_values_string(str):
  result = ""
  for i in range(len(str)):
    if i % 2 == 0:
      result = result + str[i]
  return result

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


Write a function to find minimum of three numbers.

def min_of_three(a,b,c):
      if (a <= b) and (a <= c):
        smallest = a
      elif (b <= a) and (b <= c):
        smallest = b
      else:
        smallest = c
      return smallest

FUNC_DEF IF VAR VAR VAR VAR ASSIGN VAR VAR IF VAR VAR VAR VAR ASSIGN VAR VAR ASSIGN VAR VAR RETURN VAR


Write a python function to check whether all the bits are unset in the 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 (new_num == 0):
        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 NUMBER RETURN NUMBER RETURN NUMBER


Write a function to re-arrange the elements of the given array so that all negative elements appear before positive ones.

def re_arrange_array(arr, n):
  j=0
  for i in range(0, n):
    if (arr[i] < 0):
      temp = arr[i]
      arr[i] = arr[j]
      arr[j] = temp
      j = j + 1
  return arr

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


Write a function to replace blank spaces with any character in a string.

def replace_blank(str1,char):
 str2 = str1.replace(' ', char)
 return str2

FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR RETURN VAR


Write a function to find the maximum sum in the given right triangle of numbers.

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


Write a function to get the n largest items from a dataset.

import heapq
def larg_nnum(list1,n):
 largest=heapq.nlargest(n,list1)
 return largest

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find the lateral surface area of a cylinder.

def lateralsuface_cylinder(r,h):
  lateralsurface= 2*3.1415*r*h
  return lateralsurface

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


Write a function to find the volume of a cube.

def volume_cube(l):
  volume = l * l * l
  return volume

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR


Write a python function to set all even bits of a given number.

def even_bit_set_number(n):
    count = 0;res = 0;temp = n
    while(temp > 0):
        if (count % 2 == 1):
            res |= (1 << count)
        count+=1
        temp >>= 1
    return (n | res)

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


Write a python function to count the maximum number of equilateral triangles that can be formed within a given equilateral triangle.

def No_of_Triangle(N,K):
    if (N < K):
        return -1;
    else:
        Tri_up = 0;
        Tri_up = ((N - K + 1) *(N - K + 2)) // 2;
        Tri_down = 0;
        Tri_down = ((N - 2 * K + 1) *(N - 2 * K + 2)) // 2;
        return Tri_up + Tri_down;

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


Write a function to check the occurrences of records which occur similar times in the given tuples.

from collections import Counter
def check_occurences(test_list):
  res = dict(Counter(tuple(ele) for ele in map(sorted, test_list)))
  return  (res)

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


Write a python function to count number of non-empty substrings of a given string.

def number_of_substrings(str):
	str_len = len(str);
	return int(str_len * (str_len + 1) / 2);

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


Write a function to find the number of possible sequences of length n such that each of the next element is greater than or equal to twice of the previous element but less than or equal to m.

def get_total_number_of_sequences(m,n):
	T=[[0 for i in range(n+1)] for i in range(m+1)]
	for i in range(m+1):
		for j in range(n+1):
			if i==0 or j==0:
				T[i][j]=0
			elif i<j:
				T[i][j]=0
			elif j==1:
				T[i][j]=i
			else:
				T[i][j]=T[i-1][j]+T[i//2][j-1]
	return T[m][n]

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 BIN_OP VAR NUMBER FOR VAR FUNC_CALL VAR BIN_OP VAR NUMBER IF VAR NUMBER VAR NUMBER ASSIGN VAR VAR VAR NUMBER IF VAR VAR ASSIGN VAR VAR VAR NUMBER IF VAR NUMBER ASSIGN VAR VAR VAR VAR ASSIGN VAR VAR VAR BIN_OP VAR BIN_OP VAR NUMBER VAR VAR BIN_OP VAR NUMBER BIN_OP VAR NUMBER RETURN VAR VAR VAR


Write a function to replace the last element of the list with another list.

def replace_list(list1,list2):
 list1[-1:] = list2
 replace_list=list1
 return replace_list

FUNC_DEF ASSIGN VAR NUMBER VAR ASSIGN VAR VAR RETURN VAR


Write a function to generate a 3d array having each element as '*'.

def array_3d(m,n,o):
 array_3d = [[ ['*' for col in range(m)] for col in range(n)] for row in range(o)]
 return array_3d

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


Write a function to count total characters in a string.

def count_charac(str1):
 total = 0
 for i in str1:
    total = total + 1
 return total

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


Write a function to sort the given list based on the occurrence of first element of tuples.

def sort_on_occurence(lst):
	dct = {}
	for i, j in lst:
		dct.setdefault(i, []).append(j)
	return ([(i, *dict.fromkeys(j), len(j))
				for i, j in dct.items()])

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


Write a python function to find the next perfect square greater than a given number.

import math
def next_Perfect_Square(N):
    nextN = math.floor(math.sqrt(N)) + 1
    return nextN * nextN

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