Комментарии:
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
Ответитьq1 better solution
for i in range(101,200):
if i %i==0:
print(i)
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).
I have worst youtupe channel this is ad distrub for me. Very Irrratiing
Ответить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]
Good one💯
Ответить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)
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)
Writ a program to extact the digit?
a="1w3er5t678"
b= list(filter(lambda i:i.isdigit(),a))
str="".join(b)
print(str)
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)
can u please share that google drive doc you have shown with answers
Ответить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 ?
PALINDROME
s = input()
if s[0:] == s[::-1]:
print("palindrome")
else:
print("not palidrome")
for Palindrome :
def palindrome(s):
return "Yes it is palindrome" if s[::-1].lower() ==s.lower() else "not a palindrome"
1st problom
For i in range (100,200):
If i%2==1:
Print(i)
It's also CRT or not??
You could just use this instead of the palindrome one:
def palindrome(word):
return word[::-1] == word
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 !!
Ответитьwhy in range is given (2, num) the range as been give from 100 -200;😏😏
ОтветитьQus 1:
for x in range(100,200,2):
print(x)
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..
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)
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.
ОтветитьVery very small letters.... Not visible at all.... Plz do lil bigger so that it will good for us to view
Ответить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.
Should we be using recursion for fibonacci?
ОтветитьDeveloper questions or production support questions?
Ответить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)
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)
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)
Tell me this is joke. No way somebody ask you this question on intervy for python junior developer jobs??
Ответить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:
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'
ОтветитьYour're not wasting anyone's time -- we all come here to learn so don't skip anything, no matter how minute it is.
Ответить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])
Great, thanks for the video
ОтветитьThanks a lot for video. I refreshed so many concepts
Ответитьlast question:
a='arrrbbb'
b=''
for i in a:
if i not in b:
b=b+i
b
But it said to write a function to sort not lib function..l.sort() is method of a list
ОтветитьSir ...could u please tell me which compiler do u use here ??
ОтветитьFor SDE 1 role, can we use Python to solve
ОтветитьList in reverse :
for i in range(len(input_list)-1,-1,-1) :
reverse_list.append(input_list[i])
print(reverse_list)
Thanks! Great practice
Ответитьexplain in 5th question sir... I understand logic of slice operations.. But output?
Ответить3rd problem.. Variable name should be maximum.. Right?
Ответитьcan you pls provide link for colab
Ответитьfor x in range(1,101):
if x % 10 in (1,3,5,7,9):
print(x)