Skip to content

Commit f8f91ad

Browse files
committed
Projects added
1 parent c763901 commit f8f91ad

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

Quiz-Creator/quiz.py

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import os
2+
class QuizCreation:
3+
def process(self, question, choices, answer, question_number=""):
4+
choices_dict = {'a':1, 'b':2, 'c':3, 'd':4}
5+
with open("sample.txt", "a") as f:
6+
f.write(f"\nQUESTION {question_number}:- "+question)
7+
f.write("\n")
8+
count = 65
9+
for i in range(len(choices)):
10+
f.write(f"({chr(count)}) "+choices[i])
11+
f.write("\n")
12+
count += 1
13+
f.write(f"Answer :- ({answer.upper()}) "+choices[choices_dict[answer]-1])
14+
f.write("\n")
15+
16+
def open_file(self):
17+
os.startfile("sample.txt")
18+
19+
Quiz = QuizCreation()

Quiz-Creator/sample.py

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from quiz import Quiz
2+
3+
Quiz.process(question="Entomology is the science that studies",
4+
choices=["Behavior of human beings", "Insects", "The origin and history of technical and scientific terms", "The formation of rocks"],
5+
answer="b")
6+
7+
Quiz.open_file()

Quiz-Creator/sample.txt

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
QUESTION :- Entomology is the science that studies
3+
(A) Behavior of human beings
4+
(B) Insects
5+
(C) The origin and history of technical and scientific terms
6+
(D) The formation of rocks
7+
Answer :- (B) Insects

0 commit comments

Comments
 (0)