官术网_书友最值得收藏!

The while loop

Another syntax is the while loop. This is kind of a standard looping syntax that you see in most languages:

x = 0
while (x < 10):
print (x),
x += 1

The output of the previous code is as follows:

0 1 2 3 4 5 6 7 8 9

We can also say, start with x = 0, and while (x < 10):, print it out and then increment x by 1. This will go through over and over again, incrementing x until it's less than 10, at which point we break out of the while loop and we're done. So it does the same thing as this first example here, but just in a different style. It prints out the numbers 0 through 9 using a while loop. Just some examples there, nothing too complicated. Again, if you've done any sort of programming or scripting before, this should be pretty simple.

Now to really let this sink in, I've been saying throughout this entire chapter, get in there, get your hands dirty, and play with it. So I'm going to make you do that.

主站蜘蛛池模板: 门源| 禹城市| 金华市| 久治县| 奉贤区| 莲花县| 绍兴县| 漠河县| 抚顺县| 张家口市| 桃江县| 西昌市| 随州市| 长汀县| 宜宾市| 泸溪县| 文登市| 和林格尔县| 衢州市| 井冈山市| 富锦市| 乐至县| 广州市| 龙岩市| 西安市| 嘉鱼县| 江安县| 中阳县| 天祝| 廉江市| 棋牌| 三门峡市| 鸡西市| 龙山县| 祁东县| 昌黎县| 大渡口区| 拜泉县| 渭南市| 扶风县| 商南县|