Class notes------Python data type (top)

Source: Internet
Author: User

Python data type

Python contains 6 of the standard types:
1.Number Numeric type
2.String String Type
3.List list Types
4.Tuple tuple Type
5.Dict Dictionary Type
6.Set collection type
Note: In addition to the standard data types, Python has an unlimited number of data types because users can create their own
"""

#1. Number numeric type
‘‘‘
1.int integer Integer
2.float floating-point float
3.complex Complex Complex
4.bool boolean bool
‘‘‘
#1. Integral type is an integer, including positive integer/negative integer/0
#十进制声明整数 (0-9)
Intvar = 25
Print (Intvar)
Print (Type (Intvar))

#声明二进制整数 (0-1)
Intvar = 0b10011101
Print (Intvar)
Print (Type (Intvar))

#声明八进制整数 (0-7)
Intvar = 0o532
Print (Intvar)
Print (Type (Intvar))

#声明十六进制整数 (0~9A-F)
Intvar = 0x32f
Print (Intvar)
Print (Type (Intvar))

#2. Floating-point numbers are decimals.
Floatvar = 3.2
Print (Type (Floatvar))

Floatvar = 325e-2
Print (Type (Floatvar))

#3. plural
Fsvar = 3-2j
Print (Type (Fsvar))

Fsvar = Complex (2,9)
Print (Fsvar)
Print (Type (Fsvar))

#4. BOOL Type
RST = 30<5
Print (Type (RST))

Boolvar = False
Print (Type (Boolvar))

#String String Type
#字符串类型就是文字类型

#单引号声明字符串
Strvar = ' Wanke '
Print (Strvar,type (Strvar))

#双引号声明字符串
Strvar = "Wanda"
Print (Strvar,type (Strvar))

#三引号声明字符串
#strvar = "CEO CEO"
Strvar = "" CFO Chief Financial officer ""
Print (Strvar,type (Strvar))

#三种引号使用的场合
#字符串中包含双引号但不包括单引号时, single quotation marks should be used to declare
Strvar = ' Zifuchuanzhong ' Baohan ' Shuangyinhao '
Print (Strvar)

#字符串中包含单引号但不包括双引号时, you should use double-quote declarations
Strvar = "He likes to eat ' shopping"
Print (Strvar)

When #字符串中包含单/double quotes, use a three-quote declaration
Strvar = "My good friend", and you are also "good friends". ‘‘‘
Print (Strvar)

Print (home) print (' 3xiao ')

Class notes------Python data type (top)

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.