This quiz must be submitted in Gradescope by 12:00pm CST on Tuesday, March 16, 2021.
The course topics corresponding to this quiz are tree traversals, set, defaultdict, CSV, and JSON.
Quizzes are INDIVIDUAL, closed book, and only allow access to specified resources. For this quiz you can access:
There are two problems on this quiz, numbered 2 and 3. The point breakdown is:
Points | Item |
---|---|
3 | autograder |
4 | problem 2 |
4 | problem 3 |
11 | total |
Write a program that takes one command line argument, which is the filename of an existing CSV file that has a header row. The program should read the CSV file and determine whether any of the values in its rows are equal to the empty string. For each such "missing value" found, the program should print a message in this format:
Missing value in column Quiz9Score on line 58.
The line numbers should be 1-based, so line 1 refers to the header row (which you can assume does not have any missing values), line 2 refers to the first row of actual data, etc.
For example, if the input CSV file is
Moon,Planet,YearDiscovered
Phobos,Mars,1877
Callisto,Jupiter,1610
,Saturn,2019
Eros,"",
then the expected output is
Missing value in column Moon on line 4.
Missing value in column Planet on line 5.
Missing value in column YearDiscovered on line 5.
Upload this program as quiz9prob2.py
.
Suppose S is a set of strings. Let's say that a string in S is decomposable if it can be written as A+B where A and B are both in S.
For example, in the set {"racecar","carrot","car","race","rot","cog","c","a","r"}
, the string "racecar"
is decomposabe because it can be written as "race"+"car"
and "carrot"
is decomposable because it can be written as "car"+"rot"
, but none of the other elements of the set are decomposable.
Write a function indecomposables(S)
which accepts one argument, a set object S
whose elements are strings, and which returns the set of all elements of S
that are not decomposable.
Use only sets in your function; do not use lists, tuples, or dictionaries. Also, calling the function should not modify S
.
Put this function in a file quiz9prob3.py
and upload it.