-
Write the Python expression you would use to get the pathname of your current directory.
os.getcwd()
-
What three things are found in a regular expression?
ordinary characters, meta-characters, character classes
-
Write the Python statement to create an empty set named s1.
s1 = set()
-
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}
-
Write the Python expression you would use to get the number of entries in a dictionary
named students.
len(students)
-
Can a value appear more than once in a set?
no
-
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 regular expression would you write if you wanted to match a
SINGLE lowercase character?
[a-z]
-
Write a Python expression to see if the set s1
DOES NOT contain 12.
12 not in s1
-
What string value does Python think of as
True
in an if
statement?
anything that is not the empty string
-
What does the \ do in a regular expression?
turns off the special meaning of the character that comes after it
-
Write the Python expression that gives the value of the first command line argument.
sys.argv[1]
-
Write a Python expression that returns the largest element in the set A.
max(A)
-
What is the name of the module that allows you to interact with the operating system?
os
-
What are the entries in a dictionary?
key - value pairs
The following questions require you to write code.