Python data type

Source: Internet
Author: User

Data type

A computer is a machine that can do mathematical calculations as the name implies, so a computer program can handle a variety of values. however, the computer can handle far more than the numerical value, but also can deal with text, graphics, audio, video, web and other kinds of data, different data, need to define different data types. In python, there are several types of data that can be processed directly:

one, integer

python can handle integers of any size, including, of course, negative integers, and in a Python program, integers are represented in exactly the same way as mathematically, for Example:1,100,-8080,0, and so On.

computer because of the use of binary, it is sometimes used to denote integers in hexadecimal is more convenient, hexadecimal with0xprefixes and 0-9,a-f representations, for example:0xff00,0xa5b4c3d2, and so On.

second, floating point number

floating-point numbers, which are decimals, are called floating-point numbers because, when represented by scientific notation, the decimal position of a floating-point number is variable, for example, 1.23x10^9 and 12.3x10^8 are Equal. Floating-point numbers can be written in mathematical notation, such as1.23,3.14,-9.01, and so On. But for very large or very small floating-point numbers, it must be expressed in scientific notation, the 10 is replaced with e, 1.23x10^9 is 1.23e9, or 12.3e8, 0.000012 can be written 1.2e-5, and so On.

Integers and floating-point numbers are stored inside the computer in different ways, and integer operations are always accurate (is Division accurate?). Yes! ), and the floating-point operation may have rounding Errors.

three, string

the string is ‘‘ in or""text, such as ' abc ', 'xyz ', and so On. Note that the' or ' itself is only a representation, not a part of the string, so the string‘abc‘onlya,b,cthese 3 characters.

four, Boolean value

A Boolean value is exactly the same as that of a Boolean algebra, and a Boolean value is onlyTrue、FalseTwo values, either of which areTrue, or isFalse, in python, you can directly use theTrue、FalseRepresents a Boolean value (note case), or it can be computed by a Boolean Operation.

Boolean values can be usedand,orand thenotOperation.

andOperations are associated with operations, and only the results of all true,and operations are True.

or operation is or is an operation, as long as one of the results of the true,or operation is True.

notAn operation is a non-operation, which is a single-mesh operator that turns true into False,false to True.

five, Null value

A null value is a special value in python, with None Representation. None cannot be understood as 0, because 0 is meaningful, and none is a special null Value.


Task

To try, in the right editor, complete the following tasks:

1. computes the sum of decimal integers 45678 and hexadecimal integers 0x12fd2.

2. Use a string to represent the learn Python in Imooc.

3. Calculate the Boolean value of the following expression (note = = To determine equality):

< 99

0xFF = = 255

note: Use the Print command


Code:

Print (45678 + 0x12fd2)

Print "learn Python in imooc."

Print < 99

Print 0xFF = = 255


Results:

123456
Learn Python in Imooc.
False
True



This article is from the "technical achievement dream" blog, Please be sure to keep this source http://andyliu.blog.51cto.com/518879/1854599

Python data type

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.