Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Python has several kinds of process control

2025-02-14 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you "python has several kinds of process control", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "python has several kinds of process control" this article.

1, sequence flow control, go all the way from top to bottom, regardless of any possible return, residence and other operations.

Complete all the sentences in one go, and each sentence is executed only once.

Dict= {"1": "I am the value of key 1", "xxxx": "I am the value of key for xxxx"} print (dict) print (dict.get ("1")) print (dict.keys ()) print (dict.values ())

Taking the above code as an example, the whole program starts from the definition of the dictionary to all the value of the output dictionary, and each statement is executed after the last statement has been executed, and it is no longer possible to be executed after successful execution.

2. Branch process control, when the program has many different execution methods, use conditions to control specific execution statements.

Print 50 if a > 30: print ("xx") if a > 20: print ("aaa") / / the program will output xx and then wrap to output aaa

3. Cycle flow control, the core is to repeat the same operation.

At the same time, the cycle in python is divided into while loop and for loop.

While 2-1: print / / 2-1 is essentially True, so this program will always output 233s (of course, this is an endless loop, something we should avoid. By the same token, if you change 2-1 to 2-2, then 2-2 0, then the program will not have any output. These are all the contents of the article "there are several process controls in python". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report