While Loops vs For Loops - [Which One Should I Use??]
The key to solving this problem, in the most efficient way, is to understand the difference between "for loops" and "while loops" and when to use them. #karel #coding #loops To solve the random hurdles problem in CodeHS you need to know when to use a "for loop" and when to use a "while loop." A "for loop" always loops for set number of times. A "while loop" loops as long as a condition is true. Using a while loop in this problem might seem like a good idea, but it is not. A for loop is better and easier, because we know that EVERY world in this problem is the same size. Since there are 14 columns in the worlds, we need to repeat our steps 13 times to move from the left to the right. The Karel programs can be found at CodeHS.com. Karel is a GREAT way to learn to code for beginners. And its fun!! ------------------------------------------------------- Check out my other videos on learning to program in Karel, JavaScript, Java and Python. I also have videos on Photography, Graphic Design, WordPress and other assorted topics. I have been teaching for nearly 20 years and have covered a LOT of different subjects. :-) If you are a teacher, please feel free to use my videos as part of your curriculum. I have many more videos on my channel. Check them out. If this has proved helpful, please consider subscribing to my channel. Have a great day!! Kris PS - Keep on coding!!
Download
0 formatsNo download links available.