Python Tutorial 13: Understanding Python While Loops

  Рет қаралды 20,144

Paul McWhorter

Paul McWhorter

3 жыл бұрын

You guys can help me out over at Patreon, and that will help me keep my gear updated, and help me keep this quality content coming:
/ paulmcwhorter
In this video we show step-by-step instructions on how to understand and use python while loops. I do not assume you are an expert, so these lessons are designed for complete beginners.
#Python
#Lessons
#Programming

Пікірлер: 233
@chethantb500
@chethantb500 3 жыл бұрын
I did watch your Ardiuno , Raspberry Pi, and little bit AI on Jetson series... Being Electronics student everything what you are doing is helping me a lot... Even I did my college project using your series..."Attendance system using face recognition on Raspberry Pi".....indeed yor are lifting us up.. Huge respect towards you sir Thanks a lot....🤩
@pauivorra1819
@pauivorra1819 3 жыл бұрын
I am legend, despite this homework was easier than other ones.
@kck.Schrodinger13
@kck.Schrodinger13 2 жыл бұрын
I AM FINALLY LEGEND after a losing streak! Having so much fun with these lessons.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Nice work!
@opalprestonshirley1700
@opalprestonshirley1700 3 жыл бұрын
Got it, Paul, I am legend. Enjoyed the lesson. Looking forward to reading and writing files. Have a great week.
@amayaphotos8016
@amayaphotos8016 Жыл бұрын
I AM A LEGEND I got this one correct & yeah it was a bit easy.Got to mention that your homework assignments are really helpful. Thank you for sharing your knowledge with us
@johnplowright6421
@johnplowright6421 2 жыл бұрын
I just wanted to add, I am really enjoying these lessons, with the tools you have given so far, I wrote my own little program to collect and sort two data sets for a string input and then an associated value in no particular order until the user types exit, then it sorts the data by the value and re-orders both data sets to finally print the string against its value from highest to lowest. Of course I made mistakes but the joy of fixing these and seeing the program do what you wanted it to do is great.
@sudhanshupawar8760
@sudhanshupawar8760 2 жыл бұрын
i used to hate programming before i started watching your tutorials...you really make programming fun
@426F6F
@426F6F 8 ай бұрын
I got my while loop to print the index from the beginning to the end of the array, and then print from the end back to the beginning! Counting backward requires a bit of manipulating the variables and changing the addition operator, but it was pretty simple. Another awesome lesson Paul!
@OzdemirCem
@OzdemirCem 3 жыл бұрын
Paul's words are really understandable. Congratulations. Doing homework is very important. The code is not written without encountering the problem.
@MrElFRanz
@MrElFRanz 3 жыл бұрын
Hello Paul, I completed the while homework, this one was easier than the last one, for which I needed hours. I could do the while homework in minutes. Thanks for your marvellous lessons.
@mohsenr4434
@mohsenr4434 2 жыл бұрын
I did the homework and debugged it on my own. Good lesson as always, thanks.
@pralaymajumdar1206
@pralaymajumdar1206 3 жыл бұрын
Very knowledgeable and inspirational lecture... Thank you sir and waiting for the next week.
@alfredcalleja450
@alfredcalleja450 Жыл бұрын
Hi Paul, in my version of this coding I used i and j for each of the loops and set my i counter to start at 0 and the j counter to start at 1 in the appropriate parts of the code: it all worked well. Thanks for another interesting and informative tutorial.
@cbrombaugh
@cbrombaugh 3 жыл бұрын
I AM LEGEND! it seemed easier than the for exercises. Looking forward to catching up to current lesson. Again, thanks for the most excellent courses, Paul.
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
You're very welcome!
@tejkhanvilkar5743
@tejkhanvilkar5743 3 жыл бұрын
​really appreciate your video one more amazing lesson Thanks Paul
@hojosa4592
@hojosa4592 2 жыл бұрын
I managed to do this assignment, I was preety weary at first seeing as I orginally struggled on for loops initially however now I feel like I have a grasp on the concept before moving on to this lesson so I understood it preety easily when boiled down it is just a different way to format for loop (but in my opinion easier) one thing I did learn though (mostly from me never doing it is knowing you could re apply a variable (in this case j) mid code in my code I just made a new variable for the 2nd while loop really enjoying this series thank you sir!
@martinlewis645
@martinlewis645 2 жыл бұрын
I'm back after a nice Spring/Summer break and I Am Legend! Thank you Paul.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Welcome back!
@SaffatUllah
@SaffatUllah Жыл бұрын
You're a legend, Paul! You make programming so much fun! Thank you very much!
@paulmcwhorter
@paulmcwhorter Жыл бұрын
My pleasure!
@samthelegoman7593
@samthelegoman7593 3 жыл бұрын
Hey Paul! I am legend!! I did the homework slightly differently than you did. In order to break the "asking for grades" while loop, every time, the program would check if the input was "break", and if so, it broke the loop. Thank you so much for all of your amazing lessons Paul, I can't wait for the Arduino with Python lessons!
@dawidstawowy6474
@dawidstawowy6474 2 жыл бұрын
I'm legend. It took me 2 minutes to figure out this homework, probably because previous one took me 6 hours, but I couldn't even imagine that i'm folding up like a cheap Walmart chair!. Thank You unce Paul for this incredible new tutorial series!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Nice job!
@ModernDayWanderlust
@ModernDayWanderlust 2 жыл бұрын
Legend. I was able to do the assignment in about ten minutes once I got past the initial "...how do I make this work" brainstorming phase.
@yousraabdullah3054
@yousraabdullah3054 2 жыл бұрын
Ugrades = int(input('How Many Grades You Have? ')) gradeslist = [] g = 0 p = 0 while g in range(0, Ugrades, 1): grades = float(input("please Enter Your grades Don't Be Shy : ")) g += 1 gradeslist.append(grades) print('') print('You grades Are: ') print('') while p in range(0, Ugrades,1): print(gradeslist[p]) p += 1 I used another variable (p) to store and print the grades I was mad that It didn't work thou I used the increment But when I saw you work I knew my wrong. Thanks for the Lessons Mr Paul
@davidschnider1297
@davidschnider1297 Жыл бұрын
Thanks, Paul.. another GREAT lesson.. increasing my Python skills... looking forward to what's next.. .God bless..
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Excellent!
@petefontana1958
@petefontana1958 2 жыл бұрын
I am legend. Definitely easier than the sort homework. Doing Python tutorials while I am waiting for my Raspberry Pi to come in. Keep up the good work. Will start 14 tomorrow.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
The sort, and then the toggle button switch upcoming on my raspberry pi lessons are two classic problems that are very challenging. Simple in concept yet challenging to make work. The key on both is to sketch it out on paper first. When you have a method sketched on paper it is then easy to code up.
@alexgordon9795
@alexgordon9795 2 жыл бұрын
Thanks to you Paul, I am legend! This was much easier then the for loops!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Glad it helped!
@LegoYobo
@LegoYobo 3 жыл бұрын
your explanation is very easy and nice
@shuttlepodone1707
@shuttlepodone1707 3 жыл бұрын
I am legend! Took a break and then it came to me while doing dishes. Funny how that works.
@bola5671
@bola5671 Ай бұрын
while loop came back "while" doing dishes? Haha
@danielduplessis7221
@danielduplessis7221 2 жыл бұрын
I Am Legend. Thank You Mr. Paul for Your Help and Encouragement.
@typicalcookies8123
@typicalcookies8123 Жыл бұрын
Thankyou so much for posting these ,you are excellent at conveying messages! I completed the homework quite fast using this code instead nu-int (input ('how many scores do you have?:')) Lt=[] while (0
@chknnoodlz3547
@chknnoodlz3547 3 жыл бұрын
Paul, I think you need to up your game, I haven't yet died trying to learn python, I have been a legend. For real though Paul you are an amazing teacher without your help I wouldn't be learning python this fast.
@markhouston2537
@markhouston2537 2 жыл бұрын
Dear Paul, You are our Huckleberry and for this and your most excellent Python course i have hooked a brother up. Now i'm off to learn more python or die trying.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Thanks, Mark, I appreciate it.
@johnplowright6421
@johnplowright6421 2 жыл бұрын
Got ahead of myself and went for adding two while loops into the grade sorting program from previous lesson, at first though because I used the same global variable the second while loop was already at the end of the count, easy fix but the debugging is the best bit. Oh now I watched the rest of the video you show this same problem ha ha.
@atesotheater6536
@atesotheater6536 3 жыл бұрын
Thank you for the great 👍 lesson
@hughpatterson1480
@hughpatterson1480 2 жыл бұрын
Ha, I did it but I feel more like a Lazy Boy recliner than a legend. I prefer while loops because of the control factor. My students find them easier to use but you need to know all methods of achieving the same goal to truly understand the problem and it's solution. I had that initial problem that you had on the video, but realized that I did not tell the program to do what it was supposed to do in the second while loop. Thanks again for another great lesson to pass on to my students Paul!
@dmlmedia4665
@dmlmedia4665 3 жыл бұрын
You so great paul
@silver5970
@silver5970 3 жыл бұрын
I think the first exercise was pretty easy. I can't wait to the next lesson.
@kestergascoyne6924
@kestergascoyne6924 3 жыл бұрын
So helpful Paul. One day Ill be able to be a Patreon I hope, but for now, thank you.
@learningcode314
@learningcode314 3 жыл бұрын
Great video, Paul! Your lessons are the only ones that make me look forward to homework at the end of the video 😂
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Excellent!
@nikolas8741
@nikolas8741 3 жыл бұрын
Hey Paul Can you make video series about programming the DJI Tello Drone and make it fly itself
@Nyviv
@Nyviv 2 жыл бұрын
That would be intresting
@hassanniaz7583
@hassanniaz7583 2 жыл бұрын
I am a LEGEND. One more thing is that I did was that instead of writing j
@LiamAllbright
@LiamAllbright 7 ай бұрын
It is a crime that this great video doesn't have enough views or likes, it's a great video, and all of yours are. you make great work. Keep it up! Also, are there going to be more python tutorials, or are you done with it? I hope not. cause these videos are great.
@advancedperformance9721
@advancedperformance9721 2 жыл бұрын
Great love it
@rafaeloreirorodriguez5278
@rafaeloreirorodriguez5278 2 ай бұрын
Loving every tutorial, you surely deserve a nice premium coffee from South America Mr Mcworther.
@gautambiswas7338
@gautambiswas7338 2 жыл бұрын
Managed to do it.
@ishiandnothingelse
@ishiandnothingelse 3 ай бұрын
the way i work is by looking at the end result and then teaching myself how you got to the end result by applying the knowledge i learnt from your tutorial. i know it's technically cheating, but that's how my brain works, haha. thank you for teaching my coding and making it relatively easy for me to comprehend how it's supposed to work! much appreciated.
@kingofcastlechaos
@kingofcastlechaos Жыл бұрын
Good series. I did my best to get the exact same Python version you are using but could not find it. This small difference in version has given me SO MANY great learning opportunities as I try to follow along! The good part is that you are teaching me the framework and I am figuring it out from there. Happy accident I guess........(Will save a lot of money on haircuts, tore most of it out! lol)
@lakshmadaan8871
@lakshmadaan8871 2 жыл бұрын
Lovely video sir....I am Legend!!!
@thirupathaiah2981
@thirupathaiah2981 2 жыл бұрын
This is some while loop ➿ 🤩
@vaughntaylor2855
@vaughntaylor2855 2 жыл бұрын
The main difference in my first for loop was instead of using the in loop variable of 'grd' with input and appending that to the 'grades' list, I combines the append and in put in one line: grades.append(float(input('Enter a grade: '))). Great lesson Paul! Thank You!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Nice work!
@patfacunla1687
@patfacunla1687 2 жыл бұрын
I am legend! Thanks Paul !
@HanD_1964
@HanD_1964 3 жыл бұрын
Paul, do you teach us to use functions? I notice that this is necessary for a project that I am doing to keep an overview
@thebrector3823
@thebrector3823 2 жыл бұрын
IAM LEGEND, did in 5 mins, thanks to your Arduino tutorials I am familiar with while loops!!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Nice work!
@josegermanmolina3544
@josegermanmolina3544 2 жыл бұрын
That "pause pose" kills me 🤣🤣🤣🤣
@rachellebongalon7418
@rachellebongalon7418 3 жыл бұрын
Thank you so much!!!!!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
You're welcome!
@soteros1983
@soteros1983 2 жыл бұрын
I'm watching this series after the arduino, next I'm going to wach Raspberry Pi and the rest of Python! Paul is the best :D Do you ever going to make some tutorials for the Raspberry Pi Pico?? it would be very interesting as well! :D
@martinc9215
@martinc9215 Жыл бұрын
legend 🧑‍🎓
@mikekeller7342
@mikekeller7342 3 жыл бұрын
I am legend! Thanks Paul!!
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Yes you are!
@TheSudouser
@TheSudouser 2 жыл бұрын
Got it! No lawn chair folding this time!
@IlyesCodes
@IlyesCodes 2 жыл бұрын
best teacher
@shashibhandari6318
@shashibhandari6318 2 жыл бұрын
i am legend , loving it
@nikolas8741
@nikolas8741 3 жыл бұрын
Hey Paul Can you make video series about programming the DJI Tello Drone and make it fly itself
@manavt2000
@manavt2000 2 жыл бұрын
I'm a Legend for this lesson!!!!!!
@John-vw1wj
@John-vw1wj 3 жыл бұрын
I was starting to fold bad..Could feel my fingers pinching... Hadn't looked a Python for a few daze and was getting a syntax error on a print statement. I was missing a ")" on a previous line all is fine ...now..... I am legend
@kamwilliams9085
@kamwilliams9085 2 жыл бұрын
I folded Like a cheap walmart Lawn chair. I haven't been very successful with the homework these past few lessons unfortunately. I think I will come back to lessons 10-20 once I finish them and maybe I'll do a better job on the homework assignments.
@railcat7083
@railcat7083 2 жыл бұрын
Legendary...
@Mouse_007
@Mouse_007 2 жыл бұрын
I am Legend because you are a great teacher. Thank you.
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Thank you! 😃
@user-mn9gw1tr8y
@user-mn9gw1tr8y 6 ай бұрын
GOT IT,AFTER ALMOST 2 HOURS 🤭 Tgrades=float(input('How many grades do you have? ')) H=[] k=1 while k
@neilausten9404
@neilausten9404 3 жыл бұрын
If you can do this exercise with one while loop (which you can) wouldn't this be the preferred way to go?
@chalmerditmars7037
@chalmerditmars7037 Жыл бұрын
I forgot my j+1 and is there any way to stop that program without crashing the whole thing. I used alt control delete. That home work was easy.
@tiberiumihaescu5382
@tiberiumihaescu5382 2 жыл бұрын
Still a Legend!
@Fr0ug
@Fr0ug 2 жыл бұрын
I am legend. Awesome channel, love your cintent and coding. A quick question: do you have discord? There is a little discord icon under your coding during the video. :)
@handofash
@handofash 2 жыл бұрын
I tried a method to shortcut variable "j" by using numGrades value in the parameters instead. I got it to work, but I couldn't print it out in its proper list form. I guess you can't avoid a proper index number.
@jstro-hobbytech
@jstro-hobbytech 2 жыл бұрын
i never do while loops. in all my classes and personal projects ahha. thanks paul
@TheScissorunner
@TheScissorunner Жыл бұрын
I AM LEGENG! Using the print function to print every variable provides feedback for debugging!
@paulmcwhorter
@paulmcwhorter Жыл бұрын
LEGEND!
@snakesonthebrain
@snakesonthebrain 3 жыл бұрын
Let’s do it! Straight up black coffee!
@aungphyokyaw4475
@aungphyokyaw4475 3 күн бұрын
I was able to do it using only one while loop. for printing grades I just printed grades outside of the while loop.
@larryplatzek9017
@larryplatzek9017 3 жыл бұрын
I am legend! Did the homework as assigned A employer might not like changes unless was asked about change first!
@ShinesMonkey1
@ShinesMonkey1 3 жыл бұрын
IAL - Arduino series gave me a head start on a lot of this.
@yusufguler1662
@yusufguler1662 3 жыл бұрын
same
@drorlivneh4499
@drorlivneh4499 2 жыл бұрын
I made it, thank you!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Great job!
@dubrocadidier4583
@dubrocadidier4583 2 жыл бұрын
Legend
@codecage9333
@codecage9333 3 жыл бұрын
A day late and a dollar short, but I am legend! No cheap Walmart lawn chairs in this neck of the woods!!
@criptosauro4587
@criptosauro4587 Жыл бұрын
Why grades[j] = float(input("please write grade ")) Does not work?
@dzeykop
@dzeykop Жыл бұрын
Thank you for another great lesson, Sir! Your lessons are not wasted time (#NWT) for me and that is exactly what I want! 👍
@waleedaiad3411
@waleedaiad3411 2 жыл бұрын
How can i use hc-12 with arduino using python language?
@ProfQED
@ProfQED 2 жыл бұрын
I am Legend :) thanks dear Mr. McWhorter 😍😍
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
Legend!
@flhTK-2012
@flhTK-2012 2 жыл бұрын
One little hiccup with the index but solved it in a different way than the example. I decremented the index by1 in the print call. ------------------------ print('It is time to Count!') gradeCount=int(input('Enter the number of grades: ')) grades=[] g=1 while g
@charlielowell4077
@charlielowell4077 2 жыл бұрын
I did it! (and I didn't cheat ;-) ) Although, I admit, I forgot to increment the counter. Oops. Lesson learned. Thanks again!
@gabrielcmoran
@gabrielcmoran 3 жыл бұрын
Paul, I have a doubt about programming. I'm going to start mechanical engineering in the next semester. You think that programming is useful for this career? I know that a little about this stuff is taught during the course, but I want to know if I have to go further into programming. Sorry if my english is not that good, I'm brazilian and I have been studying your language since last year but I'm far from fluency yet.
@harshjee4134
@harshjee4134 3 жыл бұрын
I am also a student but i think a good engineer must have a decent knowledge of programming. Good knowledge of hardware along with software makes you eligible for jobs in big companies. You can take Mr. Mcworther as an example, he is an electrical engineer, but as you can see through his videos, he is an all-rounder, and that's what makes him a true engineer.
@Captain_Vitorio_Muscovy
@Captain_Vitorio_Muscovy Жыл бұрын
My code was a bit different but got the job done; hope this helps: num_grades = int(input("Please inform how many grades you have: ")) grades_list = [] N = 1 G = 1 while N
@professorxavier9692
@professorxavier9692 2 жыл бұрын
11:31 my girlfriend looked over my shoulder to see the legendary Paul frozen to the screen
@soundarrajankannan7692
@soundarrajankannan7692 3 жыл бұрын
I am Legend. I used for loop a lot in C language. It is easy to use for loop for me(because all things will be in a single position i.e. initialisation, condition, increment/decrement) in C. But it appears while loop is easy to use in python.
@vwwwvv2383
@vwwwvv2383 2 жыл бұрын
Doing this with while loop is much much better. By the way, I couldn't do the sorted grades so I ended up like a cheap folded walmart. And althought I copied the exact program that you did, it didn't work. It always had a traceback telling that I cannot call a the list/array in the if statement.
@EdwardRLyons
@EdwardRLyons 3 жыл бұрын
Success! I Am Legend!
@darthdaenerys
@darthdaenerys 2 жыл бұрын
I am a legend !
@constantinstoica9037
@constantinstoica9037 2 жыл бұрын
I am legend. Thanks!
@paulmcwhorter
@paulmcwhorter 2 жыл бұрын
You are!
@allenbennett8735
@allenbennett8735 Жыл бұрын
Can you use a while loop to determine how many grades you want to input?
@paulmcwhorter
@paulmcwhorter Жыл бұрын
Yes, but you would need some key to tell it to exit the loop. Like keep inputting grades until it sees you enter 'q'
@allenbennett8735
@allenbennett8735 Жыл бұрын
@@paulmcwhorter That's why I thought of a while loop--I couldn't yhink of any way a for loop would work.
@larryplatzek9017
@larryplatzek9017 3 жыл бұрын
Paul if this premieres in 6 days how do you alread have 5 likes??? Enjoyed video 12 today and the live chat sessions! have been enjoying Arduino lessons, I need to complete portable temparture version lesson 52.
@danielbanks7500
@danielbanks7500 3 жыл бұрын
Likely early release to Patreon.
@bryankohn9660
@bryankohn9660 3 жыл бұрын
I am legend..piece of cake.
@sunilkulkarni4426
@sunilkulkarni4426 3 жыл бұрын
HELLO PAUL!...I JUST ADDED +1 TO THE THUMBS UP COUNT...WAITING FOR YOUR VIDEO..............
@paulmcwhorter
@paulmcwhorter 3 жыл бұрын
Awesome thank you!
@nicobiesheuvel5144
@nicobiesheuvel5144 2 жыл бұрын
Hello Paul, i have bay a lot of koffie to follow you
@zaief7016
@zaief7016 8 ай бұрын
I used another counter (i) instead of setting j back to 0 😅
Python Tutorial 14: Saving and Reading Data Files With Pickle
22:57
Paul McWhorter
Рет қаралды 28 М.
Python Tutorial 18: Understanding Python Methods and Classes
42:43
Paul McWhorter
Рет қаралды 23 М.
Always be more smart #shorts
00:32
Jin and Hattie
Рет қаралды 45 МЛН
Osman Kalyoncu Sonu Üzücü Saddest Videos Dream Engine 170 #shorts
00:27
10 Nooby Mistakes Devs Often Make In Python
24:31
Indently
Рет қаралды 49 М.
Python Tutorial 16: Understanding Python Functions
34:26
Paul McWhorter
Рет қаралды 23 М.
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 67 М.
Python 3D Graphics Tutorial 4: Understanding 3D Graphic Parameters
32:16
Loops in C++ (for loops, while loops)
12:20
The Cherno
Рет қаралды 397 М.
Python: While Loops (Reading User Input Indefinitely?!!)
14:40