Skip to main content

Generate Multiple Choice Questions, Choices and Correct Answer in JSON Format

Project description

mcqgen

License: MIT Python Version

Generate MCQs with options and correct answers in JSON Format. Uses GPT.

Installation

You can install the package using pip:

pip install mcqgen

Make sure you have OpenAI key stored in environment variable OPENAI_API_KEY

Usage

Simply call function generate_mcqs as below. First argument (Topic) is mandatory. Default Model (model) is GPT3.5 and default number of questions (no) is 5.

from mcqgen import mcqgen
gen = mcqgen.MCQGenerator()
data = gen.generate_mcqs('Cricket', model="gpt-3.5-turbo", no=3)
print(data)
{'questions': [{'question': 'Who holds the record for the highest individual score in Test cricket?', 'options': ['a) Sachin Tendulkar', 'b) Brian Lara', 'c) Don Bradman', 'd) Ricky Ponting'], 'answer': 'b) Brian Lara'}, {'question': 'Which cricketer has scored the most centuries in One Day Internationals (ODIs)?', 'options': ['a) Sachin Tendulkar', 'b) Ricky 
Ponting', 'c) Virat Kohli', 'd) Kumar Sangakkara'], 'answer': 'a) Sachin Tendulkar'}, {'question': 'Who has the best bowling figures in a Test innings?', 'options': ['a) Jim Laker', 'b) Anil Kumble', 'c) Muttiah Muralitharan', 'd) Shaun Pollock'], 'answer': 'a) Jim Laker'}]}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcqgen-1.0.0.tar.gz (3.1 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page