Analysis of basic Python-Process Control and basic python Processes

Source: Internet
Author: User

Analysis of basic Python-Process Control and basic python Processes

The Python programming language is very powerful, and its convenient application features also play a very important role for developers. Here we can first understand the concepts related to the keywords of Python process control, so as to grasp the characteristics of this language.

Python is an interpreted, object-oriented, and dynamic data type high-level programming language.

Python was invented by Guido van rosum at the end of 1989. The first public release was released in 1991.

Like Perl, Python source code also complies with the GPL (GNU General Public License) protocol.

Which language has flow control, that is, if switch while statements.

The principle and function of distance control for each language are similar, but the expressions are different.

Today I will share with you a Python statement, such as conditions and loops.

Here, we will not use braces, but code blocks.

Note the colon after if and else:

If

<code class="hljs lua">name = raw_input("What is your name? ")if(name.endswith('Gumby')):print 'Hello, Mr. Gumby'</code>

Else

<code class="hljs lua">name = raw_input("What is your name? ")if(name.endswith('Gumby')):print 'Hello, Mr. Gumby'else:print 'Hello, Stranger'</code>

Elif

Note that the else if statement we use in C ++ is directly written in Python: elif

<code class="hljs python">num = input('Enter a number: ')if num >0 :print 'The number is positive'elif num < 0:print 'The number is negative'else:print '0'</code>

While

<code class="hljs lua">x = 1while x <= 100print xx += 1</code>

For Loop

If you can use for, try to avoid using while

<code class="hljs livecodeserver">words = ['this', 'is', 'an', 'ex', 'parrot']for word in words:print word</code>

For dictionary Traversal

<code class="hljs lua">d = {'x':1, 'y':2, 'z':3}for key in d:print key, 'corresponds to', d[key]</code>

Zip and row Iteration

<code class="hljs lua">names = ['name', 'beth', 'george', 'damo']ages = [12, 45, 32, 99]for name, age in zip(names, ages):print name, 'is', age, 'years old'</code>

Break bounce cycle

Continue

Now, I will introduce you to the basic Python-Process Control editor, and hope to help you!

Articles you may be interested in:
  • Python Process Control instance code

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.