LinkedIn principal author Doug Winnie explains how for loops work and how you can use them as a programmer and coder to create loops that run a specific number of times. The for loop contains a special variable called an iterator, a conditional, and a step that works together to create the loop. For loops can be nested within each other to process through more complex situations requiring multiple dimensions of data.
- Loops are helpful ways to take sections of code…and run them multiple times.…With while and do while loops,…you need to have a condition that can evaluate…based on existing data and variables.…Sometimes you need to create a unique set…of information for the loop that you will use…for the conditional test.…That is when you need a for loop.…A for loop is similar to a while loop.…At the top, you'll ask a question…and then you'll have the code…for the loop located afterwards.…
The new element that is added to a for loop is an iterator.…This is a variable that is created only for the loop itself.…You define it at the top of the loop,…and it will only exist within the loop itself.…The intention is that the variable you create…at the top of the loop is used in the conditional test.…With each repetition of the loop,…you need to have a way to change the iterator.…So that is the third item that is…within the opening code of the for loop.…So, the for loop contains the declaration…of the iterator variable which is often just called i.…
Author
Released
11/28/2016Join Doug Winnie as he explains the principles of programming and helps you connect to core concepts by exploring three ways that programmers perform their jobs. Doug starts by sharing the history of coding and then dives into functions, values, variables, and parameters used to define actions. He covers capturing input from users, creating conditional tests, using loops with arrays, and object-oriented programming basics. He also takes you beyond programming, into processes like debugging, refactoring, and building iteratively.
- Working with values and variables
- Breaking down tasks
- Customizing functions and parameters
- Building conditional tests
- Creating and changing arrays
- Working with objects and classes
- Debugging and refactoring code
- Going beyond the code as a programmer
Skill Level Beginner
Duration
Views
Related Courses
-
Introduction
-
Welcome1m 40s
-
What you should know1m 3s
-
-
1. Control Computers with Code
-
History of programming2m 9s
-
Forms of programming5m 12s
-
-
2. Define Actions Using Code
-
Break down tasks2m 29s
-
Variables and scope2m 9s
-
Return values from functions2m 15s
-
Work with an API1m 27s
-
3. Repeat Actions and Test for Conditions
-
Capture input from the user3m 31s
-
Create conditional tests4m 39s
-
Use while loops2m 11s
-
Use for loops3m 11s
-
Use loops with arrays2m 5s
-
-
4. Objects and OOP
-
Everything is an object2m 21s
-
Everything is a class4m 3s
-
Extend classes2m 7s
-
-
5. Beyond Programming
-
Debug problems2m 50s
-
-
Conclusion
-
Next steps1m 19s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: Use for loops