01Python Base _02 Variable

Source: Internet
Author: User

1. Digital numbers:

int long float Complex

51924361L 0.0 3.14j

100-0x19323l 15.20 45.J

-786 0122l-21.9 9.322e-36j

080 0xDEFABCECBDAECBFBAEl 32.3e+18.876j

-0490 535633629843l-90. -.6545+0j

-0x260-052318172735l-32.54e100 3e+26j

0x69-4721885298529l 70.2E-12 4.53e-7j

2. String: ' '

The string is: ordered, immutable

1 ' Ilovepython ' 2 Print (S[1:5])        # Out:love

3. List: []

The list is: ordered, variable

1List = ['Runoob', 786, 2.23,'John', 70.2 ]2Tinylist = [123,'John']3 4 PrintList#[' Runoob ', 786, 2.23, ' John ', 70.2]5 PrintLIST[0]#Runoob6 PrintList[1:3]#[786, 2.23]7 PrintList[2:]#[2.23, ' John ', 70.2]8 PrintTinylist * 2#[123, ' John ', 123, ' John ']9 PrintList + tinylist#[' Runoob ', 786, 2.23, ' John ', 70.2, 123, ' John ']

4. Tuple tuples: ()

Tuples are: Ordered, immutable

 1  tuple = ( " runoob  , 786, 2.23, "  john   ", 70.2 2  list = [ " runoob  " , 786, 2.23,  " john   ", 70.2]  3  TUPLE[2] = #   4  list[2] = #   list is a legitimate application /span> 

5. Dictionary dict: {}

The dictionary is: unordered, key value immutable, value variable

1Dict = {}2dict[' One'] =" This is one"3DICT[2] =" This is the"4Tinydict = {'name':'John','Code': 6734,'Dept':'Sales'}5  6 Printdict[' One']# This is one7 PrintDICT[2]# This is the8 PrintTinydict#{' dept ': ' Sales ', ' Code ': 6734, ' name ': ' John '}9 PrintTinydict.keys ()#[' dept ', ' Code ', ' name ']Ten PrintTinydict.values ()#[' Sales ', 6734, ' John ']

01Python Base _02 Variable

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.