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

Example Analysis of variables and processes in python language

2025-03-26 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

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

This article mainly introduces the sample analysis of variables and processes in python language, which is very detailed and has a certain reference value. Interested friends must read it!

(1) variable

A variable is the amount by which the value can be changed.

To design variables is to consider what kind of variables need to be used, what they do, what the initial values of the variables are, what changes will probably occur in the process, and so on.

What variables are needed? This is related to the process. For example, if the process adds two input numbers, consider using two variables to hold the input value, such as this:

The simplest idea is to design variables that need to be saved (temporarily or for a long time) in the process.

For initial values, it is generally necessary to consider to avoid exceptions due to unknown initial values when using variables.

You can then consider how the values of variables may change during the operation of the process, which is helpful for debugging or mastering the process.

There are common types of variables in python, as well as some common built-in data structures, which will be described in more detail later, only to mention the concept of variables and confirm that it is an important concept.

(2) process

The process is the main content of the program.

The process does not have to be implemented, it can be a protocol development, or a framework development, can not require a specific implementation.

For processes that have been implemented, from a procedural point of view, there are process routines.

The three most common process routines are sequential routines, branching routines, and cyclic routines.

The sequence routine, which is carried out sentence by sentence from top to bottom, is bound to exist.

Branch routines are chosen to be executed according to different conditions.

A loop pattern is to repeat a process.

These three routines are basically mixed, appearing in the form of combined punches, such as:

#-*-coding: utf-8-*-

Import random

Secret=random.randint (0100)

Temp=input ("Please tell me the number I want:")

Guess=int (temp)

While guesskeeper secret:

If guess > secret:

Print ("not this big, say a small one!")

Else:

If guess < secret:

Print ("too small, say a big one!")

Else:

Break

Temp=input ("guess wrong, do it again:")

Guess=int (temp)

Print ("Bravo, you're right!")

The above "guessing numbers" game uses looping and branching tricks:

For branching routines, there are generally two expressions:

If... Else

If... Elif... Else

For circular routines, there are generally two forms of expression:

While xx:

For xx in []:

The above is all the content of the article "sample Analysis of variables and processes in python language". Thank you for reading! Hope to share the content to help you, more related 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

Internet Technology

Wechat

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

12
Report