Most asked top Interview Questions and Answers & Online Test
Education platform for interview prep, online tests, tutorials, and live practice

Build skills with focused learning paths, mock tests, and interview-ready content.

WithoutBook brings subject-wise interview questions, online practice tests, tutorials, and comparison guides into one responsive learning workspace.

Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address
Home / Interview Subjects / Python Coding
WithoutBook LIVE Mock Interviews Python Coding Related interview subjects: 9

Interview Questions and Answers

Know the top Python Coding interview questions and answers for freshers and experienced candidates to prepare for job interviews.

Total 20 questions Interview Questions and Answers

The Best LIVE Mock Interview - You should go through before interview

Know the top Python Coding interview questions and answers for freshers and experienced candidates to prepare for job interviews.

Interview Questions and Answers

Search a question to view the answer.

Intermediate / 1 to 5 years experienced level questions & answers

Ques 2

Implement a function to check if a number is prime.

def is_prime(num):

  if num < 2:

  return False

  for i in range(2, int(num**0.5) + 1):

    if num % i == 0:

      return False

   return True

Example:

is_prime(11)  # Output: True
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 3

Create a Python class for a basic stack implementation.

class Stack:

  def __init__(self):

    self.items = []

 

  def push(self, item):

    self.items.append(item)

 

  def pop(self):

    return self.items.pop()

 

  def is_empty(self):

    return len(self.items) == 0

Example:

stack = Stack()
stack.push(1)
stack.push(2)
print(stack.pop())  # Output: 2
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 5

Write a Python program to find the length of the longest increasing subsequence in an array.

def longest_increasing_subsequence(arr):

  n = len(arr)\n lis = [1]*n

  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

          return max(lis)

Example:

longest_increasing_subsequence([10, 22, 9, 33, 21, 50, 41, 60, 80])  # Output: 6
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 6

Create a Python generator function to generate the power set of a given set.

def power_set(input_set):

  n = len(input_set)

  for i in range(1 << n):

    subset = [input_set[j]

      for j in range(n):

        if (i & (1 << j)) > 0]

          yield subset

Example:

power_set({1, 2, 3})  # Output: [], [1], [2], [3], [1, 2], [1, 3], [2, 3], [1, 2, 3]
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments
Ques 7

Write a Python function to implement the binary search algorithm.

def binary_search(arr, target):

  low, high = 0, len(arr) - 1

  while low <= high:

    mid = (low + high) // 2

    if arr[mid] == target:

      return mid

    elif arr[mid] < target:

      low = mid + 1

    else:

      high = mid - 1

    return -1

Example:

binary_search([1, 2, 3, 4, 5, 6, 7], 4)  # Output: 3
Save For Revision

Save For Revision

Bookmark this item, mark it difficult, or place it in a revision set.

Open My Learning Library
Is it helpful?
Add Comment View Comments

Most helpful rated by users:

Copyright © 2026, WithoutBook.