Write a function to calculate a grid of hexagon coordinates where function returns a list of lists containing 6 tuples of x, y point coordinates.

import math
def calculate_polygons(startx, starty, endx, endy, radius):
    sl = (2 * radius) * math.tan(math.pi / 6)
    p = sl * 0.5
    b = sl * math.cos(math.radians(30))
    w = b * 2
    h = 2 * sl
    startx = startx - w
    starty = starty - h
    endx = endx + w
    endy = endy + h
    origx = startx
    origy = starty
    xoffset = b
    yoffset = 3 * p
    polygons = []
    row = 1
    counter = 0
    while starty < endy:
        if row % 2 == 0:
            startx = origx + xoffset
        else:
            startx = origx
        while startx < endx:
            p1x = startx
            p1y = starty + p
            p2x = startx
            p2y = starty + (3 * p)
            p3x = startx + b
            p3y = starty + h
            p4x = startx + w
            p4y = starty + (3 * p)
            p5x = startx + w
            p5y = starty + p
            p6x = startx + b
            p6y = starty
            poly = [
                (p1x, p1y),
                (p2x, p2y),
                (p3x, p3y),
                (p4x, p4y),
                (p5x, p5y),
                (p6x, p6y),
                (p1x, p1y)]
            polygons.append(poly)
            counter += 1
            startx += w
        starty += yoffset
        row += 1
    return polygons

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


Write a function to convert the given binary tuple to integer.

def binary_to_integer(test_tup):
  res = int("".join(str(ele) for ele in test_tup), 2)
  return (str(res))

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


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

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 function to find the smallest integers from a given list of numbers using heap queue algorithm.

import heapq as hq
def heap_queue_smallest(nums,n):
  smallest_nums = hq.nsmallest(n, nums)
  return smallest_nums

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


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

import math
def surfacearea_cone(r,h):
  l = math.sqrt(r * r + h * h)
  SA = math.pi * r * (r + l)
  return SA

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


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

def gcd(x, y):
    gcd = 1
    if x % y == 0:
        return y
    for k in range(int(y / 2), 0, -1):
        if x % k == 0 and y % k == 0:
            gcd = k
            break
    return gcd

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


Write a function to find the diameter of a circle.

def diameter_circle(r):
  diameter=2*r
  return diameter

FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN VAR


Write a function to concatenate all elements of the given list into a string.

def concatenate_elements(list):
  ans = ' '
  for i in list:
    ans = ans+ ' '+i
  return (ans)

FUNC_DEF ASSIGN VAR STRING FOR VAR VAR ASSIGN VAR BIN_OP BIN_OP VAR STRING VAR RETURN VAR


Write a python function to find common divisor between two numbers in a given pair.

def ngcd(x,y):
    i=1
    while(i<=x and i<=y):
        if(x%i==0 and y%i == 0):
            gcd=i;
        i+=1
    return gcd;
def num_comm_div(x,y):
  n = ngcd(x,y)
  result = 0
  z = int(n**0.5)
  i = 1
  while(i <= z):
    if(n % i == 0):
      result += 2
      if(i == n/i):
        result-=1
    i+=1
  return result

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


Write a python function to find remainder of two numbers.

FUNC_DEF ASSIGN VAR BIN_OP VAR VAR RETURN VAR


Write a function to add consecutive numbers of a given list.

