forked from manaswitha2000/Game
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion.py
More file actions
30 lines (26 loc) · 706 Bytes
/
question.py
File metadata and controls
30 lines (26 loc) · 706 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
29
30
import socket
import random
#Chosing a random question from "questions.txt" and sending it to clients
questions = 0
max = 35
l = []
Asked = []
for i in range (max):
l.append(i+1)
def question():
file = open("questions.txt",'r',0)
global questions
global l
global Asked
k = random.choice(l)
Asked.append(k)
l.remove(k)#to avoid repetition for questions
for s in file:
if k<10:
if(s[0] == str(k)):
questions += 1
return str(s)
else:
if(s[0] == str((k/10)) and s[1] == str((k%10))):
questions += 1
return str(s)