While Loops - Intro to Computer Science

  Рет қаралды 229,947

Udacity

Udacity

Күн бұрын

Пікірлер: 113
@yesserlabidi7831
@yesserlabidi7831 4 жыл бұрын
this is the best explanation ever of while loop !! thank you sir !
@NigerianxPrince
@NigerianxPrince 2 жыл бұрын
I swear this is the best explanation I have seen for a while loop I really understand it so now I can write a code with this understanding.
@shazrakhalid1641
@shazrakhalid1641 4 жыл бұрын
I WAS STUCK ON THIS FOREVER!!! THANK YOU!!!
@brucewayne3141
@brucewayne3141 4 жыл бұрын
This is so much better than the way my instructor told us!
@serdarkaraca9172
@serdarkaraca9172 4 жыл бұрын
The first "i" is equal to 0 (i = 0). But, before it gets printed it goes through the equation of i = i + 1 so the first i that gets printed is 1. Now at the i = 8 mark it goes through the equation i = i+1 (before getting printed) and gets printed out as 9. Then 9 != 10 goes through and gets printed as (the last number) 10. Then when 10 goes through it becomes 10 != 10 WHICH IS FALSE so ends the while loop. as printed (1,2,3,4,5,6,7,8,9,10). D - "Print out the numbers from 1 to 10"
@nickri7352
@nickri7352 3 жыл бұрын
Very detailed explanation
@chaitanyakishore2150
@chaitanyakishore2150 3 жыл бұрын
This is called a mind opening explanation.🌼
@karolstevenvillacarillo1036
@karolstevenvillacarillo1036 3 жыл бұрын
wow
@Prince-jf1nb
@Prince-jf1nb 3 жыл бұрын
Wow thanks for the in-depth explanation
@tejasaditya551
@tejasaditya551 3 жыл бұрын
the value prints 1-10 if we put i=i+1 about print, can u explain why?
@doubleq1223
@doubleq1223 5 жыл бұрын
came here for loops brother, was bamboozled
@sayedibrahim6131
@sayedibrahim6131 3 жыл бұрын
one of the best explanations ever for while loop 🔁 ❤️ thanks
@suomynona7261
@suomynona7261 3 жыл бұрын
OMG you explained this so well! Thank you! I couldn’t wrap my head around WHY is was doing that. I knew how to control it by memory alone but not by understanding. 🙏
@venkatraman_padmanaban
@venkatraman_padmanaban 5 жыл бұрын
Print from 1 to 10 values and comes out of the loop
@rashulmehul5779
@rashulmehul5779 6 жыл бұрын
We want more videos of this loop programs
@bblife167
@bblife167 Жыл бұрын
i love you so much you saved me 100%. thanks a lot fr. youre a real one
@marctkocz1478
@marctkocz1478 Жыл бұрын
10/10 Really nice explained👌🏽 Thanks a lot
@demetrik8642
@demetrik8642 4 жыл бұрын
Absolutely beautiful
@mlittleprogramming780
@mlittleprogramming780 4 жыл бұрын
Great video!
@Septix
@Septix 7 жыл бұрын
Actual answer is 1-10: Option 4. The reason it stops at 10 instead of 9 now is because it's checking... is i = 10 yet? once it says YES then we exit the loop. The loop terminates RIGHT there because it reached its goal which is 10. Only part i don't get is why it does not start at 0 to 10... why 1.
@cobain1228
@cobain1228 7 жыл бұрын
It starts at 0, but then in the block i=0+1, so i has a new value of 1, and finally print i that is equal to 1.
@williamngwaihow
@williamngwaihow 7 жыл бұрын
i = 0 while(i != 10): i = i + 1 print("i =", i) print("Exit Loop") Phython
@stannisbarracuda5693
@stannisbarracuda5693 6 жыл бұрын
it writes from zero and ends at 9 it would write 10 if the parameter was
@jamesclarity1077
@jamesclarity1077 6 жыл бұрын
@@stannisbarracuda5693 exactly that's what I was thinking... != In Python to the best of my knowledge is does NOT equal....so should have exited.... However my Python emulator is showing 10 too.
@jamesclarity1077
@jamesclarity1077 6 жыл бұрын
Scratch that....just gave this more thought think a little longer...
@aybin.v.k9562
@aybin.v.k9562 7 жыл бұрын
Thanks for comparing While and if....... can we use colon instead of parenthesis in WHILE ??? Semicolon after printf() is missing
@damiaobrito6431
@damiaobrito6431 7 жыл бұрын
AYBIN. V. K it will always depend on what programming language you are using EDIT: as I can see, his code sample is based on Python
@artursweden3653
@artursweden3653 Жыл бұрын
A perfect explanation
@LukeJosiahNadal
@LukeJosiahNadal 6 жыл бұрын
i = 0 while i is not equal to 10 i = i +1 print i is i not equal to 10? ( i = 0) Yes, the program ends until it keeps adding the value 1 to the variable i until it defies the while condition, repeating the while loop 9 times until "not equal to 10" becomes "equal to 10". Thank me later
@iztirabk5135
@iztirabk5135 4 жыл бұрын
true, same point noted here
@shivagaming5001
@shivagaming5001 4 жыл бұрын
Word I noticed that but I'm just getting into it so I think it's still helpful. I would say this is an example of debugging because how he wrote it the program would print before any addition
@YoshevElazarMikael
@YoshevElazarMikael 2 жыл бұрын
If 'i' is < 10, why would it print? While 'i' is less than 10, then the programme prints a value.
@punjab6044
@punjab6044 3 ай бұрын
Thank you 🎊
@abubekirlenty8854
@abubekirlenty8854 2 жыл бұрын
well done! thank you!
@indiaupbanda
@indiaupbanda 3 жыл бұрын
Simplest way.... Thank you so much
@minitaz3167
@minitaz3167 6 жыл бұрын
Option d is correct
@3372PHILIP
@3372PHILIP 6 жыл бұрын
Excellent explaination keep it up
@stutteringcris468
@stutteringcris468 3 жыл бұрын
i keep getting "invalid syntax" and the 3 keeps getting highlighted in the top "python 3.9.0"
@YoshevElazarMikael
@YoshevElazarMikael 2 жыл бұрын
Thank you sir!!!
@amf2702
@amf2702 6 жыл бұрын
The answer is that the program prints out the numbers from 1 to 10
@benzox9940
@benzox9940 4 жыл бұрын
Im stuck on this, Do you know why? And whats the difference when the addition follows the print?
@amf2702
@amf2702 4 жыл бұрын
@@benzox9940 bruh I forgot how it works, this was two years ago..
@dazza1080
@dazza1080 4 жыл бұрын
😂😂😂😂
@sphollo1
@sphollo1 4 жыл бұрын
@@benzox9940 its all about the sequence, having the i + 1 before the print command added 1 to the i value prior to it printing, so it started printing numbers starting with 1 then restarted the while loop and printed the numbers 1 to 10. If the i + 1 was after the print command it would have printed the number 0 then added 1 to i and restarted the while loop and printed all numbers from 0-10.
@abdullah3lshe77i8
@abdullah3lshe77i8 5 жыл бұрын
THANK YOU SO MUCH BRO
@harryneuhoff9115
@harryneuhoff9115 2 жыл бұрын
What language is this in??
@cancan740
@cancan740 4 жыл бұрын
very good explanation
@HamzaShahzad1
@HamzaShahzad1 5 жыл бұрын
produces an error, there is no parentheses around the print statement
@ivanjudiao245
@ivanjudiao245 3 жыл бұрын
Yeah
@avivpizanty8384
@avivpizanty8384 3 жыл бұрын
what pen did you use? and where you wrote it?
@isaloy_2375
@isaloy_2375 4 жыл бұрын
it does print 1 to 9 doesn't it ?
@anushkapandey8588
@anushkapandey8588 4 жыл бұрын
Is it 3) 1 to 9? Cause it'll only print after the initial value of i (0) is added to the operation *i = i + 1* And it also satisfies the condition that i ≠ 10
@JackM12345100
@JackM12345100 4 жыл бұрын
Remember that when the final loop begins when i=9 the condition is met (i is less than 10). Then the i is changed to 10 before i is printed, so this program would print 1 - 10.
@nomteemzee3540
@nomteemzee3540 2 жыл бұрын
what happens if you remove the condition of i= i +1
@m26k29
@m26k29 2 жыл бұрын
infintiiy loop will go on and prints 0 for infintiiy
@m26k29
@m26k29 2 жыл бұрын
@هه‍هههههههههههههه مصرى
@YoshevElazarMikael
@YoshevElazarMikael 2 жыл бұрын
I was given an example: n = 5 while n > 0: n = n - 1 print(n) 4 3 2 1 0 From this result: it is clear that the layout in the body is wrong; the 'print()' statement should go first.
@stephenkite399
@stephenkite399 4 жыл бұрын
Ok so I just got started in coding. My problem is i don’t understand where to execute my code. Is it supposed to work in the console? I’m using google chrome and I could really use someone’s help.
@ScholarDCareerSolutions
@ScholarDCareerSolutions 4 жыл бұрын
you can watch this video.. kzbin.info/www/bejne/ZonEnnxnjJKqsKc
@vishalkatraj
@vishalkatraj 4 жыл бұрын
thank you
@WJGSix
@WJGSix 5 жыл бұрын
Ok so who had the right answer? I felt like it was 1 to 10
@ashwinv5219
@ashwinv5219 5 жыл бұрын
It's 0 to 9
@keeshaholsey1973
@keeshaholsey1973 7 жыл бұрын
love it
@denvd.b8559
@denvd.b8559 7 жыл бұрын
there is no semilcolon in while( parenthesis)😐😐😐😐
@damiaobrito6431
@damiaobrito6431 7 жыл бұрын
diwakar bangera there is in Python programming language
@azeemsiddiqui3853
@azeemsiddiqui3853 4 жыл бұрын
It will produce error since the test expression is not true. So the block will also not be executed. Numbers are only incrementing if the test expression is true only.
@layanalkhatib6486
@layanalkhatib6486 4 жыл бұрын
i used Small Basic program and my answer was : {print out the numbers from 0 to 9}.
@billygruff6541
@billygruff6541 6 жыл бұрын
0-9 ... sorry I took so long to comment.. I'm still on dial-up
@hibakhawaja9590
@hibakhawaja9590 5 жыл бұрын
HOW?
@HJ-jl5pj
@HJ-jl5pj 8 жыл бұрын
is the answer the third option?
@bellagutierrez5194
@bellagutierrez5194 6 жыл бұрын
H J it will print numbers 1-10 then exit the loop. Nine is not equivalent to ten so it will go through the loop one more time
@keeshaholsey1973
@keeshaholsey1973 7 жыл бұрын
so cool
@ericplayer4203
@ericplayer4203 8 жыл бұрын
it is an error right?
@joojok72
@joojok72 4 жыл бұрын
option d
@mohammadkhader1759
@mohammadkhader1759 6 жыл бұрын
it will run forever , because its going to print all numpers but ten , >>>>>>1 2 3 4 5 6 7 8 9 11 12 13 .....
@TheAbsoluteSir
@TheAbsoluteSir 4 жыл бұрын
Wrong, you misunderstand how iteration works.
@jess6241
@jess6241 3 жыл бұрын
doesnt it stop once y does not equal 10?
@abhisekchetri3136
@abhisekchetri3136 5 жыл бұрын
X=1 Whilex
@floatiee
@floatiee 2 жыл бұрын
D - Print out the numbers from 1 to 10
@chidex968
@chidex968 5 жыл бұрын
option 2
@GhostRiderX7
@GhostRiderX7 6 жыл бұрын
The answer is Run forever
@AS-od4um
@AS-od4um 5 жыл бұрын
Techie Tom no if the value of i is 10 So it will be 10 ! = 10 the statement will be false
@srilanka55290
@srilanka55290 3 жыл бұрын
The answer is for your quiz = 1 2 3 4 5 6 7 8 9 10 Thank you from Sri Lanka❤❤❤
@artistalreem1180
@artistalreem1180 6 жыл бұрын
heloo any one can help me to solve this program Write a C++ programme that reads a sequence of integers terminated by zero value then finds the percentage of the negative numbers and the percentage of the positive number in the sequence. The programme output is as shown: : Enter a sequence of in integers terminated by zero 6 -7 -8 10 -12 14 15 2 -6 the percentage of negative numbers is 44.4 the percentage of positive numbers is 55.6
@ripndipp
@ripndipp 5 жыл бұрын
let a = "Hello, "; let b = "World"; let c = a + b console.log(c); thank me later this is the best i could do.
@walitouseef9751
@walitouseef9751 7 жыл бұрын
Maybe runs forever
@phuturephunk
@phuturephunk 7 жыл бұрын
In his last example (the question at the end), it will print 1 through 10 and then exit the loop.
@mohammadkhader1759
@mohammadkhader1759 6 жыл бұрын
@@phuturephunk because it was asked to print all numpers that are less than ten , this question is diffrant , it askes for all numpers that does not equal ten ( 1 2 3 4 5 6 7 8 9 _ 11 12 13 ....)
@iliyasgangaram3134
@iliyasgangaram3134 4 жыл бұрын
it prints 1 to 10
@devika389
@devika389 4 жыл бұрын
writing with a pen ......but not really..........my heads' spinning
@hanaasleem1261
@hanaasleem1261 4 жыл бұрын
from 0 to 9 (b)
@AhmedSedik
@AhmedSedik 6 жыл бұрын
prints from 0-10
@felixnyarko7828
@felixnyarko7828 6 жыл бұрын
Answer is 1-10: Option 4
@TheAbsoluteSir
@TheAbsoluteSir 4 жыл бұрын
Why would it not be B) 0-9 ? The previous while loop went from 0 through 9.
@nofilkhan6743
@nofilkhan6743 6 жыл бұрын
Answer is 1 to 10
@vincenthan5980
@vincenthan5980 8 жыл бұрын
nb
@hydos3807
@hydos3807 4 жыл бұрын
For while loop or statement click on the link kzbin.info/www/bejne/emjNYoyNqKhna6s
@ilikespaghetti2170
@ilikespaghetti2170 4 жыл бұрын
1-10
@aryamangurha
@aryamangurha 6 жыл бұрын
lol u just made it unnecessarily complecated... For printing *"Ben"* 10 times in a loop: 10 FOR i = 1 to 10 20 PRINT "Ben" 30 NEXT i 40 END
@mustufashadab8201
@mustufashadab8201 5 жыл бұрын
Stupid he was teaching while loop not for loop
@MojeZycieWSkrocie
@MojeZycieWSkrocie 5 жыл бұрын
try i = 11 lol
@devika389
@devika389 4 жыл бұрын
writing technique is soo distracting...............
@ScholarDCareerSolutions
@ScholarDCareerSolutions 4 жыл бұрын
Try watching this video to understand loops.. kzbin.info/www/bejne/ZonEnnxnjJKqsKc
@karolstevenvillacarillo1036
@karolstevenvillacarillo1036 3 жыл бұрын
hmmmmmm
@ameanasaur
@ameanasaur 5 жыл бұрын
Great video but your hands distract from everything. We don’t need to see your hand writing it, we need to see the code. Also, use white font on a black background like anyone who stares at a screen for 8+ hours a day does, can’t watch this after a day of work + school.
@roidviapulsa
@roidviapulsa Жыл бұрын
very good explanation
While Loops Solution - Intro to Computer Science
1:33
Udacity
Рет қаралды 18 М.
While loops in Python are easy ♾️
6:58
Bro Code
Рет қаралды 449 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН
人是不能做到吗?#火影忍者 #家人  #佐助
00:20
火影忍者一家
Рет қаралды 20 МЛН
We Attempted The Impossible 😱
00:54
Topper Guild
Рет қаралды 56 МЛН
6.1: While Loop - Processing Tutorial
11:15
The Coding Train
Рет қаралды 217 М.
you will never ask about pointers again after watching this video
8:03
for and while Loops
6:49
Neso Academy
Рет қаралды 768 М.
Computer Science Basics: Sequences, Selections, and Loops
2:27
LearnFree
Рет қаралды 336 М.
WHY IS THE HEAP SO SLOW?
17:53
Core Dumped
Рет қаралды 295 М.
Learn JavaScript WHILE LOOPS in 8 minutes! 🔁
8:12
Bro Code
Рет қаралды 40 М.
99.9% IMPOSSIBLE
00:24
STORROR
Рет қаралды 31 МЛН