Python learns the "third" Python variable

Source: Internet
Author: User

Variable declaration variable

1 # !/usr/bin/env python 2 3   4 " Bourbon "

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

The role of a variable: A variable has an identity meaning, which refers to what is stored in an address in memory

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 (but you can start with "_") and a space cannot appear in the variable name

· Keyword cannot be declared as a variable name:

[' 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 ']

PS: When encountering complex variable names by "_" to separate multiple words or capitalize the first letter of a word (camel body)

Assignment of variables:

1 # !/usr/bin/env python 2 3 4 " Bourbon " 5 " Sheldon "

1>>>name1 ="BOurbon"2>>>name2 =name13>>>Print(name1,name2)4 5 #Output6BOurbon Bourbon7 8 9>>>name1 =' SHeldon'Ten>>>Print(name1,name2) One  A #Output -Sheldon Bourbon

Python learns the "third" Python 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.