ISYS final review (ch.8-12)
What is the index of the first character in a string?
0
A program creates 10 instances of theCoinclass. How many_ _sideupattributes exist in memory? A. 0 B. 1 C. 10
10
What will the following code display? mystring = 'abcdefg' print(mystring[:]) A. abcdefg B. a C. g D. an empty string
A. abcdefg
What will the following code display? stuff = {1 : 'aaa', 2 : 'bbb', 3 : 'ccc'} print(stuff[3]) A. ccc B. bbbccc C. aaabbbccc D. c
A. ccc
An element in a dictionary has two parts. What are they called? A. key and value B. key and def C. id and link D. id and key
A. key and value
Which part of a dictionary element must be immutable? A. the key B. the value
A. the key
After the following code executes, what elements will be members of set3? set1 = set([1, 2, 3, 4]) set2 = set([3, 4, 5, 6]) set3 = set2.difference(set1) A. {5, 6} B. {1, 2, 3, 4} C. {1, 2, 3, 4} D. {1, 2}
A. {5, 6}
A(n) ________ attribute belongs to a specific instance of a class. A. child B. instance C. class D. global
B. instance
What will the following code display? mystring = 'abcdefg' print(mystring[:3]) A. c B. defg C. abc D. d
C. abc
What will the following code display? stuff = {1 : 'aaa', 2 : 'bbb', 3 : 'ccc'} for k in stuff: print(k) A. aaa bbb ccc B. 3 C. ccc D. 1 2 3
D
Suppose a dictionary named employee has been created, and an assignment has been made as follows. employee['id'] = 54321 Which key-value pair has been stored in the dictionary? A. 'employee' : 54321 B. employee : 54321 C. 'id' : employee D. 'id' : 54321
D. 'id' : 54321
What will the following code display? mystring = 'abcdefg' print(mystring[3:]) A. abcd B. c C. d D. defg
D. defg
The ________ method return all the values in the dictionary as a sequence of tuples. A. index B. keys C. map D. values
D. values
A class's actions must be explicitly mentioned in the problem domain description.
False
A subclass inherits all of its superclass's attributes.
True
A function that ________ is known as a recursive function. A. stores itself B. stores another function C. calls itself D. calls another function
calls itself
Write the definition of a class named Counter that provides the following methods:• An __init__ method that initializes an attribute variable named counter to the value 0.• A method named increment that adds 1 to the counter attribute variable. It should not accept arguments or return a value.• A method named get_value that accepts no arguments, and returns the value of the counter attribute.
class Counter: counter = 0 def increment(self): self.counter += 1 def get_value(self): return self.counter
Write a statement that associates d with a one-entry dictionary that maps the str 'answer' to the int value 42.
d = {'answer':42}
Given a dictionary d, create a new dictionary that reverses the keys and values of d. Thus, the keys of d become the values of the new dictionary and the values of d become the keys of the new dictionary. You may assume d contains no duplicate values (that is, no two keys map to the same values.) Associate the new dictionary with the variable inverse.
inverse = {} for key in d.keys() : val = d[key] inverse[val] = key
When one object is a specialized version of another object, the specialized object ________ version of the general object. A. has a B. is a
is a
A class's responsibilities include the things that the class is responsible for _________ and the actions that the class is responsible for _________. A. propagating; analyzing B. knowing; doing C. planning; revising D. managing; implementing
knowing; doing
Given variables first and last, each of which is associated with a string, representing a first and a last name, respectively. Write an expression whose value is a string that is a full name of the form "Last, First". So, if first were associated with "alan" and last with "turing", then your expression would be "Turing,Alan". (Note the capitalization! Note: no spaces!) And if first and last were "Florean" and "fortescue" respectively, then your expression's value would be "Fortescue,Florean".
last[0].upper() + last[1:] + "," + first[0].upper() + first[1:]
The typical UML diagram for a class has three sections. Indicate the correct section in the statements below. The ________ section holds a list of the class's fields. The ________ section holds a list of the class's methods. The ________ section is where you write the name of the class. A. top; middle; bottom B. middle; bottom; top C. top; bottom; middle D. bottom; top; middle
middle; bottom; top
Remove the smallest element from the set, s. Assume the set is not empty.
min = None for e in s : if min == None or e < min : min = e s.remove(min)
Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on, off, and setting the desired temperature. The following methods are provided for these behaviors: turn_on and turn_off, which accept no arguments and return no value, and set_temp, which accepts an int argument and returns no value. There is a reference variable my_ac to an object of this class, which has already been created. Invoke a method telling the object to set the air conditioner to 72 degrees.
my_ac.set_temp(72);
Assume that name is a variable of type string that has been assigned a value. Write an expression whose value is a string containing the first character of the value of name. So if the value of name were "Smith" the expression's value would be "S".
name[0]
In this program, we have created a dictionary of course numbers and titles. Provide a print statement to display the dictionary as indicated in this output course = {'2022' : 'Introduction to Programming', '2023' : 'Intermediate Programming', '3022' : 'Operating Systems' }
print (course.items())
When an object's internal data is hidden from outside code and access to that data is restricted to the object's methods, the data can be _________. A. inaccessible to even the object's methods B. copied and modified remotely C. shared across freely across objects D. protected from accidental corruption
protected from accidental corruption
Write an expression that is the concatenation of the strings "Hello" and "World".
'Hello' + 'World'
When you open a file for the purpose of retrieving a pickled object from it, what file access mode would you use? A. 'rb' B. 'gb' C. 'eb' D. 'wb'
'rb'
Suppose 'start' : 1472 is an element in a dictionary. _________ is the key, and _________ is the value.
'start' , 1472
When you open a file for the purpose of saving a pickled object to it, what file access mode would you use? A. 'rb' B. 'gb' C. 'eb' D. 'wb'
'wb'
Assume the availability of a function named printStars that can be passed a parameter containing a non-negative integer value. The function prints out the given number of asterisks. Write a function named printTriangle that receives a parameter that holds a non-negative integer value and prints a triangle of asterisks as follows: first a line of n asterisks, followed by a line of n-1 askterisks, and then a line of n-2 asterisks, and so on. For example, if the function received 5, it would print: ***** **** *** ** * The function must not use a loop of any kind (for, while, do-while) to accomplish its job. The function should invoke printStars to accom;lish the task of printing a single line.
) def printTriangle(n): printStars(n) if n > 1: print() printTriangle(n-1)
What will the following code display? stuff = {1 : 'aaa', 2 : 'bbb', 3 : 'ccc'} print(len(stuff)) A. 2 B. 3 C. 0 D. 1
3
If a string has 10 characters, what is the index of the last character?
9
After the following statement executes, what elements will be stored in themysetset? myset = set([1, 2, 2, 3, 4, 4, 4]) A. The set will contain these elements (in no particular order): 1, 2, 3, and 4. B. The set will contain these elements in this order: 1, 2, 3, and 4. C. The set will contain these elements (in no particular order): 1, 22, 3, and 444. D. The set will contain these elements in this order: 1,22,3, and 444.
A. The set will contain these elements (in no particular order): 1, 2, 3, and 4.
How do you determine the number of elements in a set? A. You pass the set as an argument to the len function. B. You sort the set and then run a nodup function. C. You pass the elements of the set to the len function. D. You use the built-in len function within the set.
A. You pass the set as an argument to the len function.
After the following code executes, what elements will be members of set3? set1 = set([1, 2, 3, 4]) set2 = set([3, 4, 5, 6]) set3 = set1.intersection(set2) A. {3, 4} B. { } C. {1, 2, 3, 4, 5, 6} D. {1, 2, 5, 6}
A. {3, 4}
After the following statement executes, what element might be stored in the myset set? myset = set(['www', 'xxx', 'yyy', 'zzz']) A. 'xyz' B. 'yyy' C. 'zz' D. 'x'
B. 'yyy'
Which function will return the length of a string? A. length B. len C. sringlens
B. len
The items method returns all a dictionary's keys and their associated values as a __________. A. set of two lists B. sequence of tuples C. key map D. sorted list
B. sequence of tuples
Look at the following code, what is the name of the superclass? What is the name of the subclass? class Canary(Bird): Canary is the superclass, and Bird is the subclass. Bird is the superclass, and Canary is the subclass.
Bird is the superclass, and Canary is the subclass.
After the following statement executes, what elements might be stored in the myset set? myset = set('www xxx yyy zzz') A. 'www xxx yyy zzz' B. 'ww' , 'xx' , 'yy' , 'zz' C. 'z' , 'x' , 'y' , 'w' D. 'zyxw', 'zyxw', 'zyxw'
C. 'z' , 'x' , 'y' , 'w'
After the following statement executes, what elements will be stored in the mysetset? myset = set(25) A. The set will contain all 25 elements B. The set will contain the value at the 25th indexed location C. The set will contain one element: 25
C. The set will contain one element: 25
The keys method returns __________. A. one key at a specified index B. one value in a dictionary C. all the keys in a dictionary D. all the values in a dictionary
C. all the keys in a dictionary
An object is a software entity that contains ________. A. only procedures B. only data C. both data and procedures D. neither data or procedures
C. both data and procedures
There is something wrong with this code: animal = 'Tiger' animal[0] = 'L' Namely, strings are _________, so the expression _________ cannot appear on the left side of an assignment operator. A. immutable; animal B. mutable; animal [0] C. immutable; animal [0] D. mutable; animal
C. immutable; animal[0]
To determine whether a key-value pair exists in a dictionary, use the __________ operator. A. find B. pair C. in D. exists
C. in
You can create an empty set with the built-in _________ function. A. build B. init C. set D. create
C. set
What will the following code display? mystring = 'abcdefg' print(mystring[2:5]) A. cdef B. cf C. bcde D. cde
D. cde
After the following code executes, what elements will be members of set3? set1 = set([1, 2, 3, 4]) set2 = set([3, 4, 5, 6]) set3 = set1.difference(set2) A. {5, 6} B. {1, 2, 3, 4} C. {1, 2, 3, 4} D. {1, 2}
D. {1, 2}
After the following code executes, what elements will be members of set3? set1 = set([10, 20, 30]) set2 = set([100, 200, 300]) set3 = set1.union(set2) A. {} B. {10, 20, 30} C. {100, 200, 300} D. {10, 20, 30, 100, 200, 300}
D. {10, 20, 30, 100, 200, 300}
In direct recursion, method A calls method B, which in turn calls method A.
False
Public methods cannot be accessed by entities outside an object.
False
Recursive function calls are more efficient than loops.
False
The elements of a set are ordered.
False
The pop method returns a randomly selected key-value pair, as a tuple, and removes that key-value pair from the dictionary.
False
Look at the following class definitions: class Vegetable: def _ _init_ _(self, vegtype): self._ _vegtype = vegtype def message(self): print("I'm a vegetable.") class Potato(Vegetable): def _ _init_ _(self): Vegetable._ _init_ _(self, 'potato') def message(self): print("I'm a potato.") Given these class definitions, what will the following statements display? v = Vegetable('veggie') p = Potato() v.message() p.message() A. I'm a vegetable. B. I'm a potato C. I'm a vegetable I'm a potato
I'm a vegetable I'm a potato
What is the first step in identifying the potential classes in a problem domain description? Identify the nouns and pronouns in the problem domain description. List items that represent simple values that can be stored in variables. Refine the list to eliminate duplicates. Filter items that represent objects instead of classes.
Identify the nouns and pronouns in the problem domain description.
What is the main purpose of the_ _init_ _method? Initiate communication with other methods. Start a driver program for the method. Schedule code execution testing Initialize an object's data attributes.
Initialize an object's data attributes.
What is the purpose of the_ _str_ _method? It converts a string into an object equivalent. It returns a string representation of an object. It allocates space for any object lists. It designates a string key for an object.
It returns a string representation of an object.
In this chapter, we use the metaphor of a cookie cutter and cookies that are made from the cookie cutter to describe classes and objects. In this metaphor, are objects the cookie cutter, or the cookies? Objects are the cookie cutters. Objects are the cookies.
Objects are the cookies.
You hear someone make the following comment: "A blueprint is a design for a house. A carpenter can use the blueprint to build the house. If the carpenter wishes, he or she can build several identical houses from the same blueprint." Think of this as a metaphor for classes and objects. Does the blueprint represent a class, or does it represent an object? The metaphor of a blueprint represents a class. The metaphor of a blueprint represents an object.
The metaphor of a blueprint represents a class.
After the following statement executes, what elements will be stored in the myset set? myset = set([10, 9, 8]) myset.update([1, 2, 3]) A. The set will contain these elements (in no particular order): 10, 9, 8, 1, 2, and 3. B. The set will contain these elements (in no particular order): 1, 2, and 3
The set will contain these elements (in no particular order): 10, 9, 8, 1, 2, and3.
A base case can be solved without recursion.
True
A recursive algorithm has more overhead than an iterative algorithm because it requires multiple method calls.
True
A set does not allow you to store duplicate elements
True
After the following statement executes, think about what elements will be stored in the myset set. myset = set('Jupiter') True or False: The set will contain these elements: 'J', 'u', 'p', 'i', 't', 'e', and'r'.
True
An IndexError exception will occur if you try to use an index that is out of range for a particular string.
True
If a recursive solution is evident for a particular problem, it may be a good choice if it does not slow system performance significantly.
True
If a specified element to delete is not in a set, the remove method raises a KeyError exception, but the discard method will not raise such an exception.
True
If you do not thoroughly understand the nature of a problem, you should have an expert write the problem domain description for you.
True
Suppose a dictionary named inventory exists. The statement below will delete the element that has the key 654. del inventory[654]
True
The majority of repetitive programming tasks are best done with loops.
True
You need to import thepicklemodule if you want to pickle objects.
True
Given that d refers to a dictionary, change the value mapped to by the key 'Monty' to 'Python'.
['Monty'] = 'Python'
A method that returns a value from a class's attribute but does not change it is known as a(n) ________ method. A method that stores a value in a data attribute or changes the value of a data attribute in some other way is known as a(n) _________ method. A. mutator; accessor B. accessor; mutator
accessor; mutator
Assume there is a variable, album_artists, that is associated with a dictionary that maps albums to performing artists. Write a statement that inserts the key/value pair: "Live It Out"/"Metric".
album_artists["Live It Out"]="Metric"
The combining of data and code into a single object is known as ___________. A. labeling B. encapsulation C. typing D. identification
b. encapsulation
Object serialization is the process of converting the object to a stream of ________ that can be saved to a file for later retrieval. A. keys B. bytes C. symbols D. characters
bytes
Write the class Calculator including: a function called addthat takes two parameters containing double values and returns their sum a function called subtractthat takes two parameters containing double values and returns their difference (subtract the second from the first) a function called multiply that takes two parameters containing double values and returns their product a function called divide that takes two parameters containing double values and returns the value of the first divided by the second. If the second number is a zero, do not divide, and return "You can't divide by zero!"
class Calculator: def add(self, num1, num2): return num1 + num2 def subtract(self, num1, num2): return num1 - num2 def multiply(self, num1, num2): return num1*num2 def divide(self, num1, num2): if num2==0: return "You can't divide by zero!" else: return num1/num2
Write the definition of a class WeatherForecast that provides the following methods:• An __init__ method that initializes the following attribute variables:An attribute variable named skies should be assigned an empty string.An attribute variable named high should be assigned the value 0.An attribute variable named low should be assigned the value 0.• A method named set_skies that accepts one argument, a string. The argument's value should be assigned to the attribute variable skies.• A method named set_high that accepts one argument, an int. The argument's value should be assigned to the attribute variable high.• A method named set_low that accepts one argument, an int. The argument's value should be assigned to the attribute variable low.• A method named get_skies that has no parameters and returns the value of the skies attribute.• A method named get_high that has no parameters and returns the value of the high attribute.• A method named get_low that has no parameters and returns the value of the low attribute.
class WeatherForecast: skies = ""; high = 0; low = 0; def set_skies(self, skies): self.skies = skies def set_high(self, high): self.high = high def set_low(self,low): self.low = low def get_skies(self): return self.skies def get_high(self): return self.high def get_low(self): return self.low
Given that d refers to a dictionary, write an expression that is the value to which the dictionary maps the key 'answer'.
d['answer']
Write a function called fact that recursively calculates the factorial value of its parameter, which is an integer value.
def fact(n): if n==0 or n==1: return 1 else: return n * fact(n-1)
Write a recursive function, len, that accepts a parameter that holds a string value, and returns the number of characters in the string. The length of the string is: 0 if the string is empy ("") 1 more than the length of the string beyond the first character
def len(string): if string == "": return 0 else: return 1 + len(string[1:])
Write a function called printStars. The function receives a parameter containing an integer value. If the parameter is positive, the funciton prints (to standard output) the given number of asterisks. Otherwise the function does nothing. The function does not return a value. Thus, if printStars(8) is called, ******** (8 asterisks) will be printed. The function must not use a loop of any kind (for, while, do-while) to accomplish its job. Instead, it should examine its parameter, returning if the parameters value is not positive. If the parameter is positive, it: prints a single asterisk (and no other characters) then crecursively calls itself to print the remaining asterisks
def printStars(num): if num > 0: print("*", end="") printStars(num-1)
Write a recursive function, reverse, that accepts a parameter containing a string value and returns the original string in reverse. For example, calling reverse('goodbye') would return 'eybdoog'. Reversing a string involves: No action if the string is empty or only has 1 character Concatenating the last character with the result of reversing the string consisting of the second through next-to-last character, followed by the first character
def reverse(string): if len(string) == 0 or len(string) == 1: return string else: return string[len(string)-1] + reverse(string[:-1])
The variable planet_distances is associated with a dictionary that maps planet names to planetary distances from the sun. Write a statement that deletes the entry for the planet name "Pluto".
del planet_distances["Pluto"]
The number of times that a function calls itself is known as the ________ of recursion. A. nature B. magnitude C. depth D. problem
depth
Assume you have two lists list1 and list2 that are of the same length. Create a dictionary that maps each element of list1 to the corresponding element of list2. Associate the dictionary with the variable dict1.
dict1 = {} for i in range(len(list1)) : dict1[list1[i]] = list2[i]
A problem _________ is a written description of the real-world objects, parties, and major events related to the problem. A. solution B. domain C. proposal D. category
domain
In this program, we intersect two lists to find cities with similar attributes, and print these out one line at a time. To do this, we can use a for loop with the set's intersection function. Given the code below, supply the appropriate for loop statement to display the expected output. tech_cities = set(['San Franscisco', 'New York', 'Austin', 'New Orleans']) jazz_cities = set(['New Orleans', 'New York', 'Chicago', 'Memphis']) __________:⋅⋅⋅⋅print(jazzy_tech)Fill in the blank, which is a for loop.Expected Output New York New Orleans
for jazzy_tech in tech_cities.intersection(jazz_cities)
A superclass is a ________ class, and a subclass is a ________class. A. general; specialized B. specialized; general
general; specialized
Write an if statement using the in operator that determines whether 'd' is in my_string. A print statement that might be placed after the if statement is included.# What goes here? print('Yes, it is there.')
if 'd' in my_string:
A recursive function must have some way to control the number of times it repeats to avoid a(n) _________. A. exception B. infinite loop C. warning D. syntax error
infinite loop
Assume the variable big references a string. Write a statement that converts the string it references to lowercase and assigns the converted string to the variable little.
little = big.lower()
Given the dictionary, d, find the largest key in the dictionary and associate the corresponding value with the variable val_of_max. For example, given the dictionary {5:3, 4:1, 12:2}, 2 would be associated with val_of_max. Assume d is not empty.
maxKey = list(d.keys())[0] for k in d.keys() : if k > maxKey : maxKey = k val_of_max = d[maxKey]
Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that deactivates the alarm, and armed which contains a boolean describing whether or not the alarm is activated.Alarm has a function changeCode that takes two parameters containing Strings, the first representing the current code, and the second representing the new code. If the user inputs the current code correctly, the value of code is changed to that of the new code. Call the changeCode function on the Alarm object myAlarm, whose current code is "3456", and change the code to "7921".
myAlarm.changeCode("3456", "7921")
Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that deactivates the alarm, and armed which contains a boolean describing whether or not the alarm is activated.Alarm has a function disarm that changes the value of armed to False if the user gives a parameter containing the string that represents the alarm's code. Call the disarm function on the Alarm object myAlarm and give it the code "93478".
myAlarm.disarm("93478")
Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The following methods are provided for these behaviors: turn_on and turn_off. Both methods accept no arguments and return no value. There is a reference variable my_ac to an object of this class, which has already been created. Invoke a method to turn the air conditioner off.
my_ac.turn_off();
Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The following methods are provided for these behaviors: turn_on and turn_off. Both methods accept no arguments and return no value. There is a reference variable my_ac to an object of this class, which has already been created. Invoke a method to turn the air conditioner on.
my_ac.turn_on();
Given three dictionaries, associated with the variables, canadian_capitals, mexican_capitals, and us_capitals, that map provinces or states to their respective capitals, create a new dictionary that combines these three dictionaries, and associate it with a variable, nafta_capitals.
nafta_capitals = {} for key in us_capitals : nafta_capitals[key] = us_capitals[key] for key in canadian_capitals : nafta_capitals[key] = canadian_capitals[key] for key in mexican_capitals : nafta_capitals[key] = mexican_capitals[key]
Write an expression whose value is the concatenation of the three strigs name1, name2, and name3, separated by commas. So if name1, name2, and name3, were (respectively) "Neville", "Dean", and "Seamus", your expression's value would be "Neville,Dean,Seamus".
name1 + ',' + name2 + ',' + name3
Suppose there is a class AirConditioner. The class supports the following behaviors: turning the air conditioner on and off. The following methods are provided for these behaviors: turn_on and turn_off. Both methods accept no arguments and return no value. There is a reference variable office_a_c of type AirConditioner. Create a new object of type AirConditioner using the office_a_c reference variable. After that, turn the air conditioner on using the reference to the new object.
office_a_c= AirConditioner() office_a_c.turn_on()
What function can you call to pickle an object? A. pickle.load B. pickle.dump C. pickle.init D. pickle.get
pickle.dump
What function can you call to retrieve and unpickle an object? A. pickle.load B. pickle.dump C. pickle.init D. pickle.get
pickle.load
A recursive algorithm stops calling itself when it ________. A. meets a benchmark B. is told to do so C. reaches the base case
reaches the base case
Write a statement that associates s with the empty set.
s = set()
Write a statement that associates s with a set that contains the following elements: 23, 42, -11, 89.
s = set([23,42,-11,89])
Assume the variable s has been assigned a value, and the variable the_set refers to a set. Write an expression that whose value is True if the value that is referenced by s is in the_set.
s in the_set
Given that s refers to a set, write a statement that adds integer 42 to the set.
s.add(42)
Given that s refers to a set, write a statement that attempts to remove integer 11 from the set, but will do nothing if 11 is not in the set.
s.discard(11)
Write an expression that returns True if string s ends with "ism".
s.endswith('ism')
Write an expression whose value is True if all the letters in string s are all lowercase.
s.islower()
Write an expression whose value is True if all the letters in string s are uppercase.
s.isupper()
Given that s refers to a set, write a statement that removes integer 5 from the set.
s.remove(5)
Write an expression that evaluates to True if string s starts with "p".
s.startswith('p')
Write an expression that is the concatenation of two strings s1 and s2.
s1 + s2
Write an expression whose value is the last character in string s.
s[-1]
Write an expression whose value is the string that consists of the second through fifth characters of string s.
s[1:5]
Write an expression whose value is the character at index 3 of string s.
s[3]
Write an expression whose value is the string consisting of all the characters (starting with the sixth) of string s.
s[5:]
Write an expression whose value is the string that consists of the first four characters of string s.
s[:4]
When a method is called, Python automatically makes its ________ parameter reference the specific object that the method is supposed to operate on. A. this B. my C. object D. self
self
Consider the following code: set1 = set([1, 2, 3, 4]) set2 = set([2, 3]) Which set is a superset and which is a subset? set2 is a subset of set1, and set1 is a superset of set 2. Both set1 and set2 are subsets. Both set1 and set2 are supersets. set1 is a subset of set2, and set2 is a superset of set1.
set2 is a subset of set1, and set1 is a superset of set 2.
Create a dictionary that maps the first n counting numbers to their squares. Associate the dictionary with the variable squares.
squares = {} for i in range(1, n+1) : squares[i] = i * i
You call the_ _str_ _method by passing the object to the built-in ________ method. A. convert B. string C. str D. con
str
In a Python class, you can hide an attribute from code outside the class by starting the attribute's name with __________. an exclamation point (!) two underscores (_ _) two comment tags (##) an ampersand (&)
two underscores (_ _)
Given a variable, us_cabinet, that is associated with a dictionary that maps department names to department heads, replace the value "Gonzalez" with "Mukasey" for the key "Justice Department".
us_cabinet["Justice Department"] = "Mukasey"
Given the string line, create a set of all the vowels in line. Associate the set with the variable vowels.
vowels = set() for c in line : if "aeiou".find(c) >= 0 : vowels.add(c)
After the following code executes, what elements will be members of set3? set1 = set(['a', 'b', 'c']) set2 = set(['b', 'c', 'd']) set3 = set1.symmetric_difference(set2) {'a'} {'a', 'd'} {'b', 'c'} {'d'}
{'a', 'd'}