-
What are the entries in a dictionary?
key - value pairs
-
Can the key in a dictionary entry be any data type?
no. you can only use values that are immutable, that cannot be changed
-
What string value does Python think of as
False in an if statement?
the empty string
-
Can a value appear more than once in a set?
no
-
If we have the sets A and B with the elements below, what are the elements
formed by the union of A and B?
A = {1, 2, 3}
B = {3, 4, 5}
{1, 2, 3, 4, 5}
-
If we have the sets A and B with the elements below, what are the elements
formed by the intersection of A and B?
A = {1, 2, 3}
B = {3, 4, 5}
{3}
-
Write a Python statement to create the set s2 containing the values
1, 2 and 3, using a set literal.
s2 = {1, 2, 3}
-
Write a statement that adds 5 to the set s1.
s1.add(5)
-
Write the Python expression you would use to get a list of all entries in your current directory.
os.listdir('.')
-
Write the Python expression that gives the value of the first command line argument.
sys.argv[1]
-
What are three things are found in a regular expression?
ordinary characters, meta-characters, character classes
-
What does the . (dot) in a regular expression match?
one occurrence of any character, except the newline
-
What does the * in a regular expression match?
0 or more occurrences of the character that comes before it
-
What does the + in a regular expression match?
1 or more occurrences of the character that comes before it
-
What is a greedy match?
a match with the greatest number of characters
The following questions require you to write code.