Pupils learn Python (ii)

Source: Internet
Author: User

The previous section describes the installation of the Python environment, a section that writes variables and names.

Python is written in C, so a lot of C's ideas are inside.

The basic data types are shaping, floating point, and character type.

Shaping int

Float type float

Character Type Str

Continue to open the tool IDLE,

Enter the type (3) on the interactive interface, press ENTER, type (3.0), press ENTER, type (' 3 '), and press ENTER. The result is the same as in Python, with single quotation marks (') and double quotation marks (""). The next use of variable A = 1 means that we define a variable a, and the value 1 is assigned to a, this time a is the type of a = ' 1 ' means that we define a variable a, and the character value ' 1 ' is assigned to a, this time a is the type of a character type such a child-defined variable is usually inside the function, There is no indication of the meaning of this variable. Here's an interesting example:
1  # 100M of broadband at home, calculate the actual speed 2  Bandwidth = 100/83  print'M')

# Start with a comment, can write casually, record the inspiration at the time, will not have an impact on the actual code

A variable bandwidth is defined to denote the meaning of the bandwidth; the print () function can output the data we want to see. A variable name can start with a letter, or it can begin with an underscore, not a number. Variable names can contain numeric letters and underscores.

Bandwidth = 100/8 The meaning of this sentence 100 divided by 8, 12.5, the floating-point number 12.5 is assigned to the variable bandwidth
Variables and variables can also be assigned to each other, such as:
  The value of a=1 B=a # B is 1

Pupils learn Python (ii)

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.