Score: 23/25

Q20

A large spreadsheet contains the following information about local restaurants. A sample portion of the spreadsheet is shown below. In column B, the price range represents the typical cost of a meal, where “lo” indicates under $10, “med” indicates $11 to $30, and “hi” indicates over $30. In column D, the average customer rating is set to -1.0 for restaurants that have no customer ratings. A student wants to count the number of restaurants in the spreadsheet whose price range is $30 or less and whose average customer rating is at least 4.0. For a given row in the spreadsheet, suppose prcRange contains the price range as a string and avgRating contains the average customer rating as a decimal number.

Which of the following expressions will evaluate to true if the restaurant should be counted and evaluates to false otherwise?

A. (avgRating ≥ 4.0) AND ((prcRange = “lo”) AND (prcRange = “med”)) B. (avgRating ≥ 4.0) AND ((prcRange = “lo”) OR (prcRange = “med”)) C.(avgRating ≥ 4.0) OR ((prcRange = “lo”) AND (prcRange = “med”)) D. (avgRating ≥ 4.0) OR ((prcRange = “lo”) OR (prcRange = “med”))

Explanation

The question asks students to count the number of restaurants in a spreadsheet that meet two specific criteria: their price range had to be $30 or less and their average customer rating had to be at least 4.0. We were provided with a sample portion of the spreadsheet that contained information about local restaurants, where the price range was represented by a string and the average customer rating was set to -1.0 for restaurants that had no customer ratings.

The task was to write a logical expression that evaluates to true if a restaurant meets the given criteria and evaluates to false otherwise. The expression had to use logical operators and conditionals to check if the price range is $30 or less and if the average customer rating is at least 4.0.

To write the expression, I first needed to understand the given criteria and the data provided in the spreadsheet. I noted that the price range was represented by the strings “lo,” “med,” and “hi,” where “lo” indicated a cost of under $10, “med” indicated a cost of $11 to $30, and “hi” indicated a cost over $30. Additionally, the average customer rating was set to -1.0 for restaurants that had no customer ratings.

Given this information, I started to analyze the options provided in the quiz. Option A stated that the expression would evaluate to true if the average rating was greater than or equal to 4.0 and if the price range was both “lo” and “med.” However, this was not a correct expression since a restaurant cannot have both “lo” and “med” as a price range. Thus, Option A would always evaluate to false, and it would not count any restaurants that met the criteria.

Option B, on the other hand, correctly used the logical OR operator to include restaurants that had a price range of either “lo” or “med” and a customer rating of at least 4.0. This expression would evaluate to true if either of the conditions was met, ensuring that restaurants meeting the criteria would be counted.

Q21

A large spreadsheet contains information about the photographs in a museum’s collection. A sample portion of the spreadsheet is shown below.

In column A, each unknown photographer is set to “(unknown)”. In column C, each unknown year is set to -1.

A student is developing an algorithm to determine the name of the photographer who took the oldest photograph in the collection. Photographs whose photographer or year are unknown are to be ignored.

Once the algorithm is complete, the desired entry will appear in the first row of the spreadsheet. If there are multiple entries that meet the desired criteria, then any of them can appear in the first row.

Which of the following sequences of steps can be used to identify the desired entry?

Select two answers.

A. Filter by photographer, then filter by year, then sort by subject B. Filter by photographer, then filter by year, then sort by year C. Sort by subject, then sort by year, then filter by photographer D. Sort by year, then filter by year, then filter by photographer

Explanation

In this problem, a student is developing an algorithm to determine the name of the photographer who took the oldest photograph in the collection. Photographs whose photographer or year are unknown are to be ignored.

The student has the following actions available: filter by photographer, filter by year, sort by subject, and sort by year. Applying either of the filters will not change the relative order of the rows remaining in the spreadsheet.

The desired entry will appear in the first row of the spreadsheet. If there are multiple entries that meet the desired criteria, then any of them can appear in the first row.

Option A suggests filtering by photographer, then filtering by year, and then sorting by subject. Filtering by photographer will remove the entries whose photographer is unknown. However, this does not guarantee that the oldest photograph will be selected, as there could be multiple photographs from different photographers. Additionally, sorting by subject alphabetically will not provide any useful information in determining the oldest photograph in the collection.

Option C suggests sorting by subject, then sorting by year, and then filtering by photographer. However, sorting by subject alphabetically does not provide any useful information in determining the oldest photograph in the collection. Furthermore, filtering by photographer after sorting by year does not ensure that the desired entry will appear in the first row of the spreadsheet.

Option B suggests filtering by photographer, then filtering by year, and then sorting by year. Filtering by photographer will remove the entries whose photographer is unknown. Filtering by year will remove the entries whose year is unknown. Sorting by year will arrange the photographs in the order of the oldest to the most recent. Thus, the first row of the spreadsheet will contain the oldest photograph in the collection.

Option D suggests sorting by year, then filtering by year, and then filtering by photographer. Sorting by year will arrange the photographs in the order of the oldest to the most recent. Filtering by year will remove the entries whose year is unknown. Filtering by photographer after sorting by year will ensure that the desired entry will appear in the first row of the spreadsheet.

Therefore, options B and D can be used to identify the desired entry.