-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen_example_ques.py
More file actions
28 lines (25 loc) · 960 Bytes
/
Copy pathgen_example_ques.py
File metadata and controls
28 lines (25 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import openpyxl
import random
questions = [['no', 'question', 'cho1', 'cho2', 'cho3', 'cho4', 'ans', 'pic']]
groups = ['M']
cats = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H']
for group in groups:
for cat in cats:
# generate 10 questions per each group-cat
for x in range (1, 11):
# ques_num = group + f"{x:02}" + cat
ques_num = f"{x:02}" + cat
question = f"This is question {ques_num} for the VM written test."
answer = random.randint(1, 4)
pic_no = random.randint(1, 30)
if pic_no <= 7:
pic = f"{pic_no}.jpg"
else:
pic = ""
questions.append([ques_num, question, "choice 1", "choice 2", "choice 3", "choice 4", answer, pic])
workbook = openpyxl.Workbook()
# Select the default sheet (usually named 'Sheet')
sheet = workbook.active
for item in questions:
sheet.append(item)
workbook.save("questions_VM.xlsx")