python[Little Turtle 005Python data type]

Source: Internet
Author: User

I. Numeric type
    • Plastic
    • Boolean type True and False is 1 and 0
    • Floating point Type
    • E notation E, for example 1.5e11 = 150000000000, 1e2 is the square of 1*10.

PS: Boolean types in Python can be added directly for example:

>>>true + True >>>2

Two. Type conversion

    • Strings for numbers can be converted to integers using str ()

>>>a = ' 520 ' >>>b = Int (a) >>>b >>>520

    • For shaping can also be converted into string type

>>>a = 520 >>>b = str (a) >>>a >>> ' 520′

    • String type special floating point type

>>>a = ' 520′>>>b = float (a) >>>b 520.0

Three. Application of built-in functions

    • The type function is used to determine what types of data the user gives

For example

>>>type (3.5) >>><class ' float ' >

>>>type (true) >>><class ' bool ' >
>>>type (5E15) >>><class ' float ' >

    • Isinstance () built-in function for judging the data type and returning to the user a Boolean type of True or False

For a code case

>>>a = ' haha ' >>>isinstance (A,STR) True
>>> isinstance (320,int) True

>>>isinstance (A,int) >>>false

can also be directly used to judge

python[Little Turtle 005Python data type]

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: 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.