Little white python path day1 variable

Source: Internet
Author: User

Python road, Day1-python base 1 variables

Variables are used to store information that is referenced and manipulated in a computer program. They also provide a way to tag data with descriptive names so that our programs can be more clearly understood by the reader and ourselves. It is helpful to consider variables as containers for storing information. Their sole purpose is to mark and store data in memory. This data can then be used throughout the program.

declaring variables

123 #_*_coding:utf-8_*_name ="Many Qian"

The code above declares a variable named: Name, and the value of the variable name is: "Many Qian"

Rules for variable definitions:

      • Variable names can only be any combination of letters, numbers, or underscores
      • The first character of a variable name cannot be a number
      • (The function name defined in program programming cannot be used as a variable name, otherwise it will dig a hole for itself)
      • Conventional rules: 1. Do not use Chinese (although Python3 support) 2. Do not write Pinyin 3. English words are the best (the word combination is best to use underline, do not "hump" the first letter capital)
      • Constants (Python does not support constants, we define it as "PIE")
      • The following keywords cannot be declared as variable names
      • [' and ', ' as ', ' assert ', ' Break ', ' class ', ' Continue ', ' Def ', ' del ', ' elif ', ' Else ', ' except ', ' exec ', ' finally ', ' for ', ' F ' Rom ', ' Global ', ' if ', ' import ', ' in ', ' was ', ' lambda ', ' not ', ' or ', ' pass ', ' print ', ' raise ', ' return ', ' try ', ' while ', ' WI Th ', ' yield ',]

Assigning values to variables

1234567891011121314 name = "Many Qian" name2 = nameprint(name,name2) name = "Tom" print("What is the value of name2 now?")The result would be: What's the value of Tom now?

Little white python path day1 variable

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.