Update README.md
Browse files
README.md
CHANGED
|
@@ -17,49 +17,38 @@ license: openrail
|
|
| 17 |
---
|
| 18 |
import random
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
'math': [
|
| 23 |
{'question': 'What is the value of x in the equation 2x + 5 = 11?', 'answer': '6'},
|
| 24 |
{'question': 'What is the formula for the area of a circle?', 'answer': 'A = πr^2'},
|
| 25 |
{'question': 'What is the value of sin(30°)?', 'answer': '0.5'}
|
| 26 |
],
|
| 27 |
-
'
|
| 28 |
{'question': 'What is the process by which plants make their own food?', 'answer': 'photosynthesis'},
|
| 29 |
{'question': 'What is the largest planet in our solar system?', 'answer': 'Jupiter'},
|
| 30 |
{'question': 'What is the smallest bone in the human body?', 'answer': 'stapes'}
|
| 31 |
],
|
| 32 |
-
'
|
| 33 |
{'question': 'Who wrote the book "To Kill a Mockingbird"?', 'answer': 'Harper Lee'},
|
| 34 |
{'question': 'What is the definition of the word "persuade"?', 'answer': 'to convince someone to do something'},
|
| 35 |
{'question': 'What is the title of the first book in the Harry Potter series?', 'answer': 'Harry Potter and the Philosopher\'s Stone'}
|
| 36 |
]
|
| 37 |
}
|
| 38 |
|
| 39 |
-
|
| 40 |
def get_ai_bot_response(subject, question):
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
return 'Invalid subject. Please try again.'
|
| 44 |
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
# If the question is not found, return a default message
|
| 51 |
-
return 'Sorry, I couldn\'t find the answer to that question. Please try again.'
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
def get_Brainzilla_ai_bot_response():
|
| 55 |
-
# Get a random subject
|
| 56 |
-
subject = random.choice(list(subject_questions.keys()))
|
| 57 |
-
|
| 58 |
-
# Get a random question from the subject
|
| 59 |
-
question = random.choice(subject_questions[subject])
|
| 60 |
-
|
| 61 |
-
# Return the AI bot's response
|
| 62 |
return get_ai_bot_response(subject, question['question'])
|
| 63 |
|
| 64 |
-
|
| 65 |
-
print(
|
|
|
|
| 17 |
---
|
| 18 |
import random
|
| 19 |
|
| 20 |
+
subjects = {
|
| 21 |
+
'Math': [
|
|
|
|
| 22 |
{'question': 'What is the value of x in the equation 2x + 5 = 11?', 'answer': '6'},
|
| 23 |
{'question': 'What is the formula for the area of a circle?', 'answer': 'A = πr^2'},
|
| 24 |
{'question': 'What is the value of sin(30°)?', 'answer': '0.5'}
|
| 25 |
],
|
| 26 |
+
'Science': [
|
| 27 |
{'question': 'What is the process by which plants make their own food?', 'answer': 'photosynthesis'},
|
| 28 |
{'question': 'What is the largest planet in our solar system?', 'answer': 'Jupiter'},
|
| 29 |
{'question': 'What is the smallest bone in the human body?', 'answer': 'stapes'}
|
| 30 |
],
|
| 31 |
+
'English': [
|
| 32 |
{'question': 'Who wrote the book "To Kill a Mockingbird"?', 'answer': 'Harper Lee'},
|
| 33 |
{'question': 'What is the definition of the word "persuade"?', 'answer': 'to convince someone to do something'},
|
| 34 |
{'question': 'What is the title of the first book in the Harry Potter series?', 'answer': 'Harry Potter and the Philosopher\'s Stone'}
|
| 35 |
]
|
| 36 |
}
|
| 37 |
|
|
|
|
| 38 |
def get_ai_bot_response(subject, question):
|
| 39 |
+
try:
|
| 40 |
+
for q in subjects[subject]:
|
| 41 |
+
if q['question'].lower() == question.lower():
|
| 42 |
+
return q['answer']
|
| 43 |
+
return 'Sorry, I couldn\'t find the answer to that question. Please try again.'
|
| 44 |
+
except KeyError:
|
| 45 |
return 'Invalid subject. Please try again.'
|
| 46 |
|
| 47 |
+
def get_random_ai_bot_response():
|
| 48 |
+
subject = random.choice(list(subjects.keys()))
|
| 49 |
+
questions = subjects[subject]
|
| 50 |
+
question = random.choice(questions)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
return get_ai_bot_response(subject, question['question'])
|
| 52 |
|
| 53 |
+
brainzilla1_response = get_random_ai_bot_response()
|
| 54 |
+
print(brainzilla1_response)
|