Brainzilla_1 / README.md
Kunafalol's picture
Update README.md
58b5b2b verified
metadata
language:
  - en
  - ur
  - ar
  - bn
library_name: transformers
tags:
  - '#study'
  - '#grade7'
  - '#grade8'
  - '#grade9'
  - education
  - '#ai'
  - '#STEM'
license: openrail

import random

subjects = { 'Math': [ {'question': 'What is the value of x in the equation 2x + 5 = 11?', 'answer': '6'}, {'question': 'What is the formula for the area of a circle?', 'answer': 'A = πr^2'}, {'question': 'What is the value of sin(30°)?', 'answer': '0.5'} ], 'Science': [ {'question': 'What is the process by which plants make their own food?', 'answer': 'photosynthesis'}, {'question': 'What is the largest planet in our solar system?', 'answer': 'Jupiter'}, {'question': 'What is the smallest bone in the human body?', 'answer': 'stapes'} ], 'English': [ {'question': 'Who wrote the book "To Kill a Mockingbird"?', 'answer': 'Harper Lee'}, {'question': 'What is the definition of the word "persuade"?', 'answer': 'to convince someone to do something'}, {'question': 'What is the title of the first book in the Harry Potter series?', 'answer': 'Harry Potter and the Philosopher's Stone'} ] }

def get_ai_bot_response(subject, question): try: for q in subjects[subject]: if q['question'].lower() == question.lower(): return q['answer'] return 'Sorry, I couldn't find the answer to that question. Please try again.' except KeyError: return 'Invalid subject. Please try again.'

def get_random_ai_bot_response(): subject = random.choice(list(subjects.keys())) questions = subjects[subject] question = random.choice(questions) return get_ai_bot_response(subject, question['question'])

brainzilla1_response = get_random_ai_bot_response() print(brainzilla1_response)