Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, os, shelve
- #TODO test path for shelve file
- answerSheet = shelve.open('answerDataWin.db')
- stateList = list(answerSheet.keys())
- capList = list(answerSheet.values()) #this should not be affected
- #generate a question file
- studentCount = 10
- for counter in range(studentCount):
- quizGen = open('quiz%s.txt' %counter, 'w')
- answerGen = open('answer%s.txt' %counter, 'w')
- quizGen.write('Name :\nDate\n\n\n')
- quizGen.write('Circle the correct answers\n\n')
- answerGen.write('Answers for paper %s\n\n' %counter)
- focusCap = stateList #This should reset the list to full state
- random.shuffle(focusCap)
- for questCount in range(len(focusCap)):
- corrAns = answerSheet[focusCap[questCount]]
- wrongAns = capList
- wrongAns.remove(corrAns)
- print('Total of global capList '+ str(len(capList)))
- quizGen.close()
- answerGen.close()
- answerSheet.close()
Advertisement
Add Comment
Please, Sign In to add comment