Python Two-time learning (variable, judgment statement, loop, function, import *.py)

Source: Internet
Author: User

1. A variable is an area of computer memory where a variable can store values within a specified range, and the value can be changed.

Constants are a read-only area of memory that cannot be changed once they are initialized.
In general, the simplest understanding is that Python's constants are mainly defined as immutable quantities in the course of a program's operation, and Python's variables are mainly those that can be changed in the course of program execution, and we don't have to delve into them.

A = 5print (a) #输出a为5a = 6print (a) #输出a为6

At this point a is the variable

Import Mathprint (Math.PI)

At this point, the output of pi is constant


2. Judgment statement

The simplest understanding is to judge a condition, what the condition does, and what the condition is not.

The most common is if------else-----and if----elfi-------eles-----

Score = 100if score > 90:print ("A") Elfi > Score > 80:print ("B") else:print ("C")


3. Cycle

Self-understanding is the constant execution.

Common while and for----in-----

A range (x) is filled with numbers used to generate 0-x.

While condition: execution
For I in range (x): Print (i)

The second study learned

For I in range (x): print ("xxxxx {0} {1}". Format (i, "xxxx") does not work well 4. Functions my understanding of functions is that functions can improve the modularity of applications and the reuse of code. For example a shopping system, need to recharge, you can write a recharge function, wait until the use of the direct import function can make the code simplified. Def Max (A, B): If a > B:return a else:return the size of a function, the value of output A is 5. Import function imports py name from PY name function name such as: a file called  Do test1.py test1.py function as Max () function another file for test2.py in test2.py there is the function of Max () in test1.py import test2.py or form Test1 Import max himself video site: www.ldxzs.top No ads everyone's okay. You can step on the movies and the series.



Python Two-time learning (variable, judgment statement, loop, function, import *.py)

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.