Guest User

Untitled

a guest
Oct 15th, 2019
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.92 KB | None | 0 0
  1. import random, os, shelve
  2.  
  3. #TODO test path for shelve file
  4.  
  5. answerSheet = shelve.open('answerDataWin.db')
  6. stateList = list(answerSheet.keys())
  7. capList = list(answerSheet.values()) #this should not be affected
  8.  
  9. #generate a question file
  10. studentCount = 10
  11. for counter in range(studentCount):
  12.     quizGen = open('quiz%s.txt' %counter, 'w')
  13.     answerGen = open('answer%s.txt' %counter, 'w')
  14.     quizGen.write('Name :\nDate\n\n\n')
  15.     quizGen.write('Circle the correct answers\n\n')
  16.     answerGen.write('Answers for paper %s\n\n' %counter)
  17.     focusCap = stateList #This should reset the list to full state
  18.     random.shuffle(focusCap)
  19.     for questCount in range(len(focusCap)):
  20.         corrAns = answerSheet[focusCap[questCount]]
  21.         wrongAns = capList
  22.         wrongAns.remove(corrAns)
  23.         print('Total of global capList '+ str(len(capList)))
  24.     quizGen.close()
  25.     answerGen.close()
  26.  
  27. answerSheet.close()
Advertisement
Add Comment
Please, Sign In to add comment