1. Python basic Object Type----number

Source: Internet
Author: User

First thing to remember: object thinking: All things are objects!

    • Accurate Description python an object that requires "identity, type, value" from three dimensions.

>>> 520

520

>>> 55555555555555555555555555555

55555555555555555555555555555L

>>> 3.1415926

3.1415926

>>>

int integers : 520

Long large integers : Python automatically converts large integers and displays an l at the end;

float floating point number: 3.1415926

two built-in functions (Build-in function):

Identity ID (): View the object memory address.

>>> ID (520)

38401608L

>>> ID (55555555555555555555555555555)

38334056L

>>> ID (3.1415926)

32795904L

>>>

Types type (): View Object types.

>>> Type (520)

<type ' int ' >

>>> type (55555555555555555555555555555)

<type ' Long ' >

>>> type (3.1415926)

<type ' float ' >

>>>

The value object itself, the above example is a numeric value.

object has type, variable no type!

    • Variable:

>>> x=520

>>> x

520

>>> x=110

>>> x

110

>>>

X is a variable, assign a value of 520 to it, and then assign a value of 110 to it; X is like a label;

x as a variable, no type;

Type (x) returns the value of the x corresponding to the kind;

>>> x=110

>>> type (x)

<type ' int ' >

>>> x=55555555555555555555555555555

>>> type (x)

<type ' Long ' >

>>> x=3.1415926

>>> type (x)

<type ' float ' >

>>>

    • Arithmetic

Add +, minus-, multiply *, divide/, computer and math arithmetic rules.

>>>

2

>>> 1+1.0

2.0

>>> 1.0+1.0

2.0

>>> type (1.0+55555555555555555555555555555)

<type ' float ' >

>>>

Need to note:

Float floating-point +int integer =float floating-point type

float float type +long long integer =float floating point type

    • Integer overflow problem:

Python solves this problem for us, supporting an "infinite precision" integer, as follows:

>>> 2**1000

10715086071862673209484250490600018105614048117055336074437503883703510511249361

22493198378815695858127594672917553146825187145285692314043598457757469857480393

45677748242309854210746050623711418779541821530464749835819412673987675591655439

46077062914571196477686542167660429831652624386837205668069376L

>>>

1. Python basic Object Type----number

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.