A test script that is readily written in the Python learning process-testds.py

Source: Internet
Author: User

# test for Dict
Print (' ==========start Test dict========== ')
names = [' Aa ', ' Bb ', ' Cc ']
Scores = [98, 76, 54]
# # D is equivalent to making a map map
D = {' Aa ': 98, ' Bb ': +, ' Cc ': 54}
Print (' d is ', D)

For name in Names:
Print ('%s is '% name,d[name])

# # Get can not return an error when querying data, return a specified numeric value or string
Print (' xy not exist, result of XY is ', d.get (' xy ',-1))
# # can pass in to determine if the query data exists in Dict
i = 0
Names.append (' Xy ')
While I < 10:
If not names[i] in D:
Print (' Break, names[%d] not exist '% i,names[i])
Break
Print (' names[%d] is '% i,names[i])
Print (' d[%s] is '% names[i],d[names[i])
i = i + 1

Print (' d is ', D)
# #删除映射可用pop
D.pop (' Aa ')
Print (' After Pop,d is ', D)

Print (' =========start Test set========== ')
# #set是一组字符的集合, but the data is automatically de-weighed, add and remove elements can be added and removed, but will still be repeated
s = set ([' A ', ' B ', ' C ', ' a '])
Print (' s is ', s)
S.add (' a ')
S.add (' d ')
Print (' After S.add, S-is ', s)
S.remove (' d ')
Print (' After s.remove, S-is ', s)
S2 = set ([' A ', ' B ', ' e '])
# #set可做 & and | operations
Print (' S2 is ', s2)
Print (' s & S2 is ', S & S2)
Print (' s | S2 is ', s | s2)

A test script that is readily written in the Python learning process-testds.py

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.