- Hands-On Data Science and Python Machine Learning
- Frank Kane
- 190字
- 2021-07-15 17:15:04
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.
- Learning LibGDX Game Development(Second Edition)
- Mastering Entity Framework Core 2.0
- 大學(xué)計算機應(yīng)用基礎(chǔ)實踐教程
- 構(gòu)建移動網(wǎng)站與APP:HTML 5移動開發(fā)入門與實戰(zhàn)(跨平臺移動開發(fā)叢書)
- Clojure for Domain:specific Languages
- 趣學(xué)Python算法100例
- Python爬蟲開發(fā)與項目實戰(zhàn)
- Jenkins Continuous Integration Cookbook(Second Edition)
- Spring核心技術(shù)和案例實戰(zhàn)
- Microsoft Dynamics AX 2012 R3 Financial Management
- Python大學(xué)實用教程
- Deep Learning with R Cookbook
- PHP與MySQL權(quán)威指南
- C++程序設(shè)計
- 算法圖解