Top 15 Python Coding Interview Questions with Solutions – Do it Yourself

35 Comments



More Python coding interview questions here: https://www.youtube.com/watch?v=3AHzWOWRWvQ

Top 10 Python Coding Interview Questions & Solutions for FAANG: https://www.youtube.com/watch?v=3AHzWOWRWvQ

Top 15 Python coding interview Questions & Solutions – Do it Yourself
Top 15 Python Programming Questions & Solutions -asked in Amazon, Facebook, Microsoft, Tesla Interviews
How to crack Python Programming test for Amazon?
How to crack Python Programming test for Facebook?
How to crack Python Programming test for Tesla?

1. Write a Python Program to print Prime Numbers between 2 numbers
2. Write a Sort function to sort the elements in a list
3. Write a sorting function without using the list.sort function
4. Write a Python program to print Fibonacci Series
5. Write a Python program to print a list in reverse
6. Write a Python program to check whether a string is a Palindrome or not
7. Write a Python program to print set of duplicates in a list
8. Write a Python program to print number of words in a given sentence
9. Given an array arr[] of n elements, write a Python function to search a given element x in arr[].
10. Write a Python program to implement a Binary Search
11. Write a Python program to plot a simple bar chart
12. Write a Python program to join two strings (Hint: using join())
13. Write a Python program to extract digits from given string
14. Write a Python program to split strings using newline delimiter
15. Given a string as your input, delete any reoccurring character, and return the new string.

Make a copy of the python notebook
SOLUTION HERE: https://colab.research.google.com/drive/13OM61QV_xMpw-FcX2qf_9mqoVGg5mjnE?usp=sharing

Bharati DW Consultancy
cell: +1-562-646-6746
email: bharati.dwconsultancy@gmail.com
website: http://bharatidwconsultancy.blogspot.com
Twitter: @BharatDWCons
Youtube: BharatiDWConsultancy
Whatsapp: +1-562-646-6746 (+1-56-COGNOS-46)

source

