Day1.python Common data Types-----Brief Diary

Source: Internet
Author: User

A

1. Common data types: integer, Float, Boolean, complex type, etc.

2 integer: an integer, similar to the Java BigInteger type, with unlimited length (limited to the total amount of virtual memory). Can be calculated in large numbers.

3 floating point: that is, decimal, (the only way for Python to differentiate between integral and floating point types is decimal.) Commonly used e notation (i.e. scientific notation, which represents particularly large and particularly small numbers)

4 Boolean type: a special integral type with true and False to denote "true" and "false" can be treated as integers. Ture equivalent to an integer value of 1,false equivalent to an integer value of 0. Note: It is very low to take the Boolean type as 1 and the calculation of the

Two

1. Functions related to data type: Int (), float (), str ().

2.int (): Converts a string and a floating-point number to an integer column:

>>>a= ' 520 '

>>>b=int (a)

>>>a,b

(' 520 ', 520)

>>>c=5.99

>>>d=int (c)

>>>c,d

(5.99,5) Note: Python is taking truncation processing, not rounding.

3.float (): Converts a string or integer to a floating-point (decimal) column:

>>>a= ' 520 '

>>>b=float (a)

>>>a,b

(' 520 ', 520.0)

>>>c=520

>>>d=float (c)

>>>c,d

(520,520.0)

4.STR (): Converts a number and other types to a string

Three.

Type () function:

>>>type (' 520 ')

<class ' str ' >

>>>type (5.20)

<class ' float ' >

>>>type (5E20)

<class ' float ' >

>>type (520)

<class ' int ' >

>>>type (True)

<class ' bool ' >

Isinstance (): First to determine the type of data; second specifies a data type

Isinstance () returns the value of a Boolean type according to the above two parameters true is type consistent, false is type inconsistent

                                                         ,         &N Bsp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp           small windbreaker

November 26, 2017

Day1.python Common data Types-----Brief Diary

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.