Quiz App
Decks
Folders
Back
Summary
{deck: {name: "1b How to Design Functions"}, score: [{question_type: "multiple_choice", label: "Multiple choice", graded: true, count: 15, total: 15}, {question_type: "short_answer", label: "Short answer", graded: false, count: 5, total: 5}], answers: [{question_prompt: "What is the first major step of the HtDF recipe?", question_type: "multiple_choice", choices: ["Signature, purpose, and stub", "Write the final body", "Optimize the function", "Create a data definition"], selected_choice: "Signature, purpose, and stub", response: nil, correct: true}, {question_prompt: "What should a good purpose statement do?", question_type: "multiple_choice", choices: ["Repeat only the input and output types", "Describe the relationship between the consumed data and produced result", "List every primitive used", "State the expected runtime"], selected_choice: "Describe the relationship between the consumed data and produced result", response: nil, correct: true}, {question_prompt: "Why is a stub useful before the real function body is written?", question_type: "multiple_choice", choices: ["It makes all tests pass", "It chooses the final algorithm", "It lets tests call the function and run", "It replaces the signature"], selected_choice: "It lets tests call the function and run", response: nil, correct: true}, {question_prompt: "With a correct stub and meaningful tests for an unfinished function, what is the usual desirable result?", question_type: "multiple_choice", choices: ["Tests all pass", "The program refuses to run", "The template is generated automatically", "Tests run and fail rather than error"], selected_choice: "Tests run and fail rather than error", response: nil, correct: true}, {question_prompt: "What should guide the choice of test expectations?", question_type: "multiple_choice", choices: ["Whatever is easiest to implement", "The current stub output", "The specification and purpose", "The first result the function happens to produce"], selected_choice: "The specification and purpose", response: nil, correct: true}, {question_prompt: "What is the purpose of a function template in early HtDF?", question_type: "multiple_choice", choices: ["To provide the final optimized body", "To show the structural outline and available inputs", "To replace examples", "To define a new data type"], selected_choice: "To show the structural outline and available inputs", response: nil, correct: true}, {question_prompt: "Which is the better signature when a function always produces a non-negative whole number?", question_type: "multiple_choice", choices: ["Image -> Natural", "Any -> Any", "Number -> Number", "Image -> String"], selected_choice: "Image -> Natural", response: nil, correct: true}, {question_prompt: "What does it mean that the HtDF recipe is not a waterfall process?", question_type: "multiple_choice", choices: ["The steps must be performed in reverse order", "Testing is optional", "Only the template matters", "The steps can be revisited when later work reveals a better design"], selected_choice: "The steps can be revisited when later work reveals a better design", response: nil, correct: true}, {question_prompt: "A function tall? has a test only for a tall image. What important problem remains?", question_type: "multiple_choice", choices: ["No constant is defined", "The false branch may be untested", "The function has too many parameters", "Images cannot be used in predicates"], selected_choice: "The false branch may be untested", response: nil, correct: true}, {question_prompt: "If a test fails after the body is implemented, what should you check before changing correct-looking code?", question_type: "multiple_choice", choices: ["Whether the expected value in the test matches the specification", "Whether the function name has a question mark", "Whether all constants are numbers", "Whether the source file is alphabetized"], selected_choice: "Whether the expected value in the test matches the specification", response: nil, correct: true}, {question_prompt: "The specification says a rating is poor when it is less than 4.0. What should happen at exactly 4.0?", question_type: "multiple_choice", choices: ["It must be poor", "The program must error", "It belongs to the next category, not the < 4.0 category", "It can be either category without changing the specification"], selected_choice: "It belongs to the next category, not the < 4.0 category", response: nil, correct: true}, {question_prompt: "Why are verbose expectations such as (* 2 4.2) sometimes useful?", question_type: "multiple_choice", choices: ["They prevent evaluation", "They turn a test into a stub", "They make a Number exact", "They document the intended computation, not just the final literal result"], selected_choice: "They document the intended computation, not just the final literal result", response: nil, correct: true}, {question_prompt: "What does the Racket naming convention tall? communicate?", question_type: "multiple_choice", choices: ["The function is expected to produce a Boolean", "The function mutates data", "The function has no parameters", "The function is a constant"], selected_choice: "The function is expected to produce a Boolean", response: nil, correct: true}, {question_prompt: "Which test set best examines a boundary at 25 where values below 25 and values at/above 25 behave differently?", question_type: "multiple_choice", choices: ["Only 25", "24.9, 25, and a value just above 25", "Only 0 and 100", "Two random values far from 25"], selected_choice: "24.9, 25, and a value just above 25", response: nil, correct: true}, {question_prompt: "Why is changing a correct implementation just to satisfy an incorrect test dangerous?", question_type: "multiple_choice", choices: ["It removes the need for templates", "It makes constants mutable", "It makes the function conform to a mistaken expectation instead of the specification", "It forces Racket to use inexact arithmetic"], selected_choice: "It makes the function conform to a mistaken expectation instead of the specification", response: nil, correct: true}, {question_prompt: "Why is a stub written before the examples/tests in the HtDF recipe, and what should normally happen when meaningful tests are run against an unfinished stub?", question_type: "short_answer", choices: [], selected_choice: nil, response: "Stubs are written to the tests have something to call. This makes it so you can make tests before writing out the entire body of the function.", correct: nil}, {question_prompt: "Write a signature, purpose statement, and stub for a function named double that consumes a Number and produces twice that Number. The stub should produce a valid Number but should not implement the real calculation yet.", question_type: "short_answer", choices: [], selected_choice: nil, response: "; Number -> Number\n; take a number and returns double that value (number)\n(define (double n) 10))", correct: nil}, {question_prompt: "Write a Racket function named passing? that consumes a Number score and produces true when the score is at least 60 and false otherwise.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n; Number -> Boolean\n; Takes a test score (number) and returns whether it is at least 60\n(define (passing? n) (>= n 60))\n```", correct: nil}, {question_prompt: "A function named cheap? should produce true when a price is strictly less than 100. Write three check-expect tests that test the boundary: one value below 100, exactly 100, and one value above 100.", question_type: "short_answer", choices: [], selected_choice: nil, response: "```racket\n(check-expect (cheap? 99) true)\n(check-expect (cheap? 100) false)\n(check-expect (cheap? 105) false)\n``` ", correct: nil}, {question_prompt: "The purpose of area is to produce the area of a square whose side length is n. The function is (define (area n) (* n n)), but a test says (check-expect (area 3) 3) and fails. What should you change, and why?", question_type: "short_answer", choices: [], selected_choice: nil, response: "The test should be\n```racket\n(check-expect (area 3) 9)\n```\nor\n```racket\n(check-expect (area 3) (* 3 3))\n```", correct: nil}]}
Copy JSON