Suggestion:
Code with Your Prompt :
your prompt response
[
{
"question": "Which of the following is NOT a type of galaxy?",
"options": ["Spiral galaxy", "Elliptical galaxy", "Irregular galaxy", "Dim galaxy"],
"correct_answer": "Dim galaxy"
},
{
"question": "What is the study of living organisms?",
"options": ["Geology", "Astronomy", "Ecology", "Biology"],
"correct_answer": "Biology"
},
{
"question": "What is the force that causes objects to fall towards the earth?",
"options": ["Gravity", "Friction", "Magnetism", "Inertia"],
"correct_answer": "Gravity"
},
{
"question": "What is the densest element on earth?",
"options": ["Gold", "Platinum", "Lead", "Osmium"],
"correct_answer": "Osmium"
},
{
"question": "What is the process by which plants use sunlight to make food?",
"options": ["Photosynthesis", "Respiration", "Fertilization", "Germination"],
"correct_answer": "Photosynthesis"
}
]
Python Code for with Chat completions and better prompt
import requests
import json
url = 'https://api.openai.com/v1/chat/completions'
headers = {
'Content-Type': 'application/json',
'Authorization': 'Bearer YourKEY',
}
data = {
"model": "gpt-3.5-turbo",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": """Generate 5 multiple-choice questions on science, each with 4 options labeled A, B, C, D, and indicate the correct answer. Format the response in JSON, as shown in the example below:
Example:
[
{
"question": "What is the boiling point of water?",
"options": {
"A": "100°C",
"B": "90°C",
"C": "80°C",
"D": "110°C"
},
"correct_answer": "A"
}
]"""
}
]
}
response = requests.post(url, headers=headers, json=data)
if response.status_code == 200:
print(json.dumps(response.json(), indent=2))
else:
print("Error:", response.text)
Response with the new prompt
[
{
"question": "Which of the following components is NOT found in the nucleus of an atom?",
"options": {
"A": "Proton",
"B": "Neutron",
"C": "Electron",
"D": "Quark"
},
"correct_answer": "C"
},
{
"question": "What is the process by which plants make their food called?",
"options": {
"A": "Respiration",
"B": "Photosynthesis",
"C": "Fermentation",
"D": "Transpiration"
},
"correct_answer": "B"
},
{
"question": "Which planet is known as the 'Red Planet'?",
"options": {
"A": "Venus",
"B": "Mercury",
"C": "Mars",
"D": "Jupiter"
},
"correct_answer": "C"
},
{
"question": "What is the unit of electrical resistance?",
"options": {
"A": "Farad",
"B": "Watt",
"C": "Ohm",
"D": "Volt"
},
"correct_answer": "C"
},
{
"question": "Which of the following is NOT a type of rock?",
"options": {
"A": "Igneous",
"B": "Granite",
"C": "Metamorphic",
"D": "Subduction"
},
"correct_answer": "D"
}
]