print('SCIENCE BOWL GENERATOR VERSION 0.1
Author: Christopher Chen
Copyright© 2016
')
print('Welcome to Science Bowl Generator.
Here you can generate Science Bowl Problems with speed and style. Enjoy!
')
problem_type = []
LIFE_SCIENCE = []
PHYSICAL_SCIENCE = []
MATH = []
GENERAL_SCIENCE = []
EARTH_SCIENCE = []
Name = ''
Title = ''
import random
def TEST():
Problems = []
TestProblems = []
answer_key = []
File = open('Questions_Program.txt','r')
RealFile = File.read()
Questions = RealFile.split('
')
for question in Questions:
if 'ANSWER:' in question:
answerAndAnswer = question.split('ANSWER:')
Problems.append(answerAndAnswer)
MAX = len(Problems)
Title = str(input('What do you want your title to be?
'))
Name = str(input('What is the creators name?
'))
Subject = input('Do you want to choose a specific topic? If yes, enter one of the following letters:
A) Life Science
B) Physical Science
C) Math
D) General Science
E) Earth Science
If no, just simply enter nothing.
')
while Subject.lower() != 'a' and Subject.lower() != 'b' and Subject.lower() != 'c' and Subject.lower() != 'd' and Subject.lower() != 'e' and Subject != '':
Subject = input('That input cannot be accepted because either it does not match any of the choices.
Do you want to choose a specific topic? If yes, enter one of the following letters:
A) Life Science
B) Physical Science
C) Math
D) General Science
E) Earth Science
If no, just simply enter nothing.
')
if Subject.lower() == 'a':
Subject = 'LIFE SCIENCE'
if Subject.lower() == 'b':
Subject = 'PHYSCIAL SCIENCE'
if Subject.lower() == 'c':
Subject = 'MATH'
if Subject.lower() == 'd':
Subject = 'GENERAL SCIENCE'
if Subject.lower() == 'e':
Subject = 'EARTH SCIENCE'
if Subject != '':
Problems = []
Questions = (RealFile.split('---' + Subject + '---')[1])
Questions = Questions.split('
')
for problem in Questions:
if problem == '':
Questions.remove(problem)
for problem in Questions:
answerAndAnswer = problem.split('ANSWER:')
Problems.append(answerAndAnswer)
MAX = len(Problems)
NumberOfQuestions = input('How many questions do you want(1 to ' + str(MAX) + ')?
')
while (NumberOfQuestions.isdigit() == False) or (int(NumberOfQuestions) <= 0) or (int(NumberOfQuestions) >= MAX+1):
NumberOfQuestions = input('That input cannot be accepted because it is either too much, too little, or it's simply not an integer. How many questions do you want(1 to ' + str(MAX) + ')?
')
str(NumberOfQuestions)
NumberOfQuestions = int(NumberOfQuestions)
UsedQuestions = []
for question in range(0,NumberOfQuestions):
question = random.randrange(0,MAX)
while question in UsedQuestions:
question = random.randrange(0,MAX)
UsedQuestions.append(question)
TestProblems.append(Problems[question][0])
answer_key.append(Problems[question][1])
Answer_Key = open('Answers.txt','w')
Problem_Set = open('Problems.txt','w')
problemnumber = 1
if Title != '':
Problem_Set.write(Title.upper())
Answer_Key.write(Title.upper() + '
ANSWER KEY')
if Name != '':
Problem_Set.write('
' + 'CREATOR:' + Name.upper() + '
')
Answer_Key.write('
' + 'CREATOR:' + Name.upper() + '
')
for answer in answer_key:
Answer_Key.write(str(problemnumber) + ')' + answer + '
')
problemnumber += 1
problemnumber = 1
for testproblem in TestProblems:
Problem_Set.write(str(problemnumber)+ ')' +testproblem + '
')
problemnumber += 1
print('In your files, you will find two text files named Answers.txt and Problems.txt.
Thanks for using Science Bowl Generator!!')
TEST()
Science Bowl Generator