Write a function to find the maximum sum of bi-tonic sub-sequence for the given array.

def max_sum(arr, n):
	MSIBS = arr[:]
	for i in range(n):
		for j in range(0, i):
			if arr[i] > arr[j] and MSIBS[i] < MSIBS[j] + arr[i]:
				MSIBS[i] = MSIBS[j] + arr[i]
	MSDBS = arr[:]
	for i in range(1, n + 1):
		for j in range(1, i):
			if arr[-i] > arr[-j] and MSDBS[-i] < MSDBS[-j] + arr[-i]:
				MSDBS[-i] = MSDBS[-j] + arr[-i]
	max_sum = float("-Inf")
	for i, j, k in zip(MSIBS, MSDBS, arr):
		max_sum = max(max_sum, i + j - k)
	return max_sum

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


Write a function for computing square roots using the babylonian method.

def babylonian_squareroot(number):
    if(number == 0):
        return 0;
    g = number/2.0;
    g2 = g + 1;
    while(g != g2):
        n = number/ g;
        g2 = g;
        g = (g + n)/2;
    return g;

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


Write a function to find the longest palindromic subsequence in the given string.

def lps(str):
	n = len(str)
	L = [[0 for x in range(n)] for x in range(n)]
	for i in range(n):
		L[i][i] = 1
	for cl in range(2, n+1):
		for i in range(n-cl+1):
			j = i+cl-1
			if str[i] == str[j] and cl == 2:
				L[i][j] = 2
			elif str[i] == str[j]:
				L[i][j] = L[i+1][j-1] + 2
			else:
				L[i][j] = max(L[i][j-1], L[i+1][j]);
	return L[0][n-1]

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


Write a function to calculate the harmonic sum of n-1.

def harmonic_sum(n):
  if n < 2:
    return 1
  else:
    return 1 / n + (harmonic_sum(n - 1))

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


Write a function to find the intersection of two arrays using lambda function.

def intersection_array(array_nums1,array_nums2):
 result = list(filter(lambda x: x in array_nums1, array_nums2))
 return result

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


Write a python function to count the occcurences of an element in a tuple.

def count_X(tup, x):
    count = 0
    for ele in tup:
        if (ele == x):
            count = count + 1
    return count

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


Write a function to insert an element before each element of a list.

def insert_element(list,element):
 list = [v for elt in list for v in (element, elt)]
 return list

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR RETURN VAR


Write a python function to convert complex numbers to polar coordinates.

import cmath
def convert(numbers):
  num = cmath.polar(numbers)
  return (num)

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR


Write a python function to count integers from a given list.

def count_integer(list1):
    ctr = 0
    for i in list1:
        if isinstance(i, int):
            ctr = ctr + 1
    return ctr

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


Write a function to find all words starting with 'a' or 'e' in a given string.

import re
def words_ae(text):
 list = re.findall("[ae]\w+", text)
 return list

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING VAR RETURN VAR


Write a function to choose specified number of colours from three different colours and generate all the combinations with repetitions.

from itertools import combinations_with_replacement
def combinations_colors(l, n):
    return list(combinations_with_replacement(l,n))

FUNC_DEF RETURN FUNC_CALL VAR FUNC_CALL VAR VAR VAR


Write a python function to count the number of prime numbers less than a given non-negative number.

def count_Primes_nums(n):
    ctr = 0
    for num in range(n):
        if num <= 1:
            continue
        for i in range(2,num):
            if (num % i) == 0:
                break
        else:
            ctr += 1
    return ctr

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


Write a function to swap two numbers.

def swap_numbers(a,b):
 temp = a
 a = b
 b = temp
 return (a,b)

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


Write a function to find number of odd elements in the given list using lambda function.

def count_odd(array_nums):
   count_odd = len(list(filter(lambda x: (x%2 != 0) , array_nums)))
   return count_odd

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


Write a function to maximize the given two tuples.

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

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


Write a function to find the nth newman–shanks–williams prime number.

def newman_prime(n):
	if n == 0 or n == 1:
		return 1
	return 2 * newman_prime(n - 1) + newman_prime(n - 2)

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


Write a function to perform mathematical division operation across the given tuples.

