-
Notifications
You must be signed in to change notification settings - Fork 0
/
MCQ_generator.py
113 lines (82 loc) · 3.38 KB
/
MCQ_generator.py
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
from random import choice
import random
import xlrd
file = open(r"C:\Users\Nihar Sanda\Desktop\DataStructure\paper1.txt","w")
f2 = open(r"C:\Users\Nihar Sanda\Desktop\DataStructure\answer1.txt","w")
i=1
for i in range(1,7):
wb = xlrd.open_workbook(r"C:\Users\Nihar Sanda\Desktop\DataStructure\CurrencyDataFile.xlsx")
sh1 = wb.sheet_by_index(0)
column =2
x = choice(sh1.col(column)).value
file.write(str(i)+". what is the fullform of "+str(x)+" ?"+"\n")
for row in range(sh1.nrows):
column = 2
if(sh1.cell_value(row,column)== x) :
y = row
list1 = [1,2,3]
z = random.choice(list1)
column = 1
if( z == 1):
p = sh1.cell(y,1)
file.write(' 1. '+p.value+' 2. '+choice(sh1.col(column)).value+' 3. '+choice(sh1.col(column)).value+"\n")
elif( z == 2):
p = sh1.cell(y,1)
file.write(' 1. '+choice(sh1.col(column)).value+' 2.'+p.value+' 3.'+choice(sh1.col(column)).value+"\n")
elif(z==3):
p = sh1.cell(y,1)
file.write(' 1. '+choice(sh1.col(column)).value+' 2.'+ choice(sh1.col(column)).value+' 3.'+p.value+"\n")
f2.write(str(i) + '. ' + p.value+"\n" )
i+=1
i=7
for i in range(7,13):
wb = xlrd.open_workbook(r"C:\Users\Nihar Sanda\Desktop\DataStructure\CurrencyDataFile.xlsx")
sh1 = wb.sheet_by_index(0)
column =1
x = choice(sh1.col(column)).value
file.write(str(i)+ ". what is the shortform of "+x+" ?"+"\n")
for row in range(sh1.nrows):
column = 1
if(sh1.cell_value(row,column)== x) :
y = row
list1 = [1,2,3]
z = random.choice(list1)
column = 2
if( z == 1):
p = sh1.cell(y,2)
file.write(' 1. '+p.value+' 2.'+choice(sh1.col(column)).value+' 3.'+choice(sh1.col(column)).value+"\n")
elif( z == 2):
p = sh1.cell(y,2)
file.write(' 1. '+choice(sh1.col(column)).value+' 2.'+p.value+' 3.'+choice(sh1.col(column)).value+"\n")
elif(z==3):
p = sh1.cell(y,2)
file.write(' 1. '+choice(sh1.col(column)).value+' 2.'+ choice(sh1.col(column)).value+' 3.'+p.value+"\n")
f2.write(str(i) + '. ' + p.value +"\n")
i+=1
i=13
for i in range(13,19):
wb = xlrd.open_workbook(r"C:\Users\Nihar Sanda\Desktop\DataStructure\CurrencyDataFile.xlsx")
sh1 = wb.sheet_by_index(0)
column = 1
x = choice(sh1.col(column)).value
file.write(str(i)+ ". what is the price of "+x+" ?"+"\n")
for row in range(sh1.nrows):
column = 1
if(sh1.cell_value(row,column)== x) :
y = row
list1 = [1,2,3]
z = random.choice(list1)
column = 3
if( z == 1):
p = sh1.cell(y,3)
file.write(' 1. '+str(p.value)+' 2.'+str(choice(sh1.col(column)).value)+' 3.'+str(choice(sh1.col(column)).value)+"\n")
elif( z == 2):
p = sh1.cell(y,3)
file.write(' 1. '+str(choice(sh1.col(column)).value)+' 2.'+str(p.value)+' 3.'+str(choice(sh1.col(column)).value)+"\n")
elif(z==3):
p = sh1.cell(y,3)
file.write(' 1.'+str(choice(sh1.col(column)).value)+' 2.'+ str(choice(sh1.col(column)).value)+' 3.'+str(p.value)+"\n")
f2.write(str(i) + '. ' + str(p.value) +"\n" )
i+=1
file.close()
f2.close()