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 details)

Uploaded Source

File details

Details for the file mcqgen-1.0.0.tar.gz.

File metadata

  • Download URL: mcqgen-1.0.0.tar.gz
  • Upload date:
  • Size: 3.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for mcqgen-1.0.0.tar.gz
Algorithm Hash digest
SHA256 493d1a85c60d3f5ffa663f041ce204ec8e91fb67f27feeb9b92907eb4ccb8ee3
MD5 d203c6a74c36b7197f05593f0f3ed450
BLAKE2b-256 17b4bcbd35892310b9438d3ac6ac462f56aec0ab20f91aac3c88e4aa1c0a332d

See more details on using hashes here.

Supported by

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