Advertisement
Luninariel

Flashcard Instructions

Sep 12th, 2019
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. Procedure
  2.  
  3. You'll develop a script. Create a new file in IDLE and save it as prg1.py. Also download the flashcards.txt available with the course files on Canvas to test your program with. This file contains terms followed by their definitions, one pair per line. Each term is separated from its definition by a colon.
  4.  
  5. You may collaborate with up to 2 other students on this lab if you wish, but you must have your collaborators approved by the instructor at least one week before the due date and agree that all students will receive the same grade. You may not share code with any students that are not in your group. Make sure your code is well documented, with a docstrings used at every appropriate opportunity.
  6. What to turn in
  7.  
  8. Once you're finished, turn in the prg1.py file that you created.
  9. Instructions
  10.  
  11. At the beginning of your script, read in all the values from the flashcards.txt file line by line (assume it is in your working directory -- don't hard-code a path). You'll need to split the line in to two separate values (the term and the definition). Trim off any leading or trailing whitespace from these strings. You can use any data structure you want, but realize that this assignment was designed with dictionaries in mind.
  12.  
  13. Next, enter an indefinite loop in which you prompt the user with a random definition from the file. Read a line of input from the user and check to see if they correctly identified the matching term from the file (again, trim leading or trailing whitespace, and ignore case).
  14.  
  15. If the user types "exit", break out of the loop and print out how many answers the user got correct and how many attempts they made.
  16.  
  17. Sample Interactions
  18.  
  19. Definition: a typing scheme which determines types are compatible as long as the requested methods or properties are present within the object
  20. What term does this define? goose
  21. Wrong!
  22. Correct answer: duck
  23. Definition: a sequence of statements and other blocks in a program
  24. What term does this define? block
  25. Correct!
  26. Definition: a language construct that is unnecessary but perhaps makes code shorter or easier to read
  27. What term does this define? not programming at all
  28. Wrong!
  29. Correct answer: syntactic sugar
  30. Definition: a datastructure which does not support order or multiplicity of elements and is mutable
  31. What term does this define? set
  32. Correct!
  33. Definition: collection of variable bindings available within a certain scope of a program
  34. What term does this define? quit
  35. Total Questions: 4
  36. Total Correct: 2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement