课程: Computer Science Principles: Programming
今天就学习课程吧!
今天就开通帐号,24,100 门业界名师课程任您挑!
Use while loops
- Programming allows us to repeat actions multiple times. We can used named sections of code called functions to execute lines of code whenever we need to run them. That's fine for when we need to intermittently run sections of code, but if we want to run the code over and over again, we can use loops. Loops are ways a programmer can take a section of code and have a program run them multiple times. Using a conditional, the programmer can define a limit to the number of times a loop runs. The most basic loop is a while loop. It works like this. At the top you ask a question as a conditional statement that evaluates as either true or false. If the answer to the question is true, then the code in the loop runs, and then it goes back to the top and asks the question again. If the answer to the question is ever false, then the loop stops and doesn't run again, and the program continues with code after the loop. With this type of loop, it will run for as long as it is true. But there is a…
内容
-
-
-
-
-
(已锁定)
Capture input from the user3 分钟 31 秒
-
(已锁定)
Manage different variable types2 分钟 4 秒
-
(已锁定)
Create conditional tests4 分钟 39 秒
-
(已锁定)
Build compound conditional tests4 分钟 19 秒
-
(已锁定)
Use while loops2 分钟 11 秒
-
(已锁定)
Use for loops3 分钟 11 秒
-
(已锁定)
Create arrays to store groups of values2 分钟 28 秒
-
(已锁定)
Use loops with arrays2 分钟 5 秒
-
Changing arrays2 分钟
-
(已锁定)
-
-
-