def division_elements(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 split a given list into two parts where the length of the first part of the list is given.

def split_two_parts(list1, L):
    return list1[:L], list1[L:]


Write a function to merge two dictionaries.

def merge_dict(d1,d2):
 d = d1.copy()
 d.update(d2)
 return d

FUNC_DEF ASSIGN VAR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR RETURN VAR


Write a function to calculate a dog's age in dog's years.

def dog_age(h_age):
 if h_age < 0:
 	exit()
 elif h_age <= 2:
	 d_age = h_age * 10.5
 else:
	 d_age = 21 + (h_age - 2)*4
 return d_age

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


Write a function to split a list for every nth element.

def list_split(S, step):
    return [S[i::step] for i in range(step)]

FUNC_DEF RETURN VAR VAR VAR VAR FUNC_CALL VAR VAR


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

def lateralsurface_cube(l):
  LSA = 4 * (l * l)
  return LSA

FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR RETURN VAR


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

def square_Sum(n):
    return int(n*(4*n*n-1)/3)

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


Write a function to find the n'th star number.

def find_star_num(n):
	return (6 * n * (n - 1) + 1)

FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR BIN_OP VAR NUMBER NUMBER


Write a function to find the ascii value of a character.

def ascii_value(k):
  ch=k
  return ord(ch)

FUNC_DEF ASSIGN VAR VAR RETURN FUNC_CALL VAR VAR


Write a python function to find the sum of even numbers at even positions.

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

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


Write a python function to find the sum of fifth power of first n even natural numbers.

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

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


Write a function to perfom the rear element extraction from list of tuples records.

def rear_extract(test_list):
  res = [lis[-1] for lis in test_list]
  return (res)

FUNC_DEF ASSIGN VAR VAR NUMBER VAR VAR RETURN VAR


Write a function to substract the contents of one tuple with corresponding index of other tuple.

def substract_elements(test_tup1, test_tup2):
  res = tuple(map(lambda i, j: i - j, test_tup1, test_tup2))
  return (res)

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


Write a python function to find sum of even index binomial coefficients.

import math
def even_binomial_Coeff_Sum( n):
    return (1 << (n - 1))

IMPORT FUNC_DEF RETURN BIN_OP NUMBER BIN_OP VAR NUMBER


Write a python function to find the position of the last removed element from the given array.

import math as mt
def get_Position(a,n,m):
    for i in range(n):
        a[i] = (a[i] // m + (a[i] % m != 0))
    result,maxx = -1,-1
    for i in range(n - 1,-1,-1):
        if (maxx < a[i]):
            maxx = a[i]
            result = i
    return result + 1

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


Write a function to find the volume of a cylinder.

def volume_cylinder(r,h):
  volume=3.1415*r*r*h
  return volume

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


Write a function to filter a dictionary based on values.

def dict_filter(dict,n):
 result = {key:value for (key, value) in dict.items() if value >=n}
 return result

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


Write a function to find the element count that occurs before the record in the given tuple.

def count_first_elements(test_tup):
  for count, ele in enumerate(test_tup):
    if isinstance(ele, tuple):
      break
  return (count)

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


Write a function to find the nth decagonal number.

def is_num_decagonal(n):
	return 4 * n * n - 3 * n

FUNC_DEF RETURN BIN_OP BIN_OP BIN_OP NUMBER VAR VAR BIN_OP NUMBER VAR


Write a function to search an element in the given array by using sequential search.

def sequential_search(dlist, item):
    pos = 0
    found = False
    while pos < len(dlist) and not found:
        if dlist[pos] == item:
            found = True
        else:
            pos = pos + 1
    return found, pos

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


Write a python function to check if the elements of a given list are unique or not.

def all_unique(test_list):
    if len(test_list) > len(set(test_list)):
        return False
    return True

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


Write a function to substaract two lists using map and lambda function.

def sub_list(nums1,nums2):
  result = map(lambda x, y: x - y, nums1, nums2)
  return list(result)

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


Write a python function to check whether the frequency of each digit is less than or equal to the digit itself.

def validate(n):
    for i in range(10):
        temp = n;
        count = 0;
        while (temp):
            if (temp % 10 == i):
                count+=1;
            if (count > i):
                return False
            temp //= 10;
    return True

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


Write a function to check whether all items of a list are equal to a given string.

def check_element(list,element):
  check_element=all(v== element for v in list)
  return check_element

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR


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

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

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


Write a function to find the largest sum of contiguous array in the modified array which is formed by repeating the given array k times.

def max_sub_array_sum_repeated(a, n, k):
	max_so_far = -2147483648
	max_ending_here = 0
	for i in range(n*k):
		max_ending_here = max_ending_here + a[i%n]
		if (max_so_far < max_ending_here):
			max_so_far = max_ending_here
		if (max_ending_here < 0):
			max_ending_here = 0
	return max_so_far

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


Write a python function to find the sum of squares of first n even natural numbers.

def square_Sum(n):
    return int(2*n*(n+1)*(2*n+1)/3)

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


Write a function to count array elements having modular inverse under given prime number p equal to itself.

def modular_inverse(arr, N, P):
	current_element = 0
	for i in range(0, N):
		if ((arr[i] * arr[i]) % P == 1):
			current_element = current_element + 1
	return current_element

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


Write a python function to calculate the number of odd days in a given year.

def odd_Days(N):
    hund1 = N // 100
    hund4 = N // 400
    leap = N >> 2
    ordd = N - leap
    if (hund1):
        ordd += hund1
        leap -= hund1
    if (hund4):
        ordd -= hund4
        leap += hund4
    days = ordd + leap * 2
    odd = days % 7
    return odd

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


Write a function to find the list of lists with maximum length.

def max_length(list1):
    max_length = max(len(x) for x in  list1 )
    max_list = max((x) for x in   list1)
    return(max_length, max_list)

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


Write a function to find out the number of ways of painting the fence such that at most 2 adjacent posts have the same color for the given fence with n posts and k colors.

def count_no_of_ways(n, k):
	dp = [0] * (n + 1)
	total = k
	mod = 1000000007
	dp[1] = k
	dp[2] = k * k
	for i in range(3,n+1):
		dp[i] = ((k - 1) * (dp[i - 1] + dp[i - 2])) % mod
	return dp[n]

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


Write a python function to find quotient of two numbers.

def find(n,m):
    q = n//m
    return (q)

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a function to find the third side of a right angled triangle.

import math
def otherside_rightangle(w,h):
  s=math.sqrt((w*w)+(h*h))
  return s

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


Write a function to find the maximum value in a given heterogeneous list.

def max_val(listval):
     max_val = max(i for i in listval if isinstance(i, int))
     return(max_val)

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


Write a function to return the sum of all divisors of a number.

def sum_div(number):
    divisors = [1]
    for i in range(2, number):
        if (number % i)==0:
            divisors.append(i)
    return sum(divisors)

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


Write a python function to count inversions in an array.

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

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


Write a function to flatten a given nested list structure.

def flatten_list(list1):
    result_list = []
    if not list1: return result_list
    stack = [list(list1)]
    while stack:
        c_num = stack.pop()
        next = c_num.pop()
        if c_num: stack.append(c_num)
        if isinstance(next, list):
            if next: stack.append(list(next))
        else: result_list.append(next)
    result_list.reverse()
    return result_list

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


Write a function to find the nested list elements which are present in another list.

def intersection_nested_lists(l1, l2):
    result = [[n for n in lst if n in l1] for lst in l2]
    return result

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


Write a function to calculate the maximum aggregate from the list of tuples.

from collections import defaultdict
def max_aggregate(stdata):
    temp = defaultdict(int)
    for name, marks in stdata:
        temp[name] += marks
    return max(temp.items(), key=lambda x: x[1])

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


Write a function to find the count of all binary sequences of length 2n such that sum of first n bits is same as sum of last n bits.

def count_binary_seq(n):
	nCr = 1
	res = 1
	for r in range(1, n + 1):
		nCr = (nCr * (n + 1 - r)) / r
		res += nCr * nCr
	return res

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


Write a function to find the depth of a dictionary.

def dict_depth(d):
    if isinstance(d, dict):
        return 1 + (max(map(dict_depth, d.values())) if d else 0)
    return 0

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


Write a python function to find the most significant bit number which is also a set bit.

def set_Bit_Number(n):
    if (n == 0):
        return 0;
    msb = 0;
    n = int(n / 2);
    while (n > 0):
        n = int(n / 2);
        msb += 1;
    return (1 << msb)

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


Write a python function to check whether the count of inversion of two types are same or not.

import sys
def solve(a,n):
    mx = -sys.maxsize - 1
    for j in range(1,n):
        if (mx > a[j]):
            return False
        mx = max(mx,a[j - 1])
    return True

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


Write a python function to find element at a given index after number of rotations.

def find_Element(arr,ranges,rotations,index) :
    for i in range(rotations - 1,-1,-1 ) :
        left = ranges[i][0]
        right = ranges[i][1]
        if (left <= index and right >= index) :
            if (index == left) :
                index = right
            else :
                index = index - 1
    return arr[index]

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


Write a function to match two words from a list of words starting with letter 'p'.

import re
def start_withp(words):
 for w in words:
        m = re.match("(P\w+)\W(P\w+)", w)
        if m:
            return m.groups()

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


Write a function to find the maximum sum of increasing subsequence from prefix till ith index and also including a given kth element which is after i, i.e., k > i .

def max_sum_increasing_subseq(a, n, index, k):
	dp = [[0 for i in range(n)]
			for i in range(n)]
	for i in range(n):
		if a[i] > a[0]:
			dp[0][i] = a[i] + a[0]
		else:
			dp[0][i] = a[i]
	for i in range(1, n):
		for j in range(n):
			if a[j] > a[i] and j > i:
				if dp[i - 1][i] + a[j] > dp[i - 1][j]:
					dp[i][j] = dp[i - 1][i] + a[j]
				else:
					dp[i][j] = dp[i - 1][j]
			else:
				dp[i][j] = dp[i - 1][j]
	return dp[index][k]

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


Write a function to get a colon of a tuple.

from copy import deepcopy
def colon_tuplex(tuplex,m,n):
  tuplex_colon = deepcopy(tuplex)
  tuplex_colon[m].append(n)
  return tuplex_colon

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


Write a function to find the specified number of largest products from two given lists.

def large_product(nums1, nums2, N):
    result = sorted([x*y for x in nums1 for y in nums2], reverse=True)[:N]
    return result

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


Write a python function to find the maximum of two numbers.

def maximum(a,b):
    if a >= b:
        return a
    else:
        return b

FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR


Write a function to convert a given string to a tuple.

def string_to_tuple(str1):
    result = tuple(x for x in str1 if not x.isspace())
    return result

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


Write a python function to set the left most unset bit.

def set_left_most_unset_bit(n):
    if not (n & (n + 1)):
        return n
    pos, temp, count = 0, n, 0
    while temp:
        if not (temp & 1):
            pos = count
        count += 1; temp>>=1
    return (n | (1 << (pos)))

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


Write a function to find the volume of a cone.

import math
def volume_cone(r,h):
  volume = (1.0/3) * math.pi * r * r * h
  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 print positive numbers in a list.

def pos_nos(list1):
  for num in list1:
    if num >= 0:
       return num

FUNC_DEF FOR VAR VAR IF VAR NUMBER RETURN VAR


Write a function to find out the maximum sum such that no two chosen numbers are adjacent for the given rectangular grid of dimension 2 x n.

def max_sum_rectangular_grid(grid, n) :
	incl = max(grid[0][0], grid[1][0])
	excl = 0
	for i in range(1, n) :
		excl_new = max(excl, incl)
		incl = excl + max(grid[0][i], grid[1][i])
		excl = excl_new
	return max(excl, incl)

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


Write a python function to find the first maximum length of even word.

def find_Max_Len_Even(str):
    n = len(str)
    i = 0
    currlen = 0
    maxlen = 0
    st = -1
    while (i < n):
        if (str[i] == ' '):
            if (currlen % 2 == 0):
                if (maxlen < currlen):
                    maxlen = currlen
                    st = i - currlen
            currlen = 0
        else :
            currlen += 1
        i += 1
    if (currlen % 2 == 0):
        if (maxlen < currlen):
            maxlen = currlen
            st = i - currlen
    if (st == -1):
        return "-1"
    return str[st: st + maxlen]

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


Write a function to find the index of the last occurrence of a given number in a sorted array.

def find_last_occurrence(A, x):
    (left, right) = (0, len(A) - 1)
    result = -1
    while left <= right:
        mid = (left + right) // 2
        if x == A[mid]:
            result = mid
            left = mid + 1
        elif x < A[mid]:
            right = mid - 1
        else:
            left = mid + 1
    return result

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


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

from itertools import groupby
def modified_encode(alist):
        def ctr_ele(el):
            if len(el)>1: return [len(el), el[0]]
            else: return el[0]
        return [ctr_ele(list(group)) for key, group in groupby(alist)]

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


Write a python function to find the maximum volume of a cuboid with given sum of sides.

def max_volume (s):
    maxvalue = 0
    i = 1
    for i in range(s - 1):
        j = 1
        for j in range(s):
            k = s - i - j
            maxvalue = max(maxvalue, i * j * k)
    return maxvalue

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


Write a function to find all five characters long word in the given string by using regex.

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

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


Write a function to calculate the difference between the squared sum of first n natural numbers and the sum of squared first n natural numbers.

def sum_difference(n):
    sumofsquares = 0
    squareofsum = 0
    for num in range(1, n+1):
        sumofsquares += num * num
        squareofsum += num
    squareofsum = squareofsum ** 2
    return squareofsum - sumofsquares

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


Write a function to find the demlo number for the given number.

def find_demlo(s):
	l = len(s)
	res = ""
	for i in range(1,l+1):
		res = res + str(i)
	for i in range(l-1,0,-1):
		res = res + str(i)
	return res

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


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

def position_min(list1):
    min_val = min(list1)
    min_result = [i for i, j in enumerate(list1) if j == min_val]
    return min_result

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


Write a function to re-arrange the given array in alternating positive and negative items.

def right_rotate(arr, n, out_of_place, cur):
	temp = arr[cur]
	for i in range(cur, out_of_place, -1):
		arr[i] = arr[i - 1]
	arr[out_of_place] = temp
	return arr
def re_arrange(arr, n):
	out_of_place = -1
	for index in range(n):
		if (out_of_place >= 0):
			if ((arr[index] >= 0 and arr[out_of_place] < 0) or
			(arr[index] < 0 and arr[out_of_place] >= 0)):
				arr = right_rotate(arr, n, out_of_place, index)
				if (index-out_of_place > 2):
					out_of_place += 2
				else:
					out_of_place = - 1
		if (out_of_place == -1):
			if ((arr[index] >= 0 and index % 2 == 0) or
			 (arr[index] < 0 and index % 2 == 1)):
				out_of_place = index
	return arr

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


Write a function to extract the sum of alternate chains of tuples.

def sum_of_alternates(test_tuple):
  sum1 = 0
  sum2 = 0
  for idx, ele in enumerate(test_tuple):
    if idx % 2:
      sum1 += ele
    else:
      sum2 += ele
  return ((sum1),(sum2))

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


Write a python function to find the minimum number of squares whose sum is equal to a given number.

def get_Min_Squares(n):
    if n <= 3:
        return n;
    res = n
    for x in range(1,n + 1):
        temp = x * x;
        if temp > n:
            break
        else:
            res = min(res,1 + get_Min_Squares(n  - temp))
    return res;

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


Write a function to get the word with most number of occurrences in the given strings list.

from collections import defaultdict

def most_occurrences(test_list):
  temp = defaultdict(int)
  for sub in test_list:
    for wrd in sub.split():
      temp[wrd] += 1
  res = max(temp, key=temp.get)
  return (str(res))

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


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

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

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


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

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

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR VAR VAR RETURN VAR


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

def neg_count(list):
  neg_count= 0
  for num in list:
    if num <= 0:
      neg_count += 1
  return neg_count

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


Write a function to find all three, four, five characters long words in the given string by using regex.

import re
def find_char(text):
  return (re.findall(r"\b\w{3,5}\b", text))


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

def count_unset_bits(n):
    count = 0
    x = 1
    while(x < n + 1):
        if ((x & n) == 0):
            count += 1
        x = x << 1
    return count

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


Write a function to count character frequency of a given string.

def char_frequency(str1):
    dict = {}
    for n in str1:
        keys = dict.keys()
        if n in keys:
            dict[n] += 1
        else:
            dict[n] = 1
    return dict

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


Write a python function to sort a list according to the second element in sublist.

def Sort(sub_li):
    sub_li.sort(key = lambda x: x[1])
    return sub_li

FUNC_DEF EXPR FUNC_CALL VAR VAR NUMBER RETURN VAR


Write a python function to check whether the triangle is valid or not if sides are given.

def check_Validity(a,b,c):
    if (a + b <= c) or (a + c <= b) or (b + c <= a) :
        return False
    else:
        return True

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


Write a function to find the sum of arithmetic progression.

def ap_sum(a,n,d):
  total = (n * (2 * a + (n - 1) * d)) / 2
  return total

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


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

def check_monthnum(monthname1):
  if monthname1 == "February":
    return True
  else:
    return False

FUNC_DEF IF VAR STRING RETURN NUMBER RETURN NUMBER


Write a function that matches a word at the end of a string, with optional punctuation.

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

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


Write a python function to count the number of substrings with same first and last 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 python function to find the maximum occuring divisor in an interval.

def find_Divisor(x,y):
    if (x==y):
        return y
    return 2

FUNC_DEF IF VAR VAR RETURN VAR RETURN NUMBER


Write a python function to find the sum of the three lowest positive numbers from a given list of numbers.

def sum_three_smallest_nums(lst):
	return sum(sorted([x for x in lst if x > 0])[:3])

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


Write a function to convert the given set into ordered tuples.

def set_to_tuple(s):
  t = tuple(sorted(s))
  return (t)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to find the smallest range that includes at-least one element from each of the given arrays.

from heapq import heappop, heappush
class Node:
    def __init__(self, value, list_num, index):
        self.value = value
        self.list_num = list_num
        self.index = index
    def __lt__(self, other):
        return self.value < other.value
def find_minimum_range(list):
    high = float('-inf')
    p = (0, float('inf'))
    pq = []
    for i in range(len(list)):
        heappush(pq, Node(list[i][0], i, 0))
        high = max(high, list[i][0])
    while True:
        top = heappop(pq)
        low = top.value
        i = top.list_num
        j = top.index
        if high - low < p[1] - p[0]:
            p = (low, high)
        if j == len(list[i]) - 1:
            return p
        heappush(pq, Node(list[i][j + 1], i, j + 1))
        high = max(high, list[i][j + 1])

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


Write a function to calculate the number of digits and letters in a string.

def dig_let(s):
 d=l=0
 for c in s:
    if c.isdigit():
        d=d+1
    elif c.isalpha():
        l=l+1
    else:
        pass
 return (l,d)

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


Write a python function to find number of elements with odd factors in a given range.

def count_Odd_Squares(n,m):
    return int(m**0.5) - int((n-1)**0.5)

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


Write a function to find the difference between two consecutive numbers in a given list.

def diff_consecutivenums(nums):
    result = [b-a for a, b in zip(nums[:-1], nums[1:])]
    return result

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


Write a function to find entringer number e(n, k).

def zigzag(n, k):
	if (n == 0 and k == 0):
		return 1
	if (k == 0):
		return 0
	return zigzag(n, k - 1) + zigzag(n - 1, n - k)

FUNC_DEF IF VAR NUMBER VAR NUMBER RETURN NUMBER IF VAR NUMBER RETURN NUMBER RETURN BIN_OP FUNC_CALL VAR VAR BIN_OP VAR NUMBER FUNC_CALL VAR BIN_OP VAR NUMBER BIN_OP 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 n * (n + 1) * (3 * m - n + 1) // 6

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


Write a function to count sequences of given length having non-negative prefix sums that can be generated by given values.

def bin_coff(n, r):
	val = 1
	if (r > (n - r)):
		r = (n - r)
	for i in range(0, r):
		val *= (n - i)
		val //= (i + 1)
	return val
def find_ways(M):
	n = M // 2
	a = bin_coff(2 * n, n)
	b = a // (n + 1)
	return (b)

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


Write a python function to check whether the given string is a binary string or not.

def check(string) :
    p = set(string)
    s = {'0', '1'}
    if s == p or p == {'0'} or p == {'1'}:
        return ("Yes")
    else :
        return ("No")

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


Write a python function to minimize the length of the string by removing occurrence of only one character.

def minimum_Length(s) :
    maxOcc = 0
    n = len(s)
    arr = [0]*26
    for i in range(n) :
        arr[ord(s[i]) -ord('a')] += 1
    for i in range(26) :
        if arr[i] > maxOcc :
            maxOcc = arr[i]
    return n - maxOcc

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


Write a python function to find the first element occurring k times in a given array.

def first_Element(arr,n,k):
    count_map = {};
    for i in range(0, n):
        if(arr[i] in count_map.keys()):
            count_map[arr[i]] += 1
        else:
            count_map[arr[i]] = 1
        i += 1
    for i in range(0, n):
        if (count_map[arr[i]] == k):
            return arr[i]
        i += 1
    return -1

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


Write a python function to check whether all the characters in a given string are unique.

def unique_Characters(str):
    for i in range(len(str)):
        for j in range(i + 1,len(str)):
            if (str[i] == str[j]):
                return False;
    return True;

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


Write a function to remove a specified column from a given nested list.

def remove_column(list1, n):
   for i in list1:
    del i[n]
   return list1


Write a function to find t-nth term of arithemetic progression.

def tn_ap(a,n,d):
  tn = a + (n - 1) * d
  return tn

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


Write a python function to count the number of rectangles in a circle of radius r.

def count_Rectangles(radius):
    rectangles = 0
    diameter = 2 * radius
    diameterSquare = diameter * diameter
    for a in range(1, 2 * radius):
        for b in range(1, 2 * radius):
            diagnalLengthSquare = (a * a +  b * b)
            if (diagnalLengthSquare <= diameterSquare) :
                rectangles += 1
    return rectangles

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


Write a function to find the third angle of a triangle using two angles.

def find_angle(a,b):
 c = 180 - (a + b)
 return c

FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR RETURN VAR


Write a function to find the maximum element of all the given tuple records.

def find_max(test_list):
  res = max(int(j) for i in test_list for j in i)
  return (res)

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


Write a function to find modulo division of two lists using map and lambda function.

def moddiv_list(nums1,nums2):
  result = map(lambda x, y: x % y, nums1, nums2)
  return list(result)

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


Write a python function to check whether one root of the quadratic equation is twice of the other or not.

def Check_Solution(a,b,c):
    if (2*b*b == 9*a*c):
        return ("Yes");
    else:
        return ("No");

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


Write a function to find the n’th carol number.

def get_carol(n):
	result = (2**n) - 1
	return result * result - 2

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


Write a function to remove empty lists from a given list of lists.

def remove_empty(list1):
  remove_empty = [x for x in list1 if x]
  return remove_empty

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR RETURN VAR


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

def max_occurrences(nums):
    max_val = 0
    result = nums[0]
    for i in nums:
        occu = nums.count(i)
        if occu > max_val:
            max_val = occu
            result = i
    return result

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


Write a function to add the k elements to each element in the tuple.

def add_K_element(test_list, K):
  res = [tuple(j + K for j in sub ) for sub in test_list]
  return (res)

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


Write a function to find the number of flips required to make the given binary string a sequence of alternate characters.

def make_flip(ch):
	return '1' if (ch == '0') else '0'
def get_flip_with_starting_charcter(str, expected):
	flip_count = 0
	for i in range(len( str)):
		if (str[i] != expected):
			flip_count += 1
		expected = make_flip(expected)
	return flip_count
def min_flip_to_make_string_alternate(str):
	return min(get_flip_with_starting_charcter(str, '0'),get_flip_with_starting_charcter(str, '1'))

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


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

def count_Digit(n):
    count = 0
    while n != 0:
        n //= 10
        count += 1
    return count

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


Write a python function to find the largest product of the pair of adjacent elements from a given list of integers.

def adjacent_num_product(list_nums):
    return max(a*b for a, b in zip(list_nums, list_nums[1:]))

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


Write a function to check if a binary tree is balanced or not.

class Node:
	def __init__(self, data):
		self.data = data
		self.left = None
		self.right = None
def get_height(root):
	if root is None:
		return 0
	return max(get_height(root.left), get_height(root.right)) + 1
def is_tree_balanced(root):
	if root is None:
		return True
	lh = get_height(root.left)
	rh = get_height(root.right)
	if (abs(lh - rh) <= 1) and is_tree_balanced(
	root.left) is True and is_tree_balanced( root.right) is True:
		return True
	return False

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


Write a function to repeat the given tuple n times.

def repeat_tuples(test_tup, N):
  res = ((test_tup, ) * N)
  return (res)

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a function to find the lateral surface area of cuboid

def lateralsurface_cuboid(l,w,h):
  LSA = 2*h*(l+w)
  return LSA

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


Write a function to sort a tuple by its float element.

def float_sort(price):
  float_sort=sorted(price, key=lambda x: float(x[1]), reverse=True)
  return float_sort

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


Write a function to find the smallest missing element in a sorted array.

def smallest_missing(A, left_element, right_element):
    if left_element > right_element:
        return left_element
    mid = left_element + (right_element - left_element) // 2
    if A[mid] == mid:
        return smallest_missing(A, mid + 1, right_element)
    else:
        return smallest_missing(A, left_element, mid - 1)

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


Write a function to sort a given list of elements in ascending order using heap queue algorithm.

import heapq as hq
def heap_assending(nums):
  hq.heapify(nums)
  s_result = [hq.heappop(nums) for i in range(len(nums))]
  return s_result

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


Write a function to find the volume of a cuboid.

def volume_cuboid(l,w,h):
  volume=l*w*h
  return volume

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP VAR VAR VAR RETURN VAR


Write a function to print all permutations of a given string including duplicates.

def permute_string(str):
    if len(str) == 0:
        return ['']
    prev_list = permute_string(str[1:len(str)])
    next_list = []
    for i in range(0,len(prev_list)):
        for j in range(0,len(str)):
            new_str = prev_list[i][0:j]+str[0]+prev_list[i][j:len(str)-1]
            if new_str not in next_list:
                next_list.append(new_str)
    return next_list

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


Write a function to round the given number to the nearest multiple of a specific number.

def round_num(n,m):
    a = (n //m) * m
    b = a + m
    return (b if n - a > b - n else a)

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


Write a function to remove tuple elements that occur more than once and replace the duplicates with some custom value.

def remove_replica(test_tup):
  temp = set()
  res = tuple(ele if ele not in temp and not temp.add(ele)
				else 'MSP' for ele in test_tup)
  return (res)

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


Write a python function to remove all occurrences of a character in a given string.

def remove_Char(s,c) :
    counts = s.count(c)
    s = list(s)
    while counts :
        s.remove(c)
        counts -= 1
    s = '' . join(s)
    return (s)

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


Write a python function to shift last element to first position in the given list.

def move_first(test_list):
  test_list = test_list[-1:] + test_list[:-1]
  return test_list

FUNC_DEF ASSIGN VAR BIN_OP VAR NUMBER VAR NUMBER RETURN VAR


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

def surfacearea_cuboid(l,w,h):
  SA = 2*(l*w + l * h + w * h)
  return SA

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


Write a function to generate a two-dimensional array.

def multi_list(rownum,colnum):
  multi_list = [[0 for col in range(colnum)] for row in range(rownum)]
  for row in range(rownum):
    for col in range(colnum):
        multi_list[row][col]= row*col
  return multi_list

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


Write a function to sort a list of lists by a given index of the inner list.

from operator import itemgetter
def index_on_inner_list(list_data, index_no):
    result = sorted(list_data, key=itemgetter(index_no))
    return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to find the number of rotations in a circularly sorted array.

def find_rotation_count(A):
    (left, right) = (0, len(A) - 1)
    while left <= right:
        if A[left] <= A[right]:
            return left
        mid = (left + right) // 2
        next = (mid + 1) % len(A)
        prev = (mid - 1 + len(A)) % len(A)
        if A[mid] <= A[next] and A[mid] <= A[prev]:
            return mid
        elif A[mid] <= A[right]:
            right = mid - 1
        elif A[mid] >= A[left]:
            left = mid + 1
    return -1

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


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

def even_bit_toggle_number(n) :
    res = 0; count = 0; temp = n
    while(temp > 0 ) :
        if (count % 2 == 0) :
            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 python function to find the frequency of the smallest value in a given array.

def frequency_Of_Smallest(n,arr):
    mn = arr[0]
    freq = 1
    for i in range(1,n):
        if (arr[i] < mn):
            mn = arr[i]
            freq = 1
        elif (arr[i] == mn):
            freq += 1
    return freq

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


Write a function to find the n'th perrin number using recursion.

def get_perrin(n):
  if (n == 0):
    return 3
  if (n == 1):
    return 0
  if (n == 2):
    return 2
  return get_perrin(n - 2) + get_perrin(n - 3)

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


Write a function to find out the minimum no of swaps required for bracket balancing in the given string.

def swap_count(s):
	chars = s
	count_left = 0
	count_right = 0
	swap = 0
	imbalance = 0;
	for i in range(len(chars)):
		if chars[i] == '[':
			count_left += 1
			if imbalance > 0:
				swap += imbalance
				imbalance -= 1
		elif chars[i] == ']':
			count_right += 1
			imbalance = (count_right - count_left)
	return swap

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


Write a python function to check whether the hexadecimal number is even or odd.

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


Write a python function to find the highest power of 2 that is less than or equal to n.

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 the n'th lucas number.

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

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


Write a function to insert a given string at the beginning of all items in a list.

def add_string(list,string):
 add_string=[string.format(i) for i in  list]
 return add_string

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR


Write a function to convert more than one list to nested dictionary.

def convert_list_dictionary(l1, l2, l3):
     result = [{x: {y: z}} for (x, y, z) in zip(l1, l2, l3)]
     return result

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


Write a function to find the maximum sum possible by using the given equation f(n) = max( (f(n/2) + f(n/3) + f(n/4) + f(n/5)), n).

def get_max_sum (n):
	res = list()
	res.append(0)
	res.append(1)
	i = 2
	while i<n + 1:
		res.append(max(i, (res[int(i / 2)]
						+ res[int(i / 3)] +
							res[int(i / 4)]
						+ res[int(i / 5)])))
		i = i + 1
	return res[n]

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


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

def max_length_list(input_list):
    max_length = max(len(x) for x in input_list )
    max_list = max(input_list, key = lambda i: len(i))
    return(max_length, max_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 check if given tuple is distinct or not.

def check_distinct(test_tup):
  res = True
  temp = set()
  for ele in test_tup:
    if ele in temp:
      res = False
      break
    temp.add(ele)
  return (res)

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


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

def first_non_repeating_character(str1):
  char_order = []
  ctr = {}
  for c in str1:
    if c in ctr:
      ctr[c] += 1
    else:
      ctr[c] = 1
      char_order.append(c)
  for c in char_order:
    if ctr[c] == 1:
      return c
  return None

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


Write a function to check whether the given string starts and ends with the same character or not using regex.

import re
regex = r'^[a-z]$|^([a-z]).*\1$'
def check_char(string):
	if(re.search(regex, string)):
		return "Valid"
	else:
		return "Invalid"

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


Write a function to find the median of three specific numbers.

def median_numbers(a,b,c):
 if a > b:
    if a < c:
        median = a
    elif b > c:
        median = b
    else:
        median = c
 else:
    if a > c:
        median = a
    elif b < c:
        median = b
    else:
        median = c
 return median

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


Write a function to compute the sum of digits of each number of a given list.

def sum_of_digits(nums):
    return sum(int(el) for n in nums for el in str(n) if el.isdigit())

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


Write a function to perform the mathematical bitwise xor operation across the given tuples.

def bitwise_xor(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 extract the frequency of unique tuples in the given list order irrespective.

def extract_freq(test_list):
  res = len(list(set(tuple(sorted(sub)) for sub in test_list)))
  return (res)

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


Write a function to perform index wise addition of tuple elements in the given two nested tuples.

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

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


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

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

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


Write a function to check if a url is valid or not using regex.

import re
def is_valid_URL(str):
	regex = ("((http|https)://)(www.)?" +
			"[a-zA-Z0-9@:%._\\+~#?&//=]" +
			"{2,256}\\.[a-z]" +
			"{2,6}\\b([-a-zA-Z0-9@:%" +
			"._\\+~#?&//=]*)")
	p = re.compile(regex)
	if (str == None):
		return False
	if(re.search(p, str)):
		return True
	else:
		return False

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


Write a python function to find the minimum of two numbers.

def minimum(a,b):
    if a <= b:
        return a
    else:
        return b

FUNC_DEF IF VAR VAR RETURN VAR RETURN VAR


Write a function to check whether an element exists within a tuple.

def check_tuplex(tuplex,tuple1):
  if tuple1 in tuplex:
    return True
  else:
     return False

FUNC_DEF IF VAR VAR RETURN NUMBER RETURN NUMBER


Write a python function to find the parity of a given number.

def find_Parity(x):
    y = x ^ (x >> 1);
    y = y ^ (y >> 2);
    y = y ^ (y >> 4);
    y = y ^ (y >> 8);
    y = y ^ (y >> 16);
    if (y & 1):
        return ("Odd Parity");
    return ("Even Parity");

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


Write a function to create the next bigger number by rearranging the digits of a given number.

def rearrange_bigger(n):
    nums = list(str(n))
    for i in range(len(nums)-2,-1,-1):
        if nums[i] < nums[i+1]:
            z = nums[i:]
            y = min(filter(lambda x: x > z[0], z))
            z.remove(y)
            z.sort()
            nums[i:] = [y] + z
            return int("".join(nums))
    return False

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


Write a function to find k number of pairs which consist of one element from the first array and one element from the second array.

import heapq
def k_smallest_pairs(nums1, nums2, k):
   queue = []
   def push(i, j):
       if i < len(nums1) and j < len(nums2):
           heapq.heappush(queue, [nums1[i] + nums2[j], i, j])
   push(0, 0)
   pairs = []
   while queue and len(pairs) < k:
       _, i, j = heapq.heappop(queue)
       pairs.append([nums1[i], nums2[j]])
       push(i, j + 1)
       if j == 0:
           push(i + 1, 0)
   return pairs

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


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

def min_product_tuple(list1):
    result_min = min([abs(x * y) for x, y in list1] )
    return result_min

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 minimum value in a given heterogeneous list.

def min_val(listval):
     min_val = min(i for i in listval if isinstance(i, int))
     return min_val

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


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

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

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


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

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

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


Write a function to extract the nth element from a given list of tuples.

def extract_nth_element(list1, n):
    result = [x[n] for x in list1]
    return result

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR RETURN VAR


Write a python function to check whether the value exists in a sequence or not.

def overlapping(list1,list2):
    c=0
    d=0
    for i in list1:
        c+=1
    for i in list2:
        d+=1
    for i in range(0,c):
        for j in range(0,d):
            if(list1[i]==list2[j]):
                return 1
    return 0

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


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

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

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


Write a function to find the maximum sum we can make by dividing number in three parts recursively and summing them up together for the given number.

MAX = 1000000
def breakSum(n):
	dp = [0]*(n+1)
	dp[0] = 0
	dp[1] = 1
	for i in range(2, n+1):
		dp[i] = max(dp[int(i/2)] + dp[int(i/3)] + dp[int(i/4)], i);
	return dp[n]

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


Write a function to find common first element in given list of tuple.

def group_tuples(Input):
	out = {}
	for elem in Input:
		try:
			out[elem[0]].extend(elem[1:])
		except KeyError:
			out[elem[0]] = list(elem)
	return [tuple(values) for values in out.values()]

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


Write a python function to find the sublist having maximum length.

def Find_Max(lst):
    maxList = max((x) for x in lst)
    return maxList

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR


Write a function to round every number of a given list of numbers and print the total sum multiplied by the length of the list.

def round_and_sum(list1):
  lenght=len(list1)
  round_and_sum=sum(list(map(round,list1))* lenght)
  return round_and_sum

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


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

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

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


Write a function to concatenate each element of tuple by the delimiter.

def concatenate_tuple(test_tup):
    delim = "-"
    res = ''.join([str(ele) + delim for ele in test_tup])
    res = res[ : len(res) - len(delim)]
    return (str(res))

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


Write a python function to find the average of cubes of first n natural numbers.

def find_Average_Of_Cube(n):
    sum = 0
    for i in range(1, n + 1):
        sum += i * i * i
    return round(sum / n, 6)

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


Write a function to solve gold mine problem.

def get_maxgold(gold, m, n):
    goldTable = [[0 for i in range(n)]
                        for j in range(m)]
    for col in range(n-1, -1, -1):
        for row in range(m):
            if (col == n-1):
                right = 0
            else:
                right = goldTable[row][col+1]
            if (row == 0 or col == n-1):
                right_up = 0
            else:
                right_up = goldTable[row-1][col+1]
            if (row == m-1 or col == n-1):
                right_down = 0
            else:
                right_down = goldTable[row+1][col+1]
            goldTable[row][col] = gold[row][col] + max(right, right_up, right_down)
    res = goldTable[0][0]
    for i in range(1, m):
        res = max(res, goldTable[i][0])
    return res

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


Write a function to extract only the rear index element of each string in the given tuple.

def extract_rear(test_tuple):
  res = list(sub[len(sub) - 1] for sub in test_tuple)
  return (res)

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


Write a function to count the number of sublists containing a particular element.

def count_element_in_list(list1, x):
    ctr = 0
    for i in range(len(list1)):
        if x in list1[i]:
            ctr+= 1
    return ctr

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


Write a function to filter odd numbers using lambda function.

def filter_oddnumbers(nums):
 odd_nums = list(filter(lambda x: x%2 != 0, nums))
 return odd_nums

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


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

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


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

def shell_sort(my_list):
    gap = len(my_list) // 2
    while gap > 0:
        for i in range(gap, len(my_list)):
            current_item = my_list[i]
            j = i
            while j >= gap and my_list[j - gap] > current_item:
                my_list[j] = my_list[j - gap]
                j -= gap
            my_list[j] = current_item
        gap //= 2

    return my_list

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


Write a function to extract the elementwise and tuples from the given two tuples.

def and_tuples(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 directrix of a parabola.

def parabola_directrix(a, b, c):
  directrix=((int)(c - ((b * b) + 1) * 4 * a ))
  return directrix

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


Write a function that takes two lists and returns true if they have at least one common element.

def common_element(list1, list2):
     result = False
     for x in list1:
         for y in list2:
             if x == y:
                 result = True
                 return result

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


Write a function to find the median of a trapezium.

def median_trapezium(base1,base2,height):
 median = 0.5 * (base1+ base2)
 return median

FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR RETURN VAR


Write a function to check whether the entered number is greater than the elements of the given array.

def check_greater(arr, number):
  arr.sort()
  if number > arr[-1]:
    return ('Yes, the entered number is greater than those in the array')
  else:
    return ('No, entered number is less than those in the array')

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


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

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

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


Write a python function to find the last digit of a given number.


Write a python function to print negative numbers in a list.

def neg_nos(list1):
  for num in list1:
    if num < 0:
       return num

FUNC_DEF FOR VAR VAR IF VAR NUMBER RETURN VAR


Write a function to remove odd characters in a string.

def remove_odd(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 function to count bidirectional tuple pairs.

def count_bidirectional(test_list):
  res = 0
  for idx in range(0, len(test_list)):
    for iidx in range(idx + 1, len(test_list)):
      if test_list[iidx][0] == test_list[idx][1] and test_list[idx][1] == test_list[iidx][0]:
        res += 1
  return (str(res))

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


Write a function to convert a list of multiple integers into a single integer.

def multiple_to_single(L):
  x = int("".join(map(str, L)))
  return x

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


Write a function to find all adverbs and their positions in a given sentence.

import re
def find_adverb_position(text):
 for m in re.finditer(r"\w+ly", text):
    return (m.start(), m.end(), m.group(0))

IMPORT FUNC_DEF FOR VAR FUNC_CALL VAR STRING VAR RETURN FUNC_CALL VAR FUNC_CALL VAR FUNC_CALL VAR NUMBER


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

def surfacearea_cube(l):
  surfacearea= 6*l*l
  return surfacearea

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR RETURN VAR


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

from array import array
def positive_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 find the largest negative number from the given list.

def largest_neg(list1):
    max = list1[0]
    for x in list1:
        if x < max :
             max = x
    return max

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


Write a function to trim each tuple by k in the given tuple list.

def trim_tuple(test_list, K):
  res = []
  for ele in test_list:
    N = len(ele)
    res.append(tuple(list(ele)[K: N - K]))
  return (str(res))

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


Write a function to perform index wise multiplication of tuple elements in the given two tuples.

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

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


Write a python function to count the occurence of all elements of list in a tuple.

from collections import Counter
def count_Occurrence(tup, lst):
    count = 0
    for item in tup:
        if item in lst:
            count+= 1
    return count

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


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

def cube_nums(nums):
 cube_nums = list(map(lambda x: x ** 3, nums))
 return cube_nums

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


Write a function to calculate the sum of perrin numbers.

def cal_sum(n):
	a = 3
	b = 0
	c = 2
	if (n == 0):
		return 3
	if (n == 1):
		return 3
	if (n == 2):
		return 5
	sum = 5
	while (n > 2):
		d = a + b
		sum = sum + d
		a = b
		b = c
		c = d
		n = n-1
	return sum

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


Write a python function to check whether the triangle is valid or not if 3 points are given.

def check_Triangle(x1,y1,x2,y2,x3,y3):
    a = (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))
    if a == 0:
        return ('No')
    else:
        return ('Yes')

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


Write a function to extract specified size of strings from a give list of string values.

def extract_string(str, l):
    result = [e for e in str if len(e) == l]
    return result

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


Write a function to remove all whitespaces from the given string using regex.

import re
def remove_whitespaces(text1):
  return (re.sub(r'\s+', '',text1))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


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

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

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


Write a python function to find the sum of even factors of a number.

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

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


Write a function that matches a word containing 'z'.

import re
def text_match_wordz(text):
        patterns = '\w*z.\w*'
        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 check whether the given month number contains 31 days or not.

def check_monthnumb_number(monthnum2):
  if(monthnum2==1 or monthnum2==3 or monthnum2==5 or monthnum2==7 or monthnum2==8 or monthnum2==10 or monthnum2==12):
    return True
  else:
    return False

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


Write a function to reverse strings in a given list of string values.

def reverse_string_list(stringlist):
    result = [x[::-1] for x in stringlist]
    return result

FUNC_DEF ASSIGN VAR VAR NUMBER VAR VAR RETURN VAR


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

def Find_Min(lst):
    minList = min((x) for x in lst)
    return minList

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR


Write a function to find the area of a rectangle.

def rectangle_area(l,b):
  area=l*b
  return area

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a function to remove uppercase substrings from a given string by using regex.

import re
def remove_uppercase(str1):
  remove_upper = lambda text: re.sub('[A-Z]', '', text)
  result =  remove_upper(str1)
  return (result)

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


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

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


Write a python function to count the upper case characters in a given string.

def upper_ctr(str):
    upper_ctr = 0
    for i in range(len(str)):
          if str[i] >= 'A' and str[i] <= 'Z': upper_ctr += 1
          return upper_ctr

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


Write a function to find all possible combinations of the elements of a given list.

def combinations_list(list1):
    if len(list1) == 0:
        return [[]]
    result = []
    for el in combinations_list(list1[1:]):
        result += [el, el+[list1[0]]]
    return result

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


Write a function to find the maximum product subarray of the given array.

def max_subarray_product(arr):
	n = len(arr)
	max_ending_here = 1
	min_ending_here = 1
	max_so_far = 0
	flag = 0
	for i in range(0, n):
		if arr[i] > 0:
			max_ending_here = max_ending_here * arr[i]
			min_ending_here = min (min_ending_here * arr[i], 1)
			flag = 1
		elif arr[i] == 0:
			max_ending_here = 1
			min_ending_here = 1
		else:
			temp = max_ending_here
			max_ending_here = max (min_ending_here * arr[i], 1)
			min_ending_here = temp * arr[i]
		if (max_so_far < max_ending_here):
			max_so_far = max_ending_here
	if flag == 0 and max_so_far == 0:
		return 0
	return max_so_far

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


Write a function to check if all values are same in a dictionary.

def check_value(dict, n):
    result = all(x == n for x in dict.values())
    return result

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


Write a function to drop empty items from a given dictionary.

def drop_empty(dict1):
  dict1 = {key:value for (key, value) in dict1.items() if value is not None}
  return dict1

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


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

def find_peak_util(arr, low, high, n):
	mid = low + (high - low)/2
	mid = int(mid)
	if ((mid == 0 or arr[mid - 1] <= arr[mid]) and
		(mid == n - 1 or arr[mid + 1] <= arr[mid])):
		return mid
	elif (mid > 0 and arr[mid - 1] > arr[mid]):
		return find_peak_util(arr, low, (mid - 1), n)
	else:
		return find_peak_util(arr, (mid + 1), high, n)
def find_peak(arr, n):
	return find_peak_util(arr, 0, n - 1, n)

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


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

def decimal_to_Octal(deciNum):
    octalNum = 0
    countval = 1;
    dNo = deciNum;
    while (deciNum!= 0):
        remainder= deciNum % 8;
        octalNum+= remainder*countval;
        countval= countval*10;
        deciNum //= 8;
    return (octalNum)

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


Write a function to find the maximum product formed by multiplying numbers of an increasing subsequence of that array.

def max_product(arr, n ):
	mpis =[0] * (n)
	for i in range(n):
		mpis[i] = arr[i]
	for i in range(1, n):
		for j in range(i):
			if (arr[i] > arr[j] and
					mpis[i] < (mpis[j] * arr[i])):
						mpis[i] = mpis[j] * arr[i]
	return max(mpis)

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


Write a function to find the maximum profit earned from a maximum of k stock transactions

def max_profit(price, k):
    n = len(price)
    final_profit = [[None for x in range(n)] for y in range(k + 1)]
    for i in range(k + 1):
        for j in range(n):
            if i == 0 or j == 0:
                final_profit[i][j] = 0
            else:
                max_so_far = 0
                for x in range(j):
                    curr_price = price[j] - price[x] + final_profit[i-1][x]
                    if max_so_far < curr_price:
                        max_so_far = curr_price
                final_profit[i][j] = max(final_profit[i][j-1], max_so_far)
    return final_profit[k][n-1]

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


Write a function to find the pairwise addition of the elements of the given tuples.

def add_pairwise(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 python function to find remainder of array multiplication divided by n.

def find_remainder(arr, lens, n):
    mul = 1
    for i in range(lens):
        mul = (mul * (arr[i] % n)) % n
    return mul % n

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


Write a python function to check whether the given list contains consecutive numbers or not.

def check_Consecutive(l):
    return sorted(l) == list(range(min(l),max(l)+1))

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


Write a function to find the tuple intersection of elements in the given tuple list irrespective of their order.

def tuple_intersection(test_list1, test_list2):
  res = set([tuple(sorted(ele)) for ele in test_list1]) & set([tuple(sorted(ele)) for ele in test_list2])
  return (res)

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


Write a function to replace characters in a string.

def replace_char(str1,ch,newch):
 str2 = str1.replace(ch, newch)
 return str2

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to sort counter by value.

from collections import Counter
def sort_counter(dict1):
 x = Counter(dict1)
 sort_counter=x.most_common()
 return sort_counter

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


Write a python function to find the sum of the largest and smallest value in a given array.

def big_sum(nums):
      sum= max(nums)+min(nums)
      return sum

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


Write a python function to convert the given string to lower case.

def is_lower(string):
  return (string.lower())


Write a function to remove lowercase substrings from a given string.

import re
def remove_lowercase(str1):
 remove_lower = lambda text: re.sub('[a-z]', '', text)
 result =  remove_lower(str1)
 return result

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


Write a python function to find the first digit of a given number.

def first_Digit(n) :
    while n >= 10:
        n = n / 10;
    return int(n)

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


Write a python function to find the maximum occurring character in a given string.

def get_max_occuring_char(str1):
  ASCII_SIZE = 256
  ctr = [0] * ASCII_SIZE
  max = -1
  ch = ''
  for i in str1:
    ctr[ord(i)]+=1;
  for i in str1:
    if max < ctr[ord(i)]:
      max = ctr[ord(i)]
      ch = i
  return ch

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


Write a function to determine if there is a subset of the given set with sum equal to the given sum.

def is_subset_sum(set, n, sum):
	if (sum == 0):
		return True
	if (n == 0):
		return False
	if (set[n - 1] > sum):
		return is_subset_sum(set, n - 1, sum)
	return is_subset_sum(set, n-1, sum) or is_subset_sum(set, n-1, sum-set[n-1])

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


Write a function to find sequences of one upper case letter followed by lower case letters in the given string by using regex.

import re
def match(text):
		pattern = '[A-Z]+[a-z]+$'
		if re.search(pattern, text):
				return('Yes')
		else:
				return('No')

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


Write a python function to find the first natural number whose factorial is divisible by x.

def first_Factorial_Divisible_Number(x):
    i = 1;
    fact = 1;
    for i in range(1,x):
        fact = fact * i
        if (fact % x == 0):
            break
    return i

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


Write a function to remove the matching tuples from the given two tuples.

def remove_matching_tuple(test_list1, test_list2):
  res = [sub for sub in test_list1 if sub not in test_list2]
  return (res)

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR RETURN VAR


Write a function to find the largest palindromic number in the given array.

def is_palindrome(n) :
	divisor = 1
	while (n / divisor >= 10) :
		divisor *= 10
	while (n != 0) :
		leading = n // divisor
		trailing = n % 10
		if (leading != trailing) :
			return False
		n = (n % divisor) // 10
		divisor = divisor // 100
	return True
def largest_palindrome(A, n) :
	A.sort()
	for i in range(n - 1, -1, -1) :
		if (is_palindrome(A[i])) :
			return A[i]
	return -1

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


Write a function to compute binomial probability for the given number.

def nCr(n, r):
	if (r > n / 2):
		r = n - r
	answer = 1
	for i in range(1, r + 1):
		answer *= (n - r + i)
		answer /= i
	return answer
def binomial_probability(n, k, p):
	return (nCr(n, k) * pow(p, k) *	pow(1 - p, n - k))

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


Write a function to sort a list of tuples in increasing order by the last element in each tuple.

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

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


Write a function to find the area of a pentagon.

import math
def area_pentagon(a):
  area=(math.sqrt(5*(5+2*math.sqrt(5)))*pow(a,2))/4.0
  return area

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


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

def frequency_Of_Largest(n,arr):
    mn = arr[0]
    freq = 1
    for i in range(1,n):
        if (arr[i] >mn):
            mn = arr[i]
            freq = 1
        elif (arr[i] == mn):
            freq += 1
    return freq

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


Write a function to extract all the pairs which are symmetric in the given tuple list.

def extract_symmetric(test_list):
  temp = set(test_list) & {(b, a) for a, b in test_list}
  res = {(a, b) for a, b in temp if a < b}
  return (res)

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


Write a function to find the sum of geometric progression series.

import math
def sum_gp(a,n,r):
 total = (a * (1 - math.pow(r, n ))) / (1- r)
 return total

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


Write a function to search an element in the given array by using binary search.

def binary_search(item_list,item):
	first = 0
	last = len(item_list)-1
	found = False
	while( first<=last and not found):
		mid = (first + last)//2
		if item_list[mid] == item :
			found = True
		else:
			if item < item_list[mid]:
				last = mid - 1
			else:
				first = mid + 1
	return found

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