1: |
Identifiers. Why are variable type declarations not used in Python?
|
2: |
Identifiers. Why are variable name declarations not used in Python?
|
3: |
Identifiers. Why should we avoid the use of the underscore to begin variable names with?
|
4: |
Statements. Can multiple Python statements be written on a single line?
|
5: |
Statements. Can a single Python statement be written over multiple lines?
|
6: |
Variable assignment.
(a) Given the assignment x, y, z = 1, 2, 3, what do x, y, and z contain?
(b) What do x, y, and z contain after executing: z, x, y = y, z, x?
|
7: |
Identifiers. Which of the following are valid Python identifiers? If not, why not? Of the invalid ones, which are keywords?
int32 40XL char $aving$ printf print
_print a do this self __name__ 0x40L
boolean python big-daddy 2hot2touch type
thisIsn'tAVar thisIsAVar R_U_Ready yes
if no counter-1 access -
The remaining problems deal with the fgrepwc.py application.
|
8: |
In the fgrepwc.py program above, you will notice the use of the string.find() module. What does this function do, and what are its return values for success and failure?
|
9: |
We briefly discussed module names above with regards to the __name__ variable. What are the contents of this variable if we ran fgrepwc.py directly? What would the contents be if we imported fgrepwc as a module?
|
10: |
The "-i" option is indicated in the usage() function of the fgrepwc module but is not implemented anywhere in the entire application. This option is to perform the search in a case-insensitive manner. Implement this functionality for fgrepwc.py. You may use the getopt module.
|
11: |
fgrepwc.py currently outputs the number of matching lines which contain the search string. Update the script so that it outputs the total number of times the string appears in the text file. In other words, if a match occurs more than once on a line, count all of those additional appearances.
|