[4. Constants, variables, expressions]] Zero basic learning of python, simple and rude

constants, variables, expressions

  • The value of constants will not change, such as pi;
  • A variable is a quantity whose value can change dynamically;
  • Expressions are expressions that perform mathematical or logical operations on constants and variables;
  • In Python, we often use one statement to assign values ​​to multiple variables;
        # Define constants, usually all uppercase
        PI = 3.14
    
        # Define a variable whose value can be dynamically changed
        radius = 10
    
        # use expression to assign value to variable area
        area = PI * radius * radius
        print( " The area of ​​the circle before the radius variable is changed is " , area)
    
        # The value of the variable can be dynamically changed
        radius = 20
        area = PI * radius * radius
        print( " The area of ​​the circle after the radius variable is changed is " , area)
    
        # Assign values ​​to multiple variables at the same time
        name, age = "Pythoner", 18
        print(name, age)

     

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325620728&siteId=291194637