Tutorial on nested loops

  Рет қаралды 37,048

IIT Madras - B.S. Degree Programme

IIT Madras - B.S. Degree Programme

Күн бұрын

Пікірлер: 23
@Viswesh
@Viswesh 3 жыл бұрын
First example is made very complex. This code will be simple. n=int(input("Enter number: ")) for i in range(2,n): flag=True for j in range(2,i): if i%j==0: flag=False break if flag: print(i) It could be made even simpler by using else block to the inner for loop, thereby eliminating the need for a Flag variable.
@nandarajan384
@nandarajan384 2 жыл бұрын
Thank you.
@alexioscarlos7727
@alexioscarlos7727 11 ай бұрын
I think this code is wrong bcoz n==2 then it would make flag false which is not true
@MUTHU_KRISHNAN_K
@MUTHU_KRISHNAN_K 7 ай бұрын
​@@alexioscarlos7727for n==2 , nothing should be printed, right?since there is no prime number lesser than 2.
@TEJASWAnama0
@TEJASWAnama0 3 ай бұрын
I think you forgot to mention the end=' ' in the program according to above same output
@smokyvibes
@smokyvibes Күн бұрын
much better if you check until root(i) since after thats its just gonna be multiple of them.
@avenumadhav3568
@avenumadhav3568 3 жыл бұрын
#1: 1:50 #2: 7:45 #3: 12:30 #4: 17:00
@tanmaymalviya5312
@tanmaymalviya5312 Жыл бұрын
I understand this is tutorial still they should show him type while explaining what's the logic, instead of directly taking us to the screen with already typed code
@aryangarg7359
@aryangarg7359 Жыл бұрын
thats the whole dissapointment actually, there are many a times they have missed explaining important things like flag where to use when to use , just teaching like a novel story.
@rockstrsameer17
@rockstrsameer17 3 жыл бұрын
Coming soon to iit
@Adityakumar-pn7yq
@Adityakumar-pn7yq 3 ай бұрын
this my code sample example num= int(input()) prime= 0 for i in range(2, num): for j in range(1, i): if j!= 1 and i%j == 0: break if j== i-1: print(i, end= " ")
@rituparnodhar6265
@rituparnodhar6265 2 жыл бұрын
20:17 in test case 5 , we don't have input -1 in the statement but in the code You have given.
@RohitRajSharma-kh6iu
@RohitRajSharma-kh6iu 3 ай бұрын
I think that is a printing mistake in the statements
@ManishKumar-qr4hb
@ManishKumar-qr4hb 7 ай бұрын
I don't know why.... but i feel this lecture little harder
@selvamselvam7960
@selvamselvam7960 2 жыл бұрын
What is the use of flag function true false anyone let me explain plz
@aryangarg7359
@aryangarg7359 Жыл бұрын
thats the whole dissapointment actually, there are many a times they have missed explaining important things like flag where to use when to use , just teaching like a novel story.
@MUTHU_KRISHNAN_K
@MUTHU_KRISHNAN_K 7 ай бұрын
I believe,by now,you would have no doubt on this topic.but,it may help someone else:😊 Reason for flag It's actually a more professional way, maybe,I don't know.its job is to hold 'false' if the number is not prime and to possess 'true' if the number is prime. It's usage can be completely eliminated,by using 'print' statement directly under 'else' condition 🙂👍
@054_nirajkumar3
@054_nirajkumar3 3 жыл бұрын
थैंक्यू
@sayanghosh6996
@sayanghosh6996 3 жыл бұрын
for these conditions a do-while statement is better suited. shame that python doesnt have it though 😔
@MUTHU_KRISHNAN_K
@MUTHU_KRISHNAN_K 7 ай бұрын
Is it sir?😮 I am on the initial weeks and not aware of this. Btw,you may know me from Linux course Jan 2024 term.electronic systems😀
@sayanghosh6996
@sayanghosh6996 3 жыл бұрын
Optimal playback speed for this video: 4x 😂 (for me)
@TheUnknownU
@TheUnknownU 3 жыл бұрын
#find all prime numbers less than entered number num = int(input('Enter the number: ')) if(num>2): print(2,end=" ") for i in range(3, num): if i % 2 != 0: print(i, end = " ", sep = "-")
@nikulpd8137
@nikulpd8137 Жыл бұрын
its wrong
break, continue and pass
12:58
IIT Madras - B.S. Degree Programme
Рет қаралды 30 М.
Tutorial on while loop
28:11
IIT Madras - B.S. Degree Programme
Рет қаралды 53 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН
Cheerleader Transformation That Left Everyone Speechless! #shorts
00:27
Fabiosa Best Lifehacks
Рет қаралды 16 МЛН
Enceinte et en Bazard: Les Chroniques du Nettoyage ! 🚽✨
00:21
Two More French
Рет қаралды 42 МЛН
Quando A Diferença De Altura É Muito Grande 😲😂
00:12
Mari Maria
Рет қаралды 45 МЛН
Nested loops in Python are easy ➿
5:35
Bro Code
Рет қаралды 362 М.
Nested for loop
10:39
IIT Madras - B.S. Degree Programme
Рет қаралды 30 М.
Birthday Paradox
25:39
IIT Madras - B.S. Degree Programme
Рет қаралды 40 М.
Nested for Loop in Python
9:29
Neso Academy
Рет қаралды 32 М.
Transformers (how LLMs work) explained visually | DL5
27:14
3Blue1Brown
Рет қаралды 4,5 МЛН
Tutorial on for loop and difference between while loop and for loop
20:15
IIT Madras - B.S. Degree Programme
Рет қаралды 38 М.
Lists and Sets
28:05
IIT Madras - B.S. Degree Programme
Рет қаралды 37 М.
SQLite Databases With Python - Full Course
1:29:37
freeCodeCamp.org
Рет қаралды 702 М.
Let's code a beginner Python BANKING PROGRAM 💰
15:01
Bro Code
Рет қаралды 342 М.
Правильный подход к детям
00:18
Beatrise
Рет қаралды 11 МЛН