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

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

BharatiDWConsultancy

4 года назад

258,442 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

safa khan
safa khan - 12.02.2023 23:14

In 3 it seems he copied the code... the minumum should be maximum for the problem he is trying to solve but good stuff overall for quick revision

Ответить
Meme Line
Meme Line - 12.02.2023 11:47

q1 better solution
for i in range(101,200):
if i %i==0:
print(i)

Ответить
Vikrant singh
Vikrant singh - 01.02.2023 16:19

9).Solution

def Search (arr,x):

for i in range(len(arr)):
if arr[i]==x:
return arr[i]
print('Sorry This element is not Given in this array')
list1=[1,2,3,4,5,6,7,8,9,10]
Search(list1,10)

Pardon Sir,
if we can use this code for Solution (9). So that will give us the actual Values that are in the given array. instead of using iloc (Index Location).

Ответить
raja
raja - 26.01.2023 07:00

I have worst youtupe channel this is ad distrub for me. Very Irrratiing

Ответить
Sachin Chandanshiv
Sachin Chandanshiv - 21.12.2022 13:28

Hi Sir,
In below code not getting how, lst1 is appended with element 6 when we are appending only lst2 only.
Can you please Clarify, Thanks

lst1=[1,2,3,4,5]
lst2=lst1
lst2.append(6)
print('lst1- ',lst1)
print('lst2- ',lst2)

Output-
lst1- [1, 2, 3, 4, 5, 6]
lst2- [1, 2, 3, 4, 5, 6]

Ответить
 Evans Ndoro
Evans Ndoro - 04.11.2022 11:27

Good one💯

Ответить
Swetha Dharmappa
Swetha Dharmappa - 26.10.2022 15:12

Last problem can be solved as below:
s="missisippi"
list1=[]

for i in s:
if (i not in list1) or (i==' '):
list1.append(i)

new_s=''.join(list1)
print(new_s)

Ответить
Rohan Kumara
Rohan Kumara - 18.10.2022 19:23

1.
for i in range(100,201):
y = []
for x in range(2,12):
if i%x == 0:
y.append(1)
else:
y.append(0)
if sum(y)==0:
print("prime number ",i)

Ответить
sangeetha k
sangeetha k - 26.09.2022 14:14

Writ a program to extact the digit?
a="1w3er5t678"
b= list(filter(lambda i:i.isdigit(),a))
str="".join(b)
print(str)

Ответить
BYRE GOWDA M
BYRE GOWDA M - 11.07.2022 13:33

Question no :- 3
data_list = [25, 55, 78, 64, 25, 12, 22, 11, 1, 2, 44, 3, 122, 23, 34]
for i in range( 0,len(data_list ):
for j in range (i+1,,len(data_list)):
if data_list[ i ] > data_list[ j ] :
data_list[ i ] , data_list[ j ]=data_list[ j ] , data_list[ i ]
print(data_list)

Ответить
Mahender Tirumala
Mahender Tirumala - 01.07.2022 10:45

can u please share that google drive doc you have shown with answers

Ответить
saikat ghosh
saikat ghosh - 29.06.2022 19:06

q.5>

li = [1, 2, 3, 4, 5, 6, 7, 8, 100]
l = li[::-1]
print(l)

this is also show same result ..is that right ?

Ответить
Pranjal Sharma
Pranjal Sharma - 27.06.2022 12:41

PALINDROME

s = input()
if s[0:] == s[::-1]:
print("palindrome")
else:
print("not palidrome")

Ответить
Human Helper Organization
Human Helper Organization - 26.06.2022 06:57

for Palindrome :
def palindrome(s):
return "Yes it is palindrome" if s[::-1].lower() ==s.lower() else "not a palindrome"

Ответить
Manikandan S
Manikandan S - 18.06.2022 10:37

1st problom
For i in range (100,200):
If i%2==1:
Print(i)
It's also CRT or not??

Ответить
monicka
monicka - 09.06.2022 23:26

You could just use this instead of the palindrome one:
def palindrome(word):
return word[::-1] == word

Ответить
Ravish Khullar
Ravish Khullar - 01.06.2022 11:50

In 3rd question, it should have been maximum instead of minimum as if x>minimum, minimum should not be equal to x. Please correct me if I am wrong guys !!

Ответить
Kartik Dayal
Kartik Dayal - 27.05.2022 11:10

why in range is given (2, num) the range as been give from 100 -200;😏😏

Ответить
Nikunj Rana
Nikunj Rana - 06.05.2022 01:58

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

Ответить
Manan
Manan - 21.04.2022 05:06

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..

Ответить
EveryThinG
EveryThinG - 06.04.2022 17:16

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)

Ответить
romkainmotion
romkainmotion - 05.04.2022 21:24

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.

Ответить
Ammuvideos
Ammuvideos - 28.02.2022 10:25

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

Ответить
Vedantha S M
Vedantha S M - 19.02.2022 08:15

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.

Ответить
Nikhil Noona
Nikhil Noona - 19.01.2022 03:29

Should we be using recursion for fibonacci?

Ответить
Suraj Sahoo
Suraj Sahoo - 07.01.2022 03:18

Developer questions or production support questions?

Ответить
Prathamesh Vaidya
Prathamesh Vaidya - 20.12.2021 19:35

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)

Ответить
Enes Uğuroğlu
Enes Uğuroğlu - 19.12.2021 16:37

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)

Ответить
ReflectingMe
ReflectingMe - 22.11.2021 14:22

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)

Ответить
100daychallange
100daychallange - 18.11.2021 09:02

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

Ответить
swapnil walavalkar
swapnil walavalkar - 12.11.2021 08:12

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:

Ответить
Kasinder
Kasinder - 04.11.2021 21:56

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 program\n'

Ответить
babu sartop
babu sartop - 28.10.2021 00:06

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

Ответить
Dhans Raj
Dhans Raj - 15.10.2021 00:31

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])

Ответить
Dhans Raj
Dhans Raj - 14.10.2021 13:46

Great, thanks for the video

Ответить
nishikanta mohanty
nishikanta mohanty - 26.08.2021 05:19

Thanks a lot for video. I refreshed so many concepts

Ответить
Naveen Kumar G
Naveen Kumar G - 21.08.2021 15:14

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

Ответить
Amritanjan Thakur
Amritanjan Thakur - 09.08.2021 11:49

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

Ответить
Kamal Kishore Mahato
Kamal Kishore Mahato - 16.07.2021 18:58

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

Ответить
Ad-knowledge
Ad-knowledge - 01.07.2021 16:43

For SDE 1 role, can we use Python to solve

Ответить
Shantanu Roy
Shantanu Roy - 11.06.2021 17:16

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

Ответить
bucciarati
bucciarati - 11.05.2021 02:48

Thanks! Great practice

Ответить
esakkiya e
esakkiya e - 07.04.2021 19:59

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

Ответить
AI World
AI World - 07.03.2021 00:00

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

Ответить
Chintuc chintu
Chintuc chintu - 01.03.2021 18:04

can you pls provide link for colab

Ответить
Ashwin Vijay
Ashwin Vijay - 30.01.2021 08:28

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

Ответить