# Add a dictionary
# d = {
#
#: ' Adam ',
#
#: ' Lisa ',
#
#: ' Bart '
#
# }
# # d[55]= ' Jack '
# print (d[95])
# Get key value
# d = {
# ' Adam ': 95,
# ' Lisa ': 85,
# ' Bart ': 59
# }
# for key in D:
# Print (key+ ': ', D[key])
# Determine if there is
# s = set ([' Adam ', ' Lisa ', ' Bart ', ' Paul ')
# x= ' Jack '
# if x in S:
# print (' test ')
# Else:
# print (' ERROR ')
# Show variables and values
# s = set ([' Adam ', ' + '), (' Lisa ', ' $ '), (' Bart ', 59)])
# for X in S:
# print (X[0], ': ', x[1])
# # print (x)
# Access By contrast set
# s = set ([' Adam ', ' Lisa ', ' Paul '])
# L = [' Adam ', ' Lisa ', ' Bart ', ' Paul ']
# for A in L:
# If a in S:
# S.remove (a)
# Else:
# S.add (a)
# print (s)
# Add a list
# L = [' Adam ', ' Lisa ', ' Bart ']
# print (l[1])
# # L.append (' JACK ')
# L.insert (1, ' JACK ')
# Print (L)
# # Replace List
# L = [' Adam ', ' Lisa ', ' Bart ']
# l[1]= ' JACK '
# Print (L)
# Add a dictionary
# d = {
# ' Adam ': 95,
# ' Lisa ': 85,
# ' Bart ': 59
# }
# d.update ({' Jack ': 75})
# print (d)
D = {
' Adam ': 95,
' Lisa ': 85,
' Bart ': 59
}
# Print (D.get (' Adam '))
# b= (d.get (' Lsa '))
# print (b)
# print (b)
A= ' Adam ' or ' Bart '
# if ' Bart ' in D:
# If a in D:
If a in D:
# Print (d[' Bart ')
Print (A, ': ', D[a])
Else
Print (' Error ')
# Two comparison of list lengths
# s = [' Adam ', ' Lisa ', ' Paul ']
# L = [' Adam ', ' Lisa ', ' Bart ']
# A=len (s)
# B=len (L)
# print (A, B)
# # for A in L:
# If A = = B:
# print (' Pass ')
# Else:
# print (' ERROR ')
# Go Heavy
# method 1
# a = [' Adam ', ' Lisa ', ' Paul ', ' Adam ', ' Adam ', ' Lisa ']
# b=[]
# for X in a:
# if x not in B:
# b.append (x)
# print (b)
# method 2
# a = [' Adam ', ' Lisa ', ' Paul ', ' Adam ', ' Adam ', ' Lisa ']
# a=list (Set (a))
# Print (a)
# Determine if x is in the A list
# a=[' Paul ', ' Lisa ', ' Adam '
# x= ' Adam ' and ' Lisa ' and ' Paul '
# if x in a:
# print (' PASS ')
# Else:
# print (' ERROR ')
Python Daily a basic note