{"id":266,"date":"2025-11-21T15:27:18","date_gmt":"2025-11-21T15:27:18","guid":{"rendered":"https:\/\/codetypingpro.com\/?p=266"},"modified":"2025-11-21T15:27:18","modified_gmt":"2025-11-21T15:27:18","slug":"45-real-world-python-projects-online-quiz-platform","status":"publish","type":"post","link":"https:\/\/codetypingpro.com\/?p=266","title":{"rendered":"45 &#8211; Real-World Python Projects &#8211; Online Quiz Platform"},"content":{"rendered":"\n<h6 class=\"wp-block-heading\"><\/h6>\n\n\n\n<p class=\"wp-block-paragraph\">This project is a complete <strong>web-based quiz system<\/strong> where users can take quizzes, check scores, and get results instantly.<br>You\u2019ll build <strong>backend + frontend + database<\/strong> using Python.<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83c\udfaf <strong>What You Will Learn<\/strong><\/h1>\n\n\n\n<p class=\"wp-block-paragraph\">\u2714 Flask Web Framework<br>\u2714 HTML\/CSS + Bootstrap<br>\u2714 Storing questions in JSON or SQLite<br>\u2714 Timer-based quiz<br>\u2714 Randomization of questions<br>\u2714 Auto-grading system<br>\u2714 Score history tracking<br>\u2714 Admin panel (optional)<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\udcc1 <strong>Project Folder Structure<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>online_quiz\/\n\u2502\u2500\u2500 app.py\n\u2502\u2500\u2500 questions.json\n\u2502\u2500\u2500 templates\/\n\u2502     \u251c\u2500\u2500 home.html\n\u2502     \u251c\u2500\u2500 quiz.html\n\u2502     \u251c\u2500\u2500 result.html\n\u2502\u2500\u2500 static\/\n      \u251c\u2500\u2500 style.css\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\udde9 <strong>1. Sample Questions File (questions.json)<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;\n  {\n    \"question\": \"What is the capital of France?\",\n    \"options\": &#91;\"London\", \"Paris\", \"Rome\", \"Berlin\"],\n    \"answer\": \"Paris\"\n  },\n  {\n    \"question\": \"Which language is used for AI?\",\n    \"options\": &#91;\"Python\", \"HTML\", \"CSS\", \"JavaScript\"],\n    \"answer\": \"Python\"\n  },\n  {\n    \"question\": \"Select the odd one out:\",\n    \"options\": &#91;\"Dog\", \"Cat\", \"Apple\", \"Lion\"],\n    \"answer\": \"Apple\"\n  }\n]\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83e\udde9 <strong>2. Flask Backend (app.py)<\/strong><\/h1>\n\n\n\n<pre class=\"wp-block-code\"><code>from flask import Flask, render_template, request\nimport json, random\n\napp = Flask(__name__)\n\ndef load_questions():\n    with open(\"questions.json\", \"r\") as f:\n        return json.load(f)\n\n@app.route(\"\/\")\ndef home():\n    return render_template(\"home.html\")\n\n@app.route(\"\/quiz\")\ndef quiz():\n    questions = load_questions()\n    random.shuffle(questions)\n    return render_template(\"quiz.html\", questions=questions)\n\n@app.route(\"\/result\", methods=&#91;\"POST\"])\ndef result():\n    questions = load_questions()\n    score = 0\n    total = len(questions)\n\n    for i, q in enumerate(questions):\n        user_ans = request.form.get(f\"q{i}\")\n        if user_ans == q&#91;\"answer\"]:\n            score += 1\n\n    return render_template(\"result.html\", score=score, total=total)\n\nif __name__ == \"__main__\":\n    app.run(debug=True)\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83c\udfa8 <strong>3. HTML Templates<\/strong><\/h1>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>home.html<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Online Quiz&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;Welcome to Online Quiz Platform&lt;\/h1&gt;\n    &lt;a href=\"\/quiz\"&gt;Start Quiz&lt;\/a&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>quiz.html<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Take Quiz&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h2&gt;Answer the following questions:&lt;\/h2&gt;\n\n    &lt;form action=\"\/result\" method=\"post\"&gt;\n        {% for q in questions %}\n            &lt;p&gt;&lt;b&gt;{{ loop.index }}. {{ q.question }}&lt;\/b&gt;&lt;\/p&gt;\n\n            {% for opt in q.options %}\n                &lt;input type=\"radio\" name=\"q{{ loop.index0 }}\" value=\"{{ opt }}\" required&gt;\n                {{ opt }} &lt;br&gt;\n            {% endfor %}\n            &lt;br&gt;\n        {% endfor %}\n\n        &lt;button type=\"submit\"&gt;Submit&lt;\/button&gt;\n    &lt;\/form&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>result.html<\/strong><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Quiz Result&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;Your Score: {{ score }}\/{{ total }}&lt;\/h1&gt;\n\n    {% if score == total %}\n        &lt;h2&gt;Excellent! \ud83c\udf89&lt;\/h2&gt;\n    {% elif score &gt; total\/2 %}\n        &lt;h2&gt;Good Job \ud83d\udc4d&lt;\/h2&gt;\n    {% else %}\n        &lt;h2&gt;Keep Practicing \ud83d\udcaa&lt;\/h2&gt;\n    {% endif %}\n\n    &lt;a href=\"\/\"&gt;Go Home&lt;\/a&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;\n<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h1 class=\"wp-block-heading\">\ud83d\ude80 <strong>How to Run the Project<\/strong><\/h1>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Install Flask:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install flask\n<\/code><\/pre>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Keep all files in the <code>online_quiz<\/code> folder.<\/li>\n\n\n\n<li>Run:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>python app.py\n<\/code><\/pre>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Open browser:<\/li>\n<\/ol>\n\n\n\n<pre class=\"wp-block-code\"><code>http:&#47;&#47;127.0.0.1:5000\/<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This project is a complete web-based quiz system where users can take quizzes, check scores, and get results instantly.You\u2019ll build backend + frontend + database using Python. \ud83c\udfaf What You Will Learn \u2714 Flask Web Framework\u2714 HTML\/CSS + Bootstrap\u2714 Storing questions in JSON or SQLite\u2714 Timer-based quiz\u2714 Randomization of questions\u2714 Auto-grading system\u2714 Score history tracking\u2714 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-266","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/266","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=266"}],"version-history":[{"count":1,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions"}],"predecessor-version":[{"id":267,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=\/wp\/v2\/posts\/266\/revisions\/267"}],"wp:attachment":[{"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=266"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=266"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codetypingpro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=266"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}