This is the 20th day of my participation in the August Text Challenge.More challenges in August

Python has grown so rapidly in recent years that it is not just programmers who have started learning Python, but many people in other industries have started using Python as a professional skill.

This article continues for beginners to learn the basics of Python syntax — variables and assignments. The main content includes concepts of variables and assignments, code demonstrations, variable characteristics and naming conventions, and the = symbol.

1. What are variables

A variable is a name for something, and the word variable means something that changes. Thus, a variable in Python is a container or box whose contents can change based on what you put into the container or box.

For example, to illustrate the variable, we have a cup, and we can pour a drink into the cup, the drink could be water, coke, etc. The cup is the container that holds the drink, which is the memory or hard drive of the computer, and the drink is the data that we store on the computer. Cups are called variables in Python, and you can store any type of drink in this cup.

2. What is assignment

The cup is called a variable in Python, and you can store any type of drink in this cup. The process of pouring a drink into a cup is called assignment in Python.

3. Code demonstration

Name = 'Xiaoming'

This is a common assignment to a variable. In this case, name is a variable, and the two characters’ Xiaoming ‘are assigned to the variable name.

4. Characteristics of variables

The most important feature of a variable is that the data it stores can be changed at any time. Variable is equivalent to a cup, the cup can put any content, but the cup is a size, it can not be unlimited things, only remember the last thing stored. Code demo:

So the variable eventually prints only the last assignment.

5. Naming conventions for variables

Variable names should not be arbitrarily chosen, but should follow certain norms. Contains only digits, letters, and underscores (_). Cannot start with a number; Try to describe the content of the data contained.

For example, if the information being assigned is a name, the variable name can be named; If the assigned information is age, the variable name should be age.

6, = symbol

“=” does not mean equal, but assignment, which means putting what is to the right of the = sign into the variable on the left. == is equal to.

7,

That concludes the basic Python syntax for the section on variables and assignments. Variables are the first cup for storing content in Python’s myriad worlds, and if you use this cup well, you’ll be able to use it more smoothly when you encounter other cups in the future.

A nine-story platform starts from the earth. Do not underestimate what you have learned today. It will be the cornerstone of our later big projects.