def add_consecutive_nums(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 python function to find the cube sum of first n natural numbers.

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

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


Write a function to move all zeroes to the end of the given array.

def re_order(A):
    k = 0
    for i in A:
        if i:
            A[k] = i
            k = k + 1
    for i in range(k, len(A)):
        A[i] = 0
    return A

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


Write a function to calculate the permutation coefficient of given p(n, k).

def permutation_coefficient(n, k):
	P = [[0 for i in range(k + 1)]
			for j in range(n + 1)]
	for i in range(n + 1):
		for j in range(min(i, k) + 1):
			if (j == 0):
				P[i][j] = 1
			else:
				P[i][j] = P[i - 1][j] + (
						j * P[i - 1][j - 1])
			if (j < k):
				P[i][j + 1] = 0
	return P[n][k]

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


Write a function to remove specific words from a given list.

def remove_words(list1, removewords):
    for word in list(list1):
        if word in removewords:
            list1.remove(word)
    return list1

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


Write a function to check if the common elements between two given lists are in the same order or not.

def same_order(l1, l2):
    common_elements = set(l1) & set(l2)
    l1 = [e for e in l1 if e in common_elements]
    l2 = [e for e in l2 if e in common_elements]
    return l1 == l2

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


Write a python function to find the average of odd numbers till a given odd number.

def average_Odd(n) :
    if (n%2==0) :
        return ("Invalid Input")
        return -1
    sm =0
    count =0
    while (n>=1) :
        count=count+1
        sm = sm + n
        n = n-2
    return sm//count

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


Write a function to find the number of subsequences having product smaller than k for the given non negative array.

def no_of_subsequences(arr, k):
	n = len(arr)
	dp = [[0 for i in range(n + 1)]
			for j in range(k + 1)]
	for i in range(1, k + 1):
		for j in range(1, n + 1):
			dp[i][j] = dp[i][j - 1]
			if arr[j - 1] <= i and arr[j - 1] > 0:
				dp[i][j] += dp[i // arr[j - 1]][j - 1] + 1
	return dp[k][n]

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


Write a python function to find minimum sum of factors of a given number.

def find_Min_Sum(num):
    sum = 0
    i = 2
    while(i * i <= num):
        while(num % i == 0):
            sum += i
            num /= i
        i += 1
    sum += num
    return sum

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


Write a function to count the element frequency in the mixed nested tuple.

def flatten(test_tuple):
	for tup in test_tuple:
		if isinstance(tup, tuple):
			yield from flatten(tup)
		else:
			yield tup
def count_element_freq(test_tuple):
  res = {}
  for ele in flatten(test_tuple):
    if ele not in res:
      res[ele] = 0
    res[ele] += 1
  return (res)

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


Write a function to convert tuple into list by adding the given string after every element.

def add_str(test_tup, K):
  res = [ele for sub in test_tup for ele in (sub, K)]
  return (res)

FUNC_DEF ASSIGN VAR VAR VAR VAR VAR VAR VAR RETURN VAR


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

def sum_elements(test_tup):
  res = sum(list(test_tup))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR RETURN VAR


Write a function to check if there is a subset with sum divisible by m.

def modular_sum(arr, n, m):
	if (n > m):
		return True
	DP = [False for i in range(m)]
	for i in range(n):
		if (DP[0]):
			return True
		temp = [False for i in range(m)]
		for j in range(m):
			if (DP[j] == True):
				if (DP[(j + arr[i]) % m] == False):
					temp[(j + arr[i]) % m] = True
		for j in range(m):
			if (temp[j]):
				DP[j] = True
		DP[arr[i] % m] = True
	return DP[0]

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


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

def radix_sort(nums):
    RADIX = 10
    placement = 1
    max_digit = max(nums)

    while placement < max_digit:
      buckets = [list() for _ in range( RADIX )]
      for i in nums:
        tmp = int((i / placement) % RADIX)
        buckets[tmp].append(i)
      a = 0
      for b in range( RADIX ):
        buck = buckets[b]
        for i in buck:
          nums[a] = i
          a += 1
      placement *= RADIX
    return nums

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


Write a python function to find the largest postive number from the given list.

def largest_pos(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 find the square root of a perfect number.

import math
def sqrt_root(num):
 sqrt_root = math.pow(num, 0.5)
 return sqrt_root

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR NUMBER RETURN VAR


Write a function to calculate volume of a tetrahedron.

import math
def volume_tetrahedron(num):
	volume = (num ** 3 / (6 * math.sqrt(2)))
	return round(volume, 2)

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


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

def find_lcm(num1, num2):
	if(num1>num2):
		num = num1
		den = num2
	else:
		num = num2
		den = num1
	rem = num % den
	while (rem != 0):
		num = den
		den = rem
		rem = num % den
	gcd = den
	lcm = int(int(num1 * num2)/int(gcd))
	return lcm
def get_lcm(l):
  num1 = l[0]
  num2 = l[1]
  lcm = find_lcm(num1, num2)
  for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])
  return lcm

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


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

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

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


Write a function to find the longest bitonic subsequence for the given array.

def lbs(arr):
	n = len(arr)
	lis = [1 for i in range(n+1)]
	for i in range(1 , n):
		for j in range(0 , i):
			if ((arr[i] > arr[j]) and (lis[i] < lis[j] +1)):
				lis[i] = lis[j] + 1
	lds = [1 for i in range(n+1)]
	for i in reversed(range(n-1)):
		for j in reversed(range(i-1 ,n)):
			if(arr[i] > arr[j] and lds[i] < lds[j] + 1):
				lds[i] = lds[j] + 1
	maximum = lis[0] + lds[0] - 1
	for i in range(1 , n):
		maximum = max((lis[i] + lds[i]-1), maximum)
	return maximum

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


Write a function to check whether a given string has a capital letter, a lower case letter, a number and specified length using lambda function.

def check_string(str1):
    messg = [
    lambda str1: any(x.isupper() for x in str1) or 'String must have 1 upper case character.',
    lambda str1: any(x.islower() for x in str1) or 'String must have 1 lower case character.',
    lambda str1: any(x.isdigit() for x in str1) or 'String must have 1 number.',
    lambda str1: len(str1) >= 7                 or 'String length should be atleast 8.',]
    result = [x for x in [i(str1) for i in messg] if x != True]
    if not result:
        result.append('Valid string.')
    return result

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


Write a function to find the sum of maximum increasing subsequence of the given array.

def max_sum_increasing_subsequence(arr, n):
	max = 0
	msis = [0 for x in range(n)]
	for i in range(n):
		msis[i] = arr[i]
	for i in range(1, n):
		for j in range(i):
			if (arr[i] > arr[j] and
				msis[i] < msis[j] + arr[i]):
				msis[i] = msis[j] + arr[i]
	for i in range(n):
		if max < msis[i]:
			max = msis[i]
	return max

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


Write a python function to check whether two given lines are parallel or not.

def parallel_lines(line1, line2):
  return line1[0]/line1[1] == line2[0]/line2[1]

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


Write a python function to capitalize first and last letters of each word of a given string.

def capitalize_first_last_letters(str1):
     str1 = result = str1.title()
     result =  ""
     for word in str1.split():
        result += word[:-1] + word[-1].upper() + " "
     return result[:-1]

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


Write a function to find all pairs in an integer array whose sum is equal to a given number.

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

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


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

def min_length(list1):
   min_length = min(len(x) for x in  list1 )
   min_list = min((x) for x in   list1)
   return(min_length, min_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 the nth jacobsthal-lucas number.

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

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


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

from array import array
def negative_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 function to find minimum number of coins that make a given value.

import sys
def min_coins(coins, m, V):
    if (V == 0):
        return 0
    res = sys.maxsize
    for i in range(0, m):
        if (coins[i] <= V):
            sub_res = min_coins(coins, m, V-coins[i])
            if (sub_res != sys.maxsize and sub_res + 1 < res):
                res = sub_res + 1
    return res

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


Write a function to check if the two given strings are permutations of each other.

def check_permutation(str1, str2):
  n1=len(str1)
  n2=len(str2)
  if(n1!=n2):
    return False
  a=sorted(str1)
  str1=" ".join(a)
  b=sorted(str2)
  str2=" ".join(b)
  for i in range(0, n1, 1):
    if(str1[i] != str2[i]):
      return False
  return True

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


Write a function to remove particular data type elements from the given tuple.

def remove_datatype(test_tuple, data_type):
  res = []
  for ele in test_tuple:
    if not isinstance(ele, data_type):
      res.append(ele)
  return (res)

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


Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs.

import re
def search_literal(pattern,text):
 match = re.search(pattern, text)
 s = match.start()
 e = match.end()
 return (s, e)

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


Write a function to find the top or bottom surface area of a cylinder.

def topbottom_surfacearea(r):
  toporbottomarea=3.1415*r*r
  return toporbottomarea

FUNC_DEF ASSIGN VAR BIN_OP BIN_OP NUMBER VAR VAR RETURN VAR


Write a function to select the nth items of a list.

def nth_items(list,n):
 return list[::n]


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

def first_repeated_word(str1):
  temp = set()
  for word in str1.split():
    if word in temp:
      return word;
    else:
      temp.add(word)
  return 'None'

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


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

def string_list_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 function to create a list containing the power of said number in bases raised to the corresponding number in the index using map function.

def basesnum_coresspondingnum(bases_num,index):
  result = list(map(pow, bases_num, index))
  return result

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


Write a python function to find the difference between highest and least frequencies in a given array.

def find_Diff(arr,n):
    arr.sort()
    count = 0; max_count = 0; min_count = n
    for i in range(0,(n-1)):
        if arr[i] == arr[i + 1]:
            count += 1
            continue
        else:
            max_count = max(max_count,count)
            min_count = min(min_count,count)
            count = 0
    return max_count - min_count

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


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

import math
def get_sum(n):
	sum = 0
	i = 1
	while i <= (math.sqrt(n)):
		if n%i == 0:
			if n/i == i :
				sum = sum + i
			else:
				sum = sum + i
				sum = sum + (n / i )
		i = i + 1
	sum = sum - n
	return sum
def check_abundant(n):
	if (get_sum(n) > n):
		return True
	else:
		return False

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


Write a function to replace all occurrences of spaces, commas, or dots with a colon in the given string by using regex.

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

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


Write a function to add two numbers and print number of digits of sum.

def count_digits(num1,num2):
    number=num1+num2
    count = 0
    while(number > 0):
        number = number // 10
        count = count + 1
    return count

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


Write a function to flatten the tuple list to a string.

def flatten_tuple(test_list):
  res = ' '.join([idx for tup in test_list for idx in tup])
  return (res)

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


Write a python function to toggle only first and last bits of a given number.

def take_L_and_F_set_bits(n) :
    n = n | n >> 1
    n = n | n >> 2
    n = n | n >> 4
    n = n | n >> 8
    n = n | n >> 16
    return ((n + 1) >> 1) + 1
def toggle_F_and_L_bits(n) :
    if (n == 1) :
        return 0
    return n ^ take_L_and_F_set_bits(n)

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


Write a function to find the last occurrence of a character in a string.

def last_occurence_char(string,char):
 flag = -1
 for i in range(len(string)):
     if(string[i] == char):
         flag = i
 if(flag == -1):
    return None
 else:
    return flag + 1

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


Write a python function to find the sum of hamming distances of all consecutive numbers from o to n.

def Total_Hamming_Distance(n):
    i = 1
    sum = 0
    while (n // i > 0):
        sum = sum + n // i
        i = i * 2
    return sum

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


Write a function to find the length of the longest increasing subsequence of the given sequence.

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

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


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

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

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


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

def find_Max(arr,low,high):
    if (high < low):
        return arr[0]
    if (high == low):
        return arr[low]
    mid = low + (high - low) // 2
    if (mid < high and arr[mid + 1] < arr[mid]):
        return arr[mid]
    if (mid > low and arr[mid] < arr[mid - 1]):
        return arr[mid - 1]
    if (arr[low] > arr[mid]):
        return find_Max(arr,low,mid - 1)
    else:
        return find_Max(arr,mid + 1,high)

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


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

def extract_column(list1, n):
   result = [i.pop(n) for i in list1]
   return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR RETURN VAR


Write a python function to check whether a given sequence is linear or not.

def Seq_Linear(seq_nums):
  seq_nums = [seq_nums[x] - seq_nums[x-1] for x in range(1, len(seq_nums))]
  if len(set(seq_nums)) == 1:
    return "Linear Sequence"
  else:
    return "Non Linear Sequence"

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


Write a function to convert the given tuple to a floating-point number.

def tuple_to_float(test_tup):
  res = float('.'.join(str(ele) for ele in test_tup))
  return (res)

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


Write a python function to find odd numbers from a mixed list.

def Split(list):
    od_li = []
    for i in list:
        if (i % 2 != 0):
            od_li.append(i)
    return od_li

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


Write a python function to find the difference between sum of cubes of first n natural numbers and the sum of first n natural numbers.

def difference(n) :
    S = (n*(n + 1))//2;
    res = S*(S-1);
    return res;

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


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

def find_Odd_Pair(A,N) :
    oddPair = 0
    for i in range(0,N) :
        for j in range(i+1,N) :
            if ((A[i] ^ A[j]) % 2 != 0):
                oddPair+=1
    return oddPair

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


Write a function to toggle characters case in a string.

def toggle_string(string):
 string1 = string.swapcase()
 return string1

FUNC_DEF ASSIGN VAR FUNC_CALL VAR RETURN VAR


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

def digit_distance_nums(n1, n2):
         return sum(map(int,str(abs(n1-n2))))

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


Write a function to find the largest sum of contiguous subarray in the given array.

def max_sub_array_sum(a, size):
  max_so_far = 0
  max_ending_here = 0
  for i in range(0, size):
    max_ending_here = max_ending_here + a[i]
    if max_ending_here < 0:
      max_ending_here = 0
    elif (max_so_far < max_ending_here):
      max_so_far = max_ending_here
  return max_so_far

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


Write a function to find the union of elements of the given tuples.

def union_elements(test_tup1, test_tup2):
  res = tuple(set(test_tup1 + test_tup2))
  return (res)

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


Write a function to assign with each element, its pair elements from other similar pairs in the given tuple.

def assign_elements(test_list):
  res = dict()
  for key, val in test_list:
    res.setdefault(val, [])
    res.setdefault(key, []).append(val)
  return (res)

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


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

def Find_Max_Length(lst):
    maxLength = max(len(x) for x in lst )
    return maxLength

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


Write a function to extract values between quotation marks of a string.

import re
def extract_values(text):
 return (re.findall(r'"(.*?)"', text))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


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

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

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


Write a python function to split a string into characters.

def split(word):
    return [char for char in word]


Write a function to get the sum of a non-negative integer.

def sum_digits(n):
  if n == 0:
    return 0
  else:
    return n % 10 + sum_digits(int(n / 10))

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


Write a function to check whether a specified list is sorted or not.

def issort_list(list1):
    result = all(list1[i] <= list1[i+1] for i in range(len(list1)-1))
    return result

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


Write a function to create a list of empty dictionaries.

def empty_list(length):
 empty_list = [{} for _ in range(length)]
 return empty_list

FUNC_DEF ASSIGN VAR DICT VAR FUNC_CALL VAR VAR RETURN VAR


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

def sort_sublists(list1):
    result = list(map(sorted,list1))
    return result

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to remove words from a given list of strings containing a character or string.

def remove_words(list1, charlist):
    new_list = []
    for line in list1:
        new_words = ' '.join([word for word in line.split() if not any([phrase in word for phrase in charlist])])
        new_list.append(new_words)
    return new_list

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


Write a function to find maximum possible sum of disjoint pairs for the given array of integers and a number k.

def max_sum_pair_diff_lessthan_K(arr, N, K):
	arr.sort()
	dp = [0] * N
	dp[0] = 0
	for i in range(1, N):
		dp[i] = dp[i-1]
		if (arr[i] - arr[i-1] < K):
			if (i >= 2):
				dp[i] = max(dp[i], dp[i-2] + arr[i] + arr[i-1]);
			else:
				dp[i] = max(dp[i], arr[i] + arr[i-1]);
	return dp[N - 1]

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


Write a python function to remove two duplicate numbers from a given number of lists.

def two_unique_nums(nums):
  return [i for i in nums if nums.count(i)==1]

FUNC_DEF RETURN VAR VAR VAR FUNC_CALL VAR VAR NUMBER


Write a python function to calculate the product of the unique numbers of a given list.

def unique_product(list_data):
    temp = list(set(list_data))
    p = 1
    for i in temp:
        p *= i
    return p

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


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

def surfacearea_cylinder(r,h):
  surfacearea=((2*3.1415*r*r) +(2*3.1415*r*h))
  return surfacearea

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


Write a python function to find nth number in a sequence which is not a multiple of a given number.

def count_no (A,N,L,R):
    count = 0
    for i in range (L,R + 1):
        if (i % A != 0):
            count += 1
        if (count == N):
            break
    return (i)

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


Write a python function to check whether an array is subarray of another or not.

def is_Sub_Array(A,B,n,m):
    i = 0; j = 0;
    while (i < n and j < m):
        if (A[i] == B[j]):
            i += 1;
            j += 1;
            if (j == m):
                return True;
        else:
            i = i - j + 1;
            j = 0;
    return False;

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


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

def last_Digit_Factorial(n):
    if (n == 0): return 1
    elif (n <= 2): return n
    elif (n == 3): return 6
    elif (n == 4): return 4
    else:
      return 0

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


Write a function to interleave lists of the same length.

def interleave_lists(list1,list2,list3):
    result = [el for pair in zip(list1, list2, list3) for el in pair]
    return result

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


Write a function to find the dissimilar elements in the given two tuples.

def find_dissimilar(test_tup1, test_tup2):
  res = tuple(set(test_tup1) ^ set(test_tup2))
  return (res)

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


Write a function to extract the even elements in the nested mixed tuple.

def even_ele(test_tuple, even_fnc):
	res = tuple()
	for ele in test_tuple:
		if isinstance(ele, tuple):
			res += (even_ele(ele, even_fnc), )
		elif even_fnc(ele):
			res += (ele, )
	return res
def extract_even(test_tuple):
  res = even_ele(test_tuple, lambda x: x % 2 == 0)
  return (res)

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


Write a python function to find the surface area of the square pyramid.

def surface_Area(b,s):
    return 2 * b * s + pow(b,2)

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


Write a function to check if a dictionary is empty or not.

def my_dict(dict1):
  if bool(dict1):
     return False
  else:
     return True

FUNC_DEF IF FUNC_CALL VAR VAR RETURN NUMBER RETURN NUMBER


Write a function for nth catalan number.

def catalan_number(num):
    if num <=1:
         return 1
    res_num = 0
    for i in range(num):
        res_num += catalan_number(i) * catalan_number(num-i-1)
    return res_num

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


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

import re
def find_adverbs(text):
  for m in re.finditer(r"\w+ly", text):
    return ('%d-%d: %s' % (m.start(), m.end(), m.group(0)))

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


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

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

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


Write a python function to split the array and add the first part to the end.

def split_Arr(a,n,k):
   b = a[:k]
   return (a[k::]+b[::])

FUNC_DEF ASSIGN VAR VAR VAR RETURN BIN_OP VAR VAR VAR


Write a function to convert a list to a tuple.

def list_tuple(listx):
  tuplex = tuple(listx)
  return tuplex

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR RETURN VAR


Write a python function to find the difference between largest and smallest value in a given array.

def big_diff(nums):
     diff= max(nums)-min(nums)
     return diff

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


Write a function to find perfect squares between two given numbers.

def perfect_squares(a, b):
    lists=[]
    for i in range (a,b+1):
        j = 1;
        while j*j <= i:
            if j*j == i:
                 lists.append(i)
            j = j+1
        i = i+1
    return lists

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


Write a function to convert polar coordinates to rectangular coordinates.

import cmath
def polar_rect(x,y):
 cn = complex(x,y)
 cn=cmath.polar(cn)
 cn1 = cmath.rect(2, cmath.pi)
 return (cn,cn1)

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


Write a python function to interchange the first and last elements in a list.

def swap_List(newList):
    size = len(newList)
    temp = newList[0]
    newList[0] = newList[size - 1]
    newList[size - 1] = temp
    return newList

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


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

def binomial_Coeff(n,k):
    C = [0] * (k + 1);
    C[0] = 1; # nC0 is 1
    for i in range(1,n + 1):
        for j in range(min(i, k),0,-1):
            C[j] = C[j] + C[j - 1];
    return C[k];
def sum_Of_product(n):
    return binomial_Coeff(2 * n,n - 1);

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


Write a function to remove leading zeroes from an ip address.

import re
def removezero_ip(ip):
 string = re.sub('\.[0]*', '.', ip)
 return string

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING STRING VAR RETURN VAR


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

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

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


Write a python function to count minimum number of swaps required to convert one binary string to another.

def min_Swaps(str1,str2) :
    count = 0
    for i in range(len(str1)) :
        if str1[i] != str2[i] :
            count += 1
    if count % 2 == 0 :
        return (count // 2)
    else :
        return ("Not Possible")

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


Write a function to find the size of the given tuple.

import sys
def tuple_size(tuple_list):
  return (sys.getsizeof(tuple_list))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR VAR


Write a function to find kth element from the given two sorted arrays.

def find_kth(arr1, arr2, m, n, k):
	sorted1 = [0] * (m + n)
	i = 0
	j = 0
	d = 0
	while (i < m and j < n):
		if (arr1[i] < arr2[j]):
			sorted1[d] = arr1[i]
			i += 1
		else:
			sorted1[d] = arr2[j]
			j += 1
		d += 1
	while (i < m):
		sorted1[d] = arr1[i]
		d += 1
		i += 1
	while (j < n):
		sorted1[d] = arr2[j]
		d += 1
		j += 1
	return sorted1[k - 1]

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


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

def armstrong_number(number):
 sum = 0
 times = 0
 temp = number
 while temp > 0:
           times = times + 1
           temp = temp // 10
 temp = number
 while temp > 0:
           reminder = temp % 10
           sum = sum + (reminder ** times)
           temp //= 10
 if number == sum:
           return True
 else:
           return False

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


Write a function to find sum and average of first n natural numbers.

def sum_average(number):
 total = 0
 for value in range(1, number + 1):
    total = total + value
 average = total / number
 return (total,average)

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


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

def is_Even(n) :
    if (n^1 == n+1) :
        return True;
    else :
        return False;

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


Write a function to find the longest chain which can be formed from the given set of pairs.

class Pair(object):
	def __init__(self, a, b):
		self.a = a
		self.b = b
def max_chain_length(arr, n):
	max = 0
	mcl = [1 for i in range(n)]
	for i in range(1, n):
		for j in range(0, i):
			if (arr[i].a > arr[j].b and
				mcl[i] < mcl[j] + 1):
				mcl[i] = mcl[j] + 1
	for i in range(n):
		if (max < mcl[i]):
			max = mcl[i]
	return max

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


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

def first_repeated_char(str1):
  for index,c in enumerate(str1):
    if str1[:index+1].count(c) > 1:
      return c
  return "None"

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


Write a function to get a lucid number smaller than or equal to n.

def get_ludic(n):
	ludics = []
	for i in range(1, n + 1):
		ludics.append(i)
	index = 1
	while(index != len(ludics)):
		first_ludic = ludics[index]
		remove_index = index + first_ludic
		while(remove_index < len(ludics)):
			ludics.remove(ludics[remove_index])
			remove_index = remove_index + first_ludic - 1
		index += 1
	return ludics

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


Write a function to reverse words in a given string.

def reverse_words(s):
        return ' '.join(reversed(s.split()))

FUNC_DEF RETURN FUNC_CALL STRING FUNC_CALL VAR FUNC_CALL VAR


Write a function to check if the given integer is a prime number.

def prime_num(num):
  if num >=1:
   for i in range(2, num//2):
     if (num % i) == 0:
                return False
     else:
                return True
  else:
          return False

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


Write a function to convert degrees to radians.

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

IMPORT FUNC_DEF ASSIGN VAR BIN_OP VAR BIN_OP VAR NUMBER RETURN VAR


Write a function to search a literals string in a string and also find the location within the original string where the pattern occurs by using regex.

import re
pattern = 'fox'
text = 'The quick brown fox jumps over the lazy dog.'
def find_literals(text, pattern):
  match = re.search(pattern, text)
  s = match.start()
  e = match.end()
  return (match.re.pattern, s, e)

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


Write a python function to find nth bell number.

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

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


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

def floor_Min(A,B,N):
    x = max(B - 1,N)
    return (A*x) // B

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


Write a python function to remove the k'th element from a given list.

def remove_kth_element(list1, L):
    return  list1[:L-1] + list1[L:]

FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER VAR VAR


Write a function to find the maximum of nth column from the given tuple list.

def max_of_nth(test_list, N):
  res = max([sub[N] for sub in test_list])
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR VAR VAR RETURN VAR


Write a python function to merge the first and last elements separately in a list of lists.

def merge(lst):
    return [list(ele) for ele in list(zip(*lst))]

FUNC_DEF RETURN FUNC_CALL VAR VAR VAR FUNC_CALL VAR FUNC_CALL VAR VAR


Write a function to find the maximum value in record list as tuple attribute in the given tuple list.

def maximum_value(test_list):
  res = [(key, max(lst)) for key, lst in test_list]
  return (res)

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


Write a function to find the cumulative sum of all the values that are present in the given tuple list.

def cummulative_sum(test_list):
  res = sum(map(sum, test_list))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to find average value of the numbers in a given tuple of tuples.

def average_tuple(nums):
    result = [sum(x) / len(x) for x in zip(*nums)]
    return result

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


Write a function to perfom the modulo of tuple elements in the given two tuples.

def tuple_modulo(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 check for the number of jumps required of given length to reach a point of form (d, 0) from origin in a 2d plane.

def min_Jumps(a, b, d):
    temp = a
    a = min(a, b)
    b = max(temp, b)
    if (d >= b):
        return (d + b - 1) / b
    if (d == 0):
        return 0
    if (d == a):
        return 1
    else:
        return 2

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


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

def div_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 function to move all the numbers in it to the given string.

def move_num(test_str):
  res = ''
  dig = ''
  for ele in test_str:
    if ele.isdigit():
      dig += ele
    else:
      res += ele
  res += dig
  return (res)

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


Write a function to find the largest subset where each pair is divisible.

def largest_subset(a, n):
	dp = [0 for i in range(n)]
	dp[n - 1] = 1;
	for i in range(n - 2, -1, -1):
		mxm = 0;
		for j in range(i + 1, n):
			if a[j] % a[i] == 0 or a[i] % a[j] == 0:
				mxm = max(mxm, dp[j])
		dp[i] = 1 + mxm
	return max(dp)

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


Write a function to increment the numeric values in the given strings by k.

def increment_numerics(test_list, K):
  res = [str(int(ele) + K) if ele.isdigit() else ele for ele in test_list]
  return res

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


Write a function to find the median of two sorted arrays of same size.

def get_median(arr1, arr2, n):
  i = 0
  j = 0
  m1 = -1
  m2 = -1
  count = 0
  while count < n + 1:
    count += 1
    if i == n:
      m1 = m2
      m2 = arr2[0]
      break
    elif j == n:
      m1 = m2
      m2 = arr1[0]
      break
    if arr1[i] <= arr2[j]:
      m1 = m2
      m2 = arr1[i]
      i += 1
    else:
      m1 = m2
      m2 = arr2[j]
      j += 1
  return (m1 + m2)/2

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


Write a function to find the n-th power of individual elements in a list using lambda function.

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

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


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

def is_upper(string):
  return (string.upper())


Write a python function to interchange first and last elements in a given list.

def swap_List(newList):
    size = len(newList)
    temp = newList[0]
    newList[0] = newList[size - 1]
    newList[size - 1] = temp
    return newList

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


Write a python function to find the largest triangle that can be inscribed in the semicircle.

def triangle_area(r) :
    if r < 0 :
        return -1
    return r * r

FUNC_DEF IF VAR NUMBER RETURN NUMBER RETURN BIN_OP VAR VAR


Write a python function to find the smallest missing number from the given array.

def find_First_Missing(array,start,end):
    if (start > end):
        return end + 1
    if (start != array[start]):
        return start;
    mid = int((start + end) / 2)
    if (array[mid] == mid):
        return find_First_Missing(array,mid+1,end)
    return find_First_Missing(array,start,mid)

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


Write a function to replace all spaces in the given string with character * list item * list item * list item * list item '%20'.

MAX=1000;
def replace_spaces(string):
  string=string.strip()
  i=len(string)
  space_count=string.count(' ')
  new_length = i + space_count*2
  if new_length > MAX:
    return -1
  index = new_length-1
  string=list(string)
  for f in range(i-2, new_length-2):
    string.append('0')
  for j in range(i-1, 0, -1):
    if string[j] == ' ':
      string[index] = '0'
      string[index-1] = '2'
      string[index-2] = '%'
      index=index-3
    else:
      string[index] = string[j]
      index -= 1
  return ''.join(string)

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


Write a python function to find even numbers from a mixed list.

def Split(list):
    ev_li = []
    for i in list:
        if (i % 2 == 0):
            ev_li.append(i)
    return ev_li

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


Write a function to extract all the adjacent coordinates of the given coordinate tuple.

def adjac(ele, sub = []):
  if not ele:
     yield sub
  else:
     yield from [idx for j in range(ele[0] - 1, ele[0] + 2)
                for idx in adjac(ele[1:], sub + [j])]
def get_coordinates(test_tup):
  res = list(adjac(test_tup))
  return (res)

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


Write a function to replace whitespaces with an underscore and vice versa in a given string by using regex.

import re
text = 'Python Exercises'
def replace_spaces(text):
  text =text.replace (" ", "_")
  return (text)
  text =text.replace ("_", " ")
  return (text)

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


Write a python function to move all zeroes to the end of the given list.

def move_zero(num_list):
    a = [0 for i in range(num_list.count(0))]
    x = [ i for i in num_list if i != 0]
    x.extend(a)
    return (x)

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


Write a python function to find the sum of xor of all pairs of numbers in the given array.

def pair_OR_Sum(arr,n) :
    ans = 0
    for i in range(0,n) :
        for j in range(i + 1,n) :
            ans = ans + (arr[i] ^ arr[j])
    return ans

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


Write a python function to find the sum of fourth 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);
    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 VAR VAR VAR VAR RETURN VAR


Write a function to push all values into a heap and then pop off the smallest values one at a time.

import heapq as hq
def heap_sort(iterable):
    h = []
    for value in iterable:
        hq.heappush(h, value)
    return [hq.heappop(h) for i in range(len(h))]

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


Write a python function to check if roots of a quadratic equation are reciprocal of each other or not.

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

FUNC_DEF IF VAR VAR RETURN STRING RETURN STRING


Write a function to check whether the given amount has no profit and no loss

def noprofit_noloss(actual_cost,sale_amount):
  if(sale_amount == actual_cost):
    return True
  else:
    return False

FUNC_DEF IF VAR VAR RETURN NUMBER RETURN NUMBER


Write a function to calculate wind chill index.

import math
def wind_chill(v,t):
 windchill = 13.12 + 0.6215*t -  11.37*math.pow(v, 0.16) + 0.3965*t*math.pow(v, 0.16)
 return int(round(windchill, 0))

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


Write a function to sum the length of the names of a given list of names after removing the names that start with a lowercase letter.

def sample_nam(sample_names):
  sample_names=list(filter(lambda el:el[0].isupper() and el[1:].islower(),sample_names))
  return len(''.join(sample_names))

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


Write a function to remove the parenthesis area in a string.

import re
def remove_parenthesis(items):
 for item in items:
    return (re.sub(r" ?\([^)]+\)", "", item))

IMPORT FUNC_DEF FOR VAR VAR RETURN FUNC_CALL VAR STRING STRING VAR


Write a function to find the nth nonagonal number.

def is_nonagonal(n):
	return int(n * (7 * n - 5) / 2)

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


Write a function to remove similar rows from the given tuple matrix.

def remove_similar_row(test_list):
  res = set(sorted([tuple(sorted(set(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 that matches a word containing 'z', not at the start or end of the word.

import re
def text_match_wordz_middle(text):
        patterns = '\Bz\B'
        if re.search(patterns,  text):
                return 'Found a match!'
        else:
                return('Not matched!')

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


Write a python function to reverse an array upto a given position.

def reverse_Array_Upto_K(input, k):
  return (input[k-1::-1] + input[k:])

FUNC_DEF RETURN BIN_OP VAR BIN_OP VAR NUMBER NUMBER VAR VAR


Write a function to find the product of it’s kth index in the given tuples.

def get_product(val) :
	res = 1
	for ele in val:
		res *= ele
	return res
def find_k_product(test_list, K):
  res = get_product([sub[K] for sub in test_list])
  return (res)

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


Write a python function to count number of cubes of size k in a cube of size n.

def No_of_cubes(N,K):
    No = 0
    No = (N - K + 1)
    No = pow(No, 3)
    return No

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


Write a function to split a string at uppercase letters.

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

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


Write a function to exchange the position of every n-th value with (n+1)th value and (n+1)th value with n-th value in a given list.

from itertools import zip_longest, chain, tee
def exchange_elements(lst):
    lst1, lst2 = tee(iter(lst), 2)
    return list(chain.from_iterable(zip_longest(lst[1::2], lst[::2])))

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


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

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

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


Write a python function to check whether the given two arrays are equal or not.

def are_Equal(arr1,arr2,n,m):
    if (n != m):
        return False
    arr1.sort()
    arr2.sort()
    for i in range(0,n - 1):
        if (arr1[i] != arr2[i]):
            return False
    return True

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


Write a function to check if one tuple is a subset of another tuple.

def check_subset(test_tup1, test_tup2):
  res = set(test_tup2).issubset(test_tup1)
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to flatten the given tuple matrix into the tuple list with each tuple representing each column.

def matrix_to_list(test_list):
  temp = [ele for sub in test_list for ele in sub]
  res = list(zip(*temp))
  return (str(res))

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


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

from collections import defaultdict
def grouping_dictionary(l):
    d = defaultdict(list)
    for k, v in l:
        d[k].append(v)
    return d

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


Write a function to find the perimeter of a rectangle.

def rectangle_perimeter(l,b):
  perimeter=2*(l+b)
  return perimeter

FUNC_DEF ASSIGN VAR BIN_OP NUMBER BIN_OP VAR VAR RETURN VAR


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

def fifth_Power_Sum(n) :
    sm = 0
    for i in range(1,n+1) :
        sm = sm + (i*i*i*i*i)
    return sm

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


Write a python function to find the minimum sum of absolute differences of two arrays.

def find_Min_Sum(a,b,n):
    a.sort()
    b.sort()
    sum = 0
    for i in range(n):
        sum = sum + abs(a[i] - b[i])
    return sum

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


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

import math
def first_Digit(n) :
    fact = 1
    for i in range(2,n + 1) :
        fact = fact * i
        while (fact % 10 == 0) :
            fact = int(fact / 10)
    while (fact >= 10) :
        fact = int(fact / 10)
    return math.floor(fact)

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


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

def max_occurrences(list1):
    max_val = 0
    result = list1[0]
    for i in list1:
        occu = list1.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 python function to print duplicants from a list of integers.

def Repeat(x):
    _size = len(x)
    repeated = []
    for i in range(_size):
        k = i + 1
        for j in range(k, _size):
            if x[i] == x[j] and x[i] not in repeated:
                repeated.append(x[i])
    return repeated

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


Write a python function to choose points from two ranges such that no point lies in both the ranges.

def find_Points(l1,r1,l2,r2):
    x = min(l1,l2) if (l1 != l2) else -1
    y = max(r1,r2) if (r1 != r2) else -1
    return (x,y)

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


Write a function to find the maximum sum that can be formed which has no three consecutive elements present.

def max_sum_of_three_consecutive(arr, n):
	sum = [0 for k in range(n)]
	if n >= 1:
		sum[0] = arr[0]
	if n >= 2:
		sum[1] = arr[0] + arr[1]
	if n > 2:
		sum[2] = max(sum[1], max(arr[1] + arr[2], arr[0] + arr[2]))
	for i in range(3, n):
		sum[i] = max(max(sum[i-1], sum[i-2] + arr[i]), arr[i] + arr[i-1] + sum[i-3])
	return sum[n-1]

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


Write a function to sort a list in a dictionary.

def sorted_dict(dict1):
  sorted_dict = {x: sorted(y) for x, y in dict1.items()}
  return sorted_dict

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


Write a function to find the largest possible value of k such that k modulo x is y.

import sys
def find_max_val(n, x, y):
	ans = -sys.maxsize
	for k in range(n + 1):
		if (k % x == y):
			ans = max(ans, k)
	return (ans if (ans >= 0 and
					ans <= n) else -1)

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


Write a python function to find the average of even numbers till a given even number.

def average_Even(n) :
    if (n% 2!= 0) :
        return ("Invalid Input")
        return -1
    sm = 0
    count = 0
    while (n>= 2) :
        count = count+1
        sm = sm+n
        n = n-2
    return sm // count

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


Write a python function to shift first element to the end of given list.

def move_last(num_list):
    a = [num_list[0] for i in range(num_list.count(num_list[0]))]
    x = [ i for i in num_list if i != num_list[0]]
    x.extend(a)
    return (x)

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


Write a function to count occurrence of a character in a string.

def count_char(string,char):
 count = 0
 for i in range(len(string)):
    if(string[i] == char):
        count = count + 1
 return count

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


Write a python function to count number of vowels in the string.

def Check_Vow(string, vowels):
    final = [each for each in string if each in vowels]
    return(len(final))

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


Write a python function to replace multiple occurence of character by single.

import re
def replace(string, char):
    pattern = char + '{2,}'
    string = re.sub(pattern, char, string)
    return string

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


Write a function to check whether the given ip address is valid or not using regex.

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


Write a python function to check whether a sequence of numbers has a decreasing trend or not.

def decreasing_trend(nums):
    if (sorted(nums)== nums):
        return True
    else:
        return False

FUNC_DEF IF FUNC_CALL VAR VAR VAR RETURN NUMBER RETURN NUMBER


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

import math
def get_Pos_Of_Right_most_Set_Bit(n):
    return int(math.log2(n&-n)+1)
def set_Right_most_Unset_Bit(n):
    if (n == 0):
        return 1
    if ((n & (n + 1)) == 0):
        return n
    pos = get_Pos_Of_Right_most_Set_Bit(~n)
    return ((1 << (pos - 1)) | n)

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


Write a function to find maximum of three numbers.

def max_of_three(num1,num2,num3):
    if (num1 >= num2) and (num1 >= num3):
       lnum = num1
    elif (num2 >= num1) and (num2 >= num3):
       lnum = num2
    else:
       lnum = num3
    return lnum

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


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

def convert(list):
    s = [str(i) for i in list]
    res = int("".join(s))
    return (res)

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


Write a function to remove duplicate words from a given string using collections module.

from collections import OrderedDict
def remove_duplicate(string):
  result = ' '.join(OrderedDict((w,w) for w in string.split()).keys())
  return result

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


Write a function to add two integers. however, if the sum is between the given range it will return 20.

def sum_nums(x, y,m,n):
    sum_nums= x + y
    if sum_nums in range(m, n):
        return 20
    else:
        return sum_nums

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


Write a function to remove everything except alphanumeric characters from the given string by using regex.

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

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


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

def validity_triangle(a,b,c):
 total = a + b + c
 if total == 180:
    return True
 else:
    return False

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


Write a python function to remove spaces from a given string.

def remove_spaces(str1):
  str1 = str1.replace(' ','')
  return str1

FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING STRING RETURN VAR


Write a function to access dictionary key’s element by index.

def access_key(ditionary,key):
  return list(ditionary)[key]


Write a python function to check whether a sequence of numbers has an increasing trend or not.

def increasing_trend(nums):
    if (sorted(nums)== nums):
        return True
    else:
        return False


Write a python function to find the smallest prime divisor of a number.

def smallest_Divisor(n):
    if (n % 2 == 0):
        return 2;
    i = 3;
    while (i*i <= n):
        if (n % i == 0):
            return i;
        i += 2;
    return n;

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


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

def mul_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 given number can be represented by sum of two squares or not.

def sum_Square(n) :
    i = 1
    while i*i <= n :
        j = 1
        while (j*j <= n) :
            if (i*i+j*j == n) :
                return True
            j = j+1
        i = i+1
    return False

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


Write a python function to count occurences of a character in a repeated string.

def count_Char(str,x):
    count = 0
    for i in range(len(str)):
        if (str[i] == x) :
            count += 1
    n = 10
    repititions = n // len(str)
    count = count * repititions
    l = n % len(str)
    for i in range(l):
        if (str[i] == x):
            count += 1
    return count

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


Write a python function to find sum of prime numbers between 1 to n.

def sum_Of_Primes(n):
    prime = [True] * (n + 1)
    p = 2
    while p * p <= n:
        if prime[p] == True:
            i = p * 2
            while i <= n:
                prime[i] = False
                i += p
        p += 1
    sum = 0
    for i in range (2,n + 1):
        if(prime[i]):
            sum += i
    return sum

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


Write a function to find the frequency of each element in the given list.

from collections import defaultdict
def freq_element(test_tup):
  res = defaultdict(int)
  for ele in test_tup:
    res[ele] += 1
  return (str(dict(res)))

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


Write a function to find the greatest common divisor (gcd) of two integers by using recursion.

def recur_gcd(a, b):
	low = min(a, b)
	high = max(a, b)
	if low == 0:
		return high
	elif low == 1:
		return 1
	else:
		return recur_gcd(low, high%low)

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


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

import cmath
def len_complex(a,b):
  cn=complex(a,b)
  length=abs(cn)
  return length

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


## write a function to find the minimum number of jumps to reach the end of the array for the given array of integers where each element represents the max number of steps that can be made forward from that element. > indented block > indented block

def min_jumps(arr, n):
	jumps = [0 for i in range(n)]
	if (n == 0) or (arr[0] == 0):
		return float('inf')
	jumps[0] = 0
	for i in range(1, n):
		jumps[i] = float('inf')
		for j in range(i):
			if (i <= j + arr[j]) and (jumps[j] != float('inf')):
				jumps[i] = min(jumps[i], jumps[j] + 1)
				break
	return jumps[n-1]

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


Write a function to multiply consecutive numbers of a given list.

def mul_consecutive_nums(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 group the 1st elements on the basis of 2nd elements in the given tuple list.

from itertools import groupby
def group_element(test_list):
  res = dict()
  for key, val in groupby(sorted(test_list, key = lambda ele: ele[1]), key = lambda ele: ele[1]):
    res[key] = [ele[0] for ele in val]
  return (res)

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


Write a python function to find the last two digits in factorial of a given number.

def last_Two_Digits(N):
    if (N >= 10):
        return
    fac = 1
    for i in range(1,N + 1):
        fac = (fac * i) % 100
    return (fac)

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


Write a function to remove multiple spaces in a string by using regex.

import re
def remove_multiple_spaces(text1):
  return (re.sub(' +',' ',text1))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


Write a function to extract unique values from the given dictionary values.

def extract_unique(test_dict):
  res = list(sorted({ele for val in test_dict.values() for ele in val}))
  return res

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


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

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

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


Write a function to zip two given lists of lists.

def zip_list(list1,list2):
 result = list(map(list.__add__, list1, list2))
 return result

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


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

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

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 sort dictionary items by tuple product of keys for the given dictionary with tuple keys.

def sort_dict_item(test_dict):
  res = {key: test_dict[key] for key in sorted(test_dict.keys(), key = lambda ele: ele[1] * ele[0])}
  return  (res)

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


Write a python function to find the minimum number of swaps required to convert one binary string to another.

def min_Swaps(str1,str2) :
    count = 0
    for i in range(len(str1)) :
        if str1[i] != str2[i] :
            count += 1
    if count % 2 == 0 :
        return (count // 2)
    else :
        return ("Not Possible")

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


Write a function to count the number of elements in a list which are within a specific range.

def count_range_in_list(li, min, max):
	ctr = 0
	for x in li:
		if min <= x <= max:
			ctr += 1
	return ctr

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


Write a function to find the equilibrium index of the given array.

def equilibrium_index(arr):
  total_sum = sum(arr)
  left_sum=0
  for i, num in enumerate(arr):
    total_sum -= num
    if left_sum == total_sum:
      return i
    left_sum += num
  return -1

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


Write a function to find the minimum number of elements that should be removed such that amax-amin<=k.

def find_ind(key, i, n,
			k, arr):
	ind = -1
	start = i + 1
	end = n - 1;
	while (start < end):
		mid = int(start +
				(end - start) / 2)
		if (arr[mid] - key <= k):
			ind = mid
			start = mid + 1
		else:
			end = mid
	return ind
def removals(arr, n, k):
	ans = n - 1
	arr.sort()
	for i in range(0, n):
		j = find_ind(arr[i], i,
					n, k, arr)
		if (j != -1):
			ans = min(ans, n -
						(j - i + 1))
	return ans

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


Write a function to check whether the given key is present in the dictionary or not.

def is_key_present(d,x):
  if x in d:
    return True
  else:
     return False

FUNC_DEF IF VAR VAR RETURN NUMBER RETURN 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 sort a list of lists by length and value.

def sort_sublists(list1):
      list1.sort()
      list1.sort(key=len)
      return  list1

FUNC_DEF EXPR FUNC_CALL VAR EXPR FUNC_CALL VAR VAR RETURN VAR


Write a function to find whether an array is subset of another array.

def is_subset(arr1, m, arr2, n):
	hashset = set()
	for i in range(0, m):
		hashset.add(arr1[i])
	for i in range(0, n):
		if arr2[i] in hashset:
			continue
		else:
			return False
	return True

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


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

def count_Set_Bits(n) :
    n += 1;
    powerOf2 = 2;
    cnt = n // 2;
    while (powerOf2 <= n) :
        totalPairs = n // powerOf2;
        cnt += (totalPairs // 2) * powerOf2;
        if (totalPairs & 1) :
            cnt += (n % powerOf2)
        else :
            cnt += 0
        powerOf2 <<= 1;
    return cnt;

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


Write a python function to convert a string to a list.

def Convert(string):
    li = list(string.split(" "))
    return li

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR STRING RETURN VAR


Write a function to count unique keys for each value present in the tuple.

from collections import defaultdict
def get_unique(test_list):
  res = defaultdict(list)
  for sub in test_list:
    res[sub[1]].append(sub[0])
  res = dict(res)
  res_dict = dict()
  for key in res:
    res_dict[key] = len(list(set(res[key])))
  return (str(res_dict))

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


Write a function to access the initial and last data of the given tuple record.

def front_and_rear(test_tup):
  res = (test_tup[0], test_tup[-1])
  return (res)

FUNC_DEF ASSIGN VAR VAR NUMBER VAR NUMBER RETURN VAR


Write a python function to check whether the product of digits of a number at even and odd places is equal or not.

def product_Equal(n):
    if n < 10:
        return False
    prodOdd = 1; prodEven = 1
    while n > 0:
        digit = n % 10
        prodOdd *= digit
        n = n//10
        if n == 0:
            break;
        digit = n % 10
        prodEven *= digit
        n = n//10
    if prodOdd == prodEven:
        return True
    return False

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


Write a function to remove duplicates from a list of lists.

import itertools
def remove_duplicate(list1):
 list.sort(list1)
 remove_duplicate = list(list1 for list1,_ in itertools.groupby(list1))
 return remove_duplicate

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


Write a function to check if the given tuple contains all valid values or not.

def check_valid(test_tup):
  res = not any(map(lambda ele: not ele, test_tup))
  return (res)

FUNC_DEF ASSIGN VAR FUNC_CALL VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a python function to count the number of distinct power of prime factor of given number.

def count_Fac(n):
    m = n
    count = 0
    i = 2
    while((i * i) <= m):
        total = 0
        while (n % i == 0):
            n /= i
            total += 1
        temp = 0
        j = 1
        while((temp + j) <= total):
            temp += j
            count += 1
            j += 1
        i += 1
    if (n != 1):
        count += 1
    return count

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


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

def str_to_tuple(test_str):
  res = tuple(map(int, test_str.split(', ')))
  return (res)

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


Write a function to find the perimeter of a rombus.

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

FUNC_DEF ASSIGN VAR BIN_OP NUMBER VAR RETURN VAR


Write a function to calculate the standard deviation.

import math
import sys
def sd_calc(data):
    n = len(data)
    if n <= 1:
        return 0.0
    mean, sd = avg_calc(data), 0.0
    for el in data:
        sd += (float(el) - mean)**2
    sd = math.sqrt(sd / float(n-1))
    return sd
def avg_calc(ls):
    n, mean = len(ls), 0.0
    if n <= 1:
        return ls[0]
    for el in ls:
        mean = mean + float(el)
    mean = mean / float(n)
    return mean

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


Write a function to create a list taking alternate elements from another given list.

def alternate_elements(list1):
    result=[]
    for item in list1[::2]:
        result.append(item)
    return result

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


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

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

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


Write a function to add a dictionary to the tuple.

def add_dict_to_tuple(test_tup, test_dict):
  test_tup = list(test_tup)
  test_tup.append(test_dict)
  test_tup = tuple(test_tup)
  return (test_tup)

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


Write a function to find a path with the maximum average over all existing paths for the given square matrix of size n*n.

M = 100
def maxAverageOfPath(cost, N):
	dp = [[0 for i in range(N + 1)] for j in range(N + 1)]
	dp[0][0] = cost[0][0]
	for i in range(1, N):
		dp[i][0] = dp[i - 1][0] + cost[i][0]
	for j in range(1, N):
		dp[0][j] = dp[0][j - 1] + cost[0][j]
	for i in range(1, N):
		for j in range(1, N):
			dp[i][j] = max(dp[i - 1][j],
						dp[i][j - 1]) + cost[i][j]
	return dp[N - 1][N - 1] / (2 * N - 1)

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


Write a function to filter the height and width of students which are stored in a dictionary.

def filter_data(students,h,w):
    result = {k: s for k, s in students.items() if s[0] >=h and s[1] >=w}
    return result

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


Write a function to count the same pair in two given lists using map function.

from operator import eq
def count_same_pair(nums1, nums2):
    result = sum(map(eq, nums1, nums2))
    return result

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


Write a function to calculate the sum of all digits of the base to the specified power.

def power_base_sum(base, power):
    return sum([int(i) for i in str(pow(base, power))])

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


Write a function to extract values between quotation marks of the given string by using regex.

import re
def extract_quotation(text1):
  return (re.findall(r'"(.*?)"', text1))

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING VAR


Write a function to multiply the adjacent elements of the given tuple.

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

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


Write a function to remove all characters except letters and numbers using regex

import re
def remove_char(S):
  result = re.sub('[\W_]+', '', S)
  return result

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR STRING STRING VAR RETURN VAR


Write a function to sum elements in two lists.

def sum_list(lst1,lst2):
  res_list = [lst1[i] + lst2[i] for i in range(len(lst1))]
  return res_list

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


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

def add_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 function to remove consecutive duplicates of a given list.

from itertools import groupby
def consecutive_duplicates(nums):
    return [key for key, group in groupby(nums)]

FUNC_DEF RETURN VAR VAR VAR FUNC_CALL VAR VAR


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

import math
def lateralsurface_cone(r,h):
  l = math.sqrt(r * r + h * h)
  LSA = math.pi * r  * l
  return LSA

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


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

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

IMPORT FUNC_DEF RETURN FUNC_CALL VAR STRING STRING VAR


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

def find_first_occurrence(A, x):
    (left, right) = (0, len(A) - 1)
    result = -1
    while left <= right:
        mid = (left + right) // 2
        if x == A[mid]:
            result = mid
            right = 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 python function to find sum of products of all possible subarrays.

def sum_Of_Subarray_Prod(arr,n):
    ans = 0
    res = 0
    i = n - 1
    while (i >= 0):
        incr = arr[i]*(1 + res)
        ans += incr
        res = incr
        i -= 1
    return (ans)

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


Write a python function to toggle bits of the number except the first and the last bit.

def set_middle_bits(n):
    n |= n >> 1;
    n |= n >> 2;
    n |= n >> 4;
    n |= n >> 8;
    n |= n >> 16;
    return (n >> 1) ^ 1
def toggle_middle_bits(n):
    if (n == 1):
        return 1
    return n ^ set_middle_bits(n)

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


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

import bisect
def left_insertion(a, x):
    i = bisect.bisect_left(a, x)
    return i

IMPORT FUNC_DEF ASSIGN VAR FUNC_CALL VAR VAR VAR RETURN VAR


Write a function to check whether the given string is starting with a vowel or not using regex.

import re
regex = '^[aeiouAEIOU][A-Za-z0-9_]*'
def check_str(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 calculate the geometric sum of n-1.

def geometric_sum(n):
  if n < 0:
    return 0
  else:
    return 1 / (pow(2, n)) + geometric_sum(n - 1)

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


Write a python function to find the index of smallest triangular number with n digits.

import math
def find_Index(n):
    x = math.sqrt(2 * math.pow(10,(n - 1)));
    return round(x);

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