35 Comments
    • blank
      Nikunj Rana
      May 10, 2022 15:30 pm Reply

      Qus 1:
      for x in range(100,200,2):
      print(x)

    • blank
      pawan deep singh
      May 10, 2022 15:30 pm Reply

      best part was when 'khatron ke khiladi' recommendation poped up at

    • blank
      Manan
      May 10, 2022 15:30 pm Reply

      Questions are okay. But most of the solutions can be further optimised..

      For example palindrome can be check while interating string .just check I and n-1-i char ..mis match then false

      I don't think reversed would take constant time..

    • blank
      arun kumar
      May 10, 2022 15:30 pm Reply

      Sir oru program ku solution venum

      Input: 13/02/2022
      Output: 13/feb/2022

      Idha epudi sir pananum

    • blank
      EveryThinG
      May 10, 2022 15:30 pm Reply

      Q1:
      For num in range(100, 200) :
      Cpt = 0
      For i in range(2, num) :
      If num % i != 0:
      Cpt += 1
      If cpt == num – 2:
      Print(num)

    • blank
      romkainmotion
      May 10, 2022 15:30 pm Reply

      some nice questions to play around with shortest or interesnig answer. For example for first question. There is much shorter solution with if statment, and it possible to do it with oneliner: print(*(i for i in range(100, 200) if i % 2 != 0), sep="n") just for fun.

    • blank
      Ishwarya Sagar
      May 10, 2022 15:30 pm Reply

      Very very small letters…. Not visible at all…. Plz do lil bigger so that it will good for us to view

    • blank
      Vedantha S M
      May 10, 2022 15:30 pm Reply

      Hi.
      Can you please confirm on the Question No: 14 solution. I think below code also produce the same result, then why you are using…. rstrip() etc.

      new_string = "How are you doing"

      output = new_string.split()

      print(output)
      Result = ['How', 'are', 'you', 'doing']

      Thank you.

    • blank
      Nikhil Noona
      May 10, 2022 15:30 pm Reply

      Should we be using recursion for fibonacci?

    • blank
      Suraj Sahoo
      May 10, 2022 15:30 pm Reply

      Developer questions or production support questions?

    • blank
      Abduljelil Ali
      May 10, 2022 15:30 pm Reply

      i don't think facebook, amazon and other tech giants' interview is this easy.

    • blank
      Prathamesh Vaidya
      May 10, 2022 15:30 pm Reply

      What if we use built in fun i.e min() and max() to sort a list
      a=[5,1,8,10,3,7,2,4]

      b=[]

      while a:

      minimum = a[0]

      for i in a:

      if i==max(a):

      b.append(i)

      a.remove(i)

      print(b)

    • blank
      Enes Uğuroğlu
      May 10, 2022 15:30 pm Reply

      Here is alternative for question 3
      def sort_list(x):
      l = []
      k = list(x)
      for j in range(0, len(k)):
      for i in k:
      if i == max(k):
      l.append(i)
      k.remove(i)
      print(l)

    • blank
      ReflectingMe
      May 10, 2022 15:30 pm Reply

      Question on 3rd answer – no need to iterate over the list with a for-loop or did I miss something? Just get the smallest number, append to new, remove from existing and repeat using the while.

      data_list = [25, 55, 78, 64, 25, 12, 22, 11, 1, 2, 44, 3, 122, 23, 34]
      new_list = []

      while data_list:
      minimum = min(data_list)
      new_list.append(minimum)
      data_list.remove(minimum)

      new_list.reverse(sort = True)
      print(new_list)

    • blank
      Klejara
      May 10, 2022 15:30 pm Reply

      Tell me this is joke. No way somebody ask you this question on intervy for python junior developer jobs??

    • blank
      swapnil walavalkar
      May 10, 2022 15:30 pm Reply

      Use this template for print the questions (Can anybody solve this? pls help)

      Enter name:

      Enter department:

      Enter feedback:

      Enter year:

      The program should output the result with the entered values

      Name:

      Department:

      Feedback:

      Year:

    • blank
      Kasinder
      May 10, 2022 15:30 pm Reply

      If anyone's watching this in 2021. Question 14, the point of String.rstrip() is to remove newline characters. This is a newline character "n". ini_str should be 'This is a test programn'

    • blank
      babu sartop
      May 10, 2022 15:30 pm Reply

      Your're not wasting anyone's time — we all come here to learn so don't skip anything, no matter how minute it is.

    • blank
      Dhans Raj
      May 10, 2022 15:30 pm Reply

      4th answer: Tried in a different way and works

      newlist1=[]
      for i in range(0,30):
      if not newlist1:
      newlist1.append(i)
      print('first',i)
      elif len(newlist1)==1:
      print(i+newlist1[0])
      newlist1.append(i)
      else:
      print(newlist1[len(newlist1)-1]+newlist1[len(newlist1)-2])
      newlist1.append(newlist1[len(newlist1)-1]+newlist1[len(newlist1)-2])

    • blank
      Dhans Raj
      May 10, 2022 15:30 pm Reply

      Great, thanks for the video

    • blank
      nishikanta mohanty
      May 10, 2022 15:30 pm Reply

      Thanks a lot for video. I refreshed so many concepts

    • blank
      Naveen Kumar G
      May 10, 2022 15:30 pm Reply

      last question:
      a='arrrbbb'
      b=''
      for i in a:
      if i not in b:
      b=b+i
      b

    • blank
      Amritanjan Thakur
      May 10, 2022 15:30 pm Reply

      But it said to write a function to sort not lib function..l.sort() is method of a list

    • blank
      Kamal Kishore Mahato
      May 10, 2022 15:30 pm Reply

      Sir …could u please tell me which compiler do u use here ??

    • blank
      Ad-knowledge
      May 10, 2022 15:30 pm Reply

      For SDE 1 role, can we use Python to solve

    • blank
      Shantanu Roy
      May 10, 2022 15:30 pm Reply

      List in reverse :
      for i in range(len(input_list)-1,-1,-1) :
      reverse_list.append(input_list[i])
      print(reverse_list)

    • blank
      bucciarati
      May 10, 2022 15:30 pm Reply

      Thanks! Great practice

    • blank
      esakkiya e
      May 10, 2022 15:30 pm Reply

      explain in 5th question sir… I understand logic of slice operations.. But output?

    • blank
      Sandesh Vora
      May 10, 2022 15:30 pm Reply

      3rd problem.. Variable name should be maximum.. Right?

    • blank
      Chintuc chintu
      May 10, 2022 15:30 pm Reply

      can you pls provide link for colab

    • blank
      Arun Kumar N
      May 10, 2022 15:30 pm Reply

      Q15:
      #given a string , return recurring characters and display new string

      s = 'mississippi'

      lst = []

      for i in s:

      if i not in lst:

      lst.append(i)

      newS = ''.join(lst)

      newS

      (or)

      #given a string , return recurring characters and display new string

      s = 'mississippi'

      setList = set()

      for i in s:

      setList.add(i)

      newS = ''.join(setList)

      newS

    • blank
      Ashwin Vijay
      May 10, 2022 15:30 pm Reply

      for x in range(1,101):
      if x % 10 in (1,3,5,7,9):
      print(x)

    • blank
      Vedant X-B
      May 10, 2022 15:30 pm Reply

      Thx for this video

    • blank
      Vaibhav Kulkarni
      May 10, 2022 15:30 pm Reply

      Osm Video bro

Leave us a comment