Python What are the variables in ? Variable , Record the changing state of things . It is to make the computer have a certain function of human , It can better complete the tasks assigned by human beings , This gave birth to variables .
" Variables are composed of three parts "
name = "Mike"
What is a variable name ?
When variables are defined , It will apply for a space in memory for storing variable values , And the variable name , It is the house number of this space , Can easily find this memory space .
The variable name should be able to describe the meaning of the variable value , It is best to consider the name and the meaning , Proper variable name naming can improve the readability of your program .
How variable names are named
Variable names are generally Three ways of naming .
<!---->
<!---->
Assignment symbol
above “=” The equal sign is the assignment symbol of the variable . Its meaning is to bind the memory address of the variable value on the right to the variable name on the left , When we use the variable name, we can find the variable value .
A variable's value
The variable value is The state of things , After the definition, you can use the variable name to access . The variable value has a reference number , Once this space has been referenced for 0, That means we have no way to find this space , If not cleaned , Will cause memory to be occupied . Once you can't find this space , It will trigger Python Memory management for : Garbage collection mechanism , Recycle the space . Variables have three very important characteristics :id、type、 A variable's value .
A variable's value : Store the value itself .
Example
For example, the average score of a student , We input students' scores in three subjects in turn , Calculate the student's average score and print it out , Keep one decimal point for the average score and calculate the percentage of the student's Chinese score in the total score ?
Today, let's talk about this first !