Home > Database > Mysql Tutorial > body text

Learning Python in anger - Part 3 - Structural Control

黄舟
Release: 2016-12-20 16:56:43
Original
833 people have browsed it

As we all know, the structure of program statement execution is nothing more than sequential structure, branch structure and loop structure. The same is true for Python. The sequential structure is too simple to mention. Let’s briefly record the similarities and differences between branches and loops and C++. By the way, for those who already know C++ For those who are learning Python, they should pay attention to the fact that statement blocks are controlled through indentation.

Branch structure: both use if and else, with an additional elif instead of C++'s else if. The essence is the same, so no examples are given

Loop structure: Compared with C++, there is no do..until statement, but while and for, which also uses break to end the loop and continue to enter the next loop, but there is a difference in for and a new statement pass. Examples are given below, but for the other parts, they are the same

for i in 'wyp':                                                                                                                                                                               ​ #Loop through the sequence structure
​ print 'This is', fruitfor i in range(3):                                                                                                                                                                                                        #pass can’t do anything and feels useless


The above is about learning Python in anger - Chapter 1 Three articles - the content of structural control. For more related content, please pay attention to the PHP Chinese website (www.php.cn)!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!