Quiz App
Decks
Folders
Back
Summary
{deck: {name: "2 How to Design Data"}, score: [{question_type: "multiple_choice", label: "Multiple choice", graded: true, count: 0, total: 0}, {question_type: "short_answer", label: "Short answer", graded: false, count: 8, total: 8}], answers: [{question_prompt: "Define a data definition named LetterGrade that represents exactly the three strings \"A\", \"B\", and \"C\". Include the type comment, an interpretation, and the template for a function that consumes a LetterGrade.", question_type: "short_answer", choices: [], selected_choice: nil, response: "; LetterGrade is one of\n; - \"A\"\n; - \"B\"\n; - \"C\"\n; LetterGrade represents a letter grade as one of A,B or C\n(define (fn-for-lettergrade lg)\n (cond [(string=? \"A\") (... lg)]\n [(string=? \"B\") (... lg)]\n [(string=? \"C\") (... lg)]))", correct: nil}, {question_prompt: "Define a data definition named SeatNum for legal seat numbers from 1 through 32 inclusive. Include the type comment, an interpretation, and the basic template for a function that consumes a SeatNum.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n; SeatNum is [1,32]Integer\n; represents the value of a given seats position\n(define (fn-for-s s) (... s))", correct: nil}, {question_prompt: "Consider this itemization: Status is one of \"closed\" or an Integer from 1 through 10 inclusive. Write a template for a function that consumes a Status. Make sure the numeric test cannot accidentally be applied to the string case.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n; Status is one of\n; - \"closed\"\n; - [1, 10]\n; Status represents the a status of closed or a integer representing how much longer until we are closed\n(define (STATUS1 \"closed\"))\n(define (STATUS2 1))\n(define (STATUS3 10))\n(define (fn-for-status s)\n (cond [(and (number? s) (>= s 0) (<= s 10)) (... s)]\n [(string=? \"closed\") (... s)]))\n", correct: nil}, {question_prompt: "In your own words, explain the difference between a function purpose statement and the interpretation in a data definition.", question_type: "short_answer", choices: [], selected_choice: nil, response: "function purpose defines what the function should do. This mean it states the relationship between the input values and the output values.\n\nThe data interpretation defines how the information of the problem domain is represented as data in the program", correct: nil}, {question_prompt: "Suppose an itemization says a value is either Integer[0,10] or Integer[5,20]. What problem does the value 7 create? If a cond checks the first interval before the second, what will happen?", question_type: "short_answer", choices: [], selected_choice: nil, response: "1. it's difficult to tell which one 7 should be.\n2. Cond will always evaluate true to the first interval for overlapping portions", correct: nil}, {question_prompt: "A parking garage has levels numbered 1 through 8 inclusive. Define a data definition named LevelNum with a precise type comment, an interpretation, and the basic template for a function that consumes a LevelNum.", question_type: "short_answer", choices: [], selected_choice: nil, response: "; LevelNum is Integer[1, 8]\n; LevelNum represents the current floor of a parking garage\n(define (fn-for-level-num ln) (... ln))", correct: nil}, {question_prompt: "TrafficLight is one of the strings \"red\", \"yellow\", or \"green\". Write the data definition and template. In the template, use placeholders for unfinished function behavior rather than accidentally calling the parameter as a function.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n; TrafficLight is one of\n; - \"red\"\n; - \"yellow\"\n; - \"green\"\n; TraffcLight represents the color of a currently on traffic light\n(define (fn-for-tl tl)\n (cond [(string=? \"red\") (... tl)]\n [(string=? \"yellow\") (... tl)]\n [(string=? \"green\") (... tl)]))", correct: nil}, {question_prompt: "A data definition says TemperatureRange is either Integer[-10,10] or Integer[5,30]. Explain why this is a problematic itemization. Then explain what happens to the value 7 if a cond checks the -10-to-10 case before the 5-to-30 case.", question_type: "short_answer", choices: [], selected_choice: nil, response: "This is problematic because you can't tell which one the 7 is suppose to belong to. When you do this with a cond the first one that matches will always trigger. The overlapping portions can never be attributed the first subclass", correct: nil}]}
Copy JSON