{"id":8795,"date":"2021-03-07T08:13:47","date_gmt":"2021-03-07T07:13:47","guid":{"rendered":"https:\/\/pythonprogramming.altervista.org\/?p=8795"},"modified":"2021-03-07T17:35:51","modified_gmt":"2021-03-07T16:35:51","slug":"make-an-html-quiz-easily-with-python","status":"publish","type":"post","link":"https:\/\/pythonprogramming.altervista.org\/make-an-html-quiz-easily-with-python\/","title":{"rendered":"Make an html quiz easily with Python"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">We will generate this test here:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"542\" height=\"398\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-3.png\" alt=\"\" class=\"wp-image-8797\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-3.png 542w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-3-320x235.png 320w\" sizes=\"auto, (max-width: 542px) 100vw, 542px\" \/><\/a><figcaption>The test in html<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The code is in html and javascript, but we want to create new tests easily with the help of python to generate them using simple text files with questions, images and answers, so that we do not have to write all this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">{\n          question : 'When you see this sign, you must:',\n          image : 'c2-q01.png',\n          answers : [\n            '+Stop completely, check for pedestrians, and cross traffic',\n            'Slow down without coming to a complete stop',\n            'Stop completely and wait for a green light',\n            'Slow down and check for traffic'\n          ]\n        },<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">for every single question, but this<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">When you see this sign, you must:\nStop completely, check for pedestrians, and cross traffic\nSlow down without coming to a complete stop\nStop completely and wait for a green light\nSlow down and check for traffic<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">so that is easy and you can also use other quizzes that you written as text like this.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: create the py file like this<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from resource.start import start, end\n\n\n\nquestions = \"\"\"        {\n          question : 'When you see this sign, you must:',\n          image : 'c2-q01.png',\n          answers : [\n            '+Stop completely, check for pedestrians, and cross traffic',\n            'Slow down without coming to a complete stop',\n            'Stop completely and wait for a green light',\n            'Slow down and check for traffic'\n          ]\n        },\"\"\"\n\nprint(start + questions + end)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then you will store in a folder called resource this python file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">start = \"\"\"&lt;!DOCTYPE html>\n&lt;html lang=\"en\" prefix=\"og: http:\/\/ogp.me\/ns#\">\n  &lt;head>\n    &lt;meta charset=\"UTF-8\">\n    &lt;title>Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests&lt;\/title>\n    &lt;meta name=\"title\" content=\"Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests\">\n    &lt;meta name=\"twitter:title\" content=\"Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests\">\n    &lt;meta property=\"og:title\" content=\"Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests\">\n    &lt;meta name=\"description\" content=\"This test reviews what you have learned in Chapter 2 (p.7-22) of the Pennsylvania Driver's Manual. Answer the questions as best as you can.\">\n    &lt;meta property=\"og:description\" content=\"This test reviews what you have learned in Chapter 2 (p.7-22) of the Pennsylvania Driver's Manual. Answer the questions as best as you can.\">\n    &lt;link rel=\"shortcut icon\" type=\"image\/x-icon\" href=\"..\/..\/..\/resources\/images\/padt.ico\">\n\n    &lt;meta name=\"keywords\" content=\"PennDOT, Driver Manual, Tests, Practice, Exercises\" lang=\"en\">\n    &lt;meta name=\"language\" content=\"en\">\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n    &lt;meta property=\"og:site_name\" content=\"sethclydesdale.github.io\">\n    &lt;meta property=\"og:url\" content=\"https:\/\/sethclydesdale.github.io\/pa-driver-tests\/tests\/chapter-2\/review\/\">\n    &lt;meta property=\"og:type\" content=\"website\">\n    &lt;meta property=\"og:image\" content=\"https:\/\/sethclydesdale.github.io\/pa-driver-tests\/resources\/images\/padt-thumb.png\">\n    &lt;meta name=\"twitter:card\" content=\"summary\">\n    &lt;meta name=\"twitter:creator\" content=\"@SethC1995\">\n\n    &lt;link rel=\"stylesheet\" href=\"..\/..\/..\/resources\/stylesheet.min.css\">\n    &lt;script src=\"..\/..\/..\/resources\/ga.js\" async>&lt;\/script>\n  &lt;\/head>\n\n  &lt;body>\n    \n    &lt;header>\n      &lt;h1>&lt;a href=\"..\/..\/..\/\" id=\"home-link\">Pennsylvania Driver Tests&lt;\/a>&lt;\/h1>\n      &lt;a id=\"fork-me\" href=\"https:\/\/github.com\/SethClydesdale\/pa-driver-tests\">Fork Me&lt;\/a>\n    &lt;\/header>\n    \n    &lt;div id=\"content\">\n      &lt;div id=\"exercise\" class=\"content-block\">\n        &lt;h2 id=\"exercise-title\" class=\"center\">Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings&lt;\/h2>\n        &lt;div id=\"quiz-result\">&lt;\/div>\n        &lt;div id=\"quiz-zone\" class=\"clear\">&lt;\/div>\n        &lt;div id=\"quiz-timer\" class=\"center\">&lt;\/div>\n      &lt;\/div>\n    &lt;\/div>\n    \n    &lt;footer class=\"clear\">\n      &lt;ul class=\"footer-left\">\n        &lt;li>&lt;a href=\"..\/..\/..\/\">Home&lt;\/a>&lt;\/li>\n        &lt;li>&lt;a href=\"..\/..\/..\/privacy\/\">Privacy&lt;\/a>&lt;\/li>\n        &lt;li>&lt;a href=\"..\/..\/..\/report\/\">Report a Bug&lt;\/a>&lt;\/li>\n      &lt;\/ul>\n      \n      &lt;ul class=\"footer-right\">\n        &lt;li>Created by &lt;a href=\"https:\/\/github.com\/SethClydesdale\">Seth Clydesdale&lt;\/a> and the &lt;a href=\"https:\/\/github.com\/SethClydesdale\/pa-driver-tests\/graphs\/contributors\">Github Community&lt;\/a>&lt;\/li>\n      &lt;\/ul>\n    &lt;\/footer>\n    \n    &lt;script src=\"..\/..\/..\/resources\/easytimer.min.js\">&lt;\/script>\n    &lt;script src=\"..\/..\/..\/resources\/ezquiz.min.js\">&lt;\/script>\n    &lt;script src=\"..\/..\/..\/resources\/javascript.min.js\">&lt;\/script>\n    &lt;script>EZQuiz.generate({\n      info : 'This test reviews what you have learned in Chapter 2 (p.7-22) of the Pennsylvania Driver\\'s Manual.&lt;br>Answer the questions as best as you can.',\n\n      quiz : [\"\"\"\n\nend = \"\"\" }\n      ]\n    });&lt;\/script>\n  &lt;\/body>\n&lt;\/html>\"\"\"<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now you got the template stored in the memory of the computer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Create a list of strings with the questions<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Now we will load the question from an external file in a folder called &#8220;data&#8221; like this:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Come ti chiami\ngio\ncarla\nsara\ntommaso\n\nDove sei nato\ngenova\nmilano\ntorino\nvenezia<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">We will use this function in the main python file<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">quest = []\nwith open(\"data\/test.txt\") as file:\n\tfile = file.read()\n\t# store a question in each item of cont\n\tcont = [l for l in file.split(\"\\n\\n\")]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now we will make the right javascript code for the html test<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">for q in cont:\n\tq = q.split(\"\\n\")\n\ttesto = f\"{{question:{q[0]}, image: 'image01.png', answes : [\\'{q[1]}\\',\\'{q[2]}\\',\\'{q[3]}\\',\\'{q[4]}\\']}},\"\n\tquest.append(testo)\n\nprint(quest)\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">this is the output<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[\"{question:Come ti chiami, image: 'image01.png', answes : ['gio','carla','sara','tommaso']},\", \"{question:Dove sei nato, image: 'image01.png', answes : ['genova','milano','torino','venezia']},\"]<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now we just have to save the file in html with the new questions<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from resource.start import start, end\nimport os\nfrom createfile import createfile\n\n\nquestions = \"\"\"        {\n          question : 'When you see this sign, you must:',\n          image : 'c2-q01.png',\n          answers : [\n            '+Stop completely, check for pedestrians, and cross traffic',\n            'Slow down without coming to a complete stop',\n            'Stop completely and wait for a green light',\n            'Slow down and check for traffic'\n          ]\n        },\"\"\"\n\nquest = []\nwith open(\"data\/test.txt\") as file:\n\tfile = file.read()\n\t# store a question in each item of cont\n\tcont = [l for l in file.split(\"\\n\\n\")]\n\ntesto = \"\"\nfor q in cont:\n\tq = q.split(\"\\n\")\n\ttesto += f\"{{question:\\'{q[0]}\\', image: 'image01.png', answers : [\\'{q[1]}\\',\\'{q[2]}\\',\\'{q[3]}\\',\\'{q[4]}\\']}},\\n\"\n\tquest.append(testo)\n\n\n\nhtml = start + \"\".join(testo) + end\n\ncreatefile(\"02.html\", html)\nprint(os.getcwd())\nos.startfile(\"data\\\\review\\\\02.html\")<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The whole code is this<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import os\nfrom createfile import createfile\nfrom tkinter import filedialog\nfrom random import shuffle\nimport tkinter as tk\n\n\n\nstart = \"\"\"&lt;!DOCTYPE html>\n&lt;html lang=\"en\" prefix=\"og: http:\/\/ogp.me\/ns#\">\n  &lt;head>\n    &lt;meta charset=\"UTF-8\">\n    &lt;title>Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests&lt;\/title>\n    &lt;meta name=\"title\" content=\"Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests\">\n    &lt;meta name=\"twitter:title\" content=\"Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests\">\n    &lt;meta property=\"og:title\" content=\"Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings | Pennsylvania Driver Tests\">\n    &lt;meta name=\"description\" content=\"This test reviews what you have learned in Chapter 2 (p.7-22) of the Pennsylvania Driver's Manual. Answer the questions as best as you can.\">\n    &lt;meta property=\"og:description\" content=\"This test reviews what you have learned in Chapter 2 (p.7-22) of the Pennsylvania Driver's Manual. Answer the questions as best as you can.\">\n    &lt;link rel=\"shortcut icon\" type=\"image\/x-icon\" href=\"..\/..\/..\/resources\/images\/padt.ico\">\n\n    &lt;meta name=\"keywords\" content=\"PennDOT, Driver Manual, Tests, Practice, Exercises\" lang=\"en\">\n    &lt;meta name=\"language\" content=\"en\">\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n    &lt;meta property=\"og:site_name\" content=\"sethclydesdale.github.io\">\n    &lt;meta property=\"og:url\" content=\"https:\/\/sethclydesdale.github.io\/pa-driver-tests\/tests\/chapter-2\/review\/\">\n    &lt;meta property=\"og:type\" content=\"website\">\n    &lt;meta property=\"og:image\" content=\"https:\/\/sethclydesdale.github.io\/pa-driver-tests\/resources\/images\/padt-thumb.png\">\n    &lt;meta name=\"twitter:card\" content=\"summary\">\n    &lt;meta name=\"twitter:creator\" content=\"@SethC1995\">\n\n    &lt;link rel=\"stylesheet\" href=\"..\/..\/..\/resources\/stylesheet.min.css\">\n    &lt;script src=\"..\/..\/..\/resources\/ga.js\" async>&lt;\/script>\n  &lt;\/head>\n\n  &lt;body>\n    \n    &lt;header>\n      &lt;h1>&lt;a href=\"..\/..\/..\/\" id=\"home-link\">Pennsylvania Driver Tests&lt;\/a>&lt;\/h1>\n      &lt;a id=\"fork-me\" href=\"https:\/\/github.com\/SethClydesdale\/pa-driver-tests\">Fork Me&lt;\/a>\n    &lt;\/header>\n    \n    &lt;div id=\"content\">\n      &lt;div id=\"exercise\" class=\"content-block\">\n        &lt;h2 id=\"exercise-title\" class=\"center\">Review Questions: Chapter 2 - Signals, Signs, and Pavement Markings&lt;\/h2>\n        &lt;div id=\"quiz-result\">&lt;\/div>\n        &lt;div id=\"quiz-zone\" class=\"clear\">&lt;\/div>\n        &lt;div id=\"quiz-timer\" class=\"center\">&lt;\/div>\n      &lt;\/div>\n    &lt;\/div>\n    \n    &lt;footer class=\"clear\">\n      &lt;ul class=\"footer-left\">\n        &lt;li>&lt;a href=\"..\/..\/..\/\">Home&lt;\/a>&lt;\/li>\n        &lt;li>&lt;a href=\"..\/..\/..\/privacy\/\">Privacy&lt;\/a>&lt;\/li>\n        &lt;li>&lt;a href=\"..\/..\/..\/report\/\">Report a Bug&lt;\/a>&lt;\/li>\n      &lt;\/ul>\n      \n      &lt;ul class=\"footer-right\">\n        &lt;li>Created by &lt;a href=\"https:\/\/github.com\/SethClydesdale\">Seth Clydesdale&lt;\/a> and the &lt;a href=\"https:\/\/github.com\/SethClydesdale\/pa-driver-tests\/graphs\/contributors\">Github Community&lt;\/a>&lt;\/li>\n      &lt;\/ul>\n    &lt;\/footer>\n    \n    &lt;script src=\"..\/..\/..\/resources\/easytimer.min.js\">&lt;\/script>\n    &lt;script src=\"..\/..\/..\/resources\/ezquiz.min.js\">&lt;\/script>\n    &lt;script src=\"..\/..\/..\/resources\/javascript.min.js\">&lt;\/script>\n    &lt;script>EZQuiz.generate({\n      info : 'Pythonprogramming.altervista.org',\n\n      quiz : [\"\"\"\n\nend = \"\"\"\n      ]\n    });&lt;\/script>\n  &lt;\/body>\n&lt;\/html>\"\"\"\n\nquest = []\n\ndef opentext():\n    rep = filedialog.askopenfilenames(\n        # parent=root,\n        initialdir=os.getcwd() + \"data\",\n        initialfile='tmp',\n        filetypes=[\n            (\"TXT\", \"*.txt\")])\n    return rep\n\n\ndef open_text_file():\n    name = opentext()\n    with open(name[0]) as file:\n        file = file.read()\n        # store a question in each item of cont\n        cont = [l for l in file.split(\"\\n\\n\")]\n    return cont\n\ncont = open_text_file()\n\ntesto = \"\"\nfor q in cont:\n    q = q.split(\"\\n\")\n    # first answer is right\n    q[1] = \"+\" + q[1]\n    answers = q[:]\n    answers.pop(0)\n    # shuffle answers and then add to q\n    shuffle(answers)\n    q = [q[0], *answers]\n    print(q)\n    testo += f\"{{question:\\'{q[0]}\\', image: '', answers : [\\'{q[1]}\\',\\'{q[2]}\\',\\'{q[3]}\\',\\'{q[4]}\\']}},\\n\"\n    quest.append(testo)\n\n\nhtml = start + \"\".join(testo) + end\ndef createfile(name, html):\n    with open(\"data\/review\/\" + name, \"w\") as newfile:\n        newfile.write(html)\n    return html\n\n\ncreatefile(\"02.html\", html)\nprint(os.getcwd())\nos.startfile(\"data\\\\review\\\\02.html\")\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The files must be in this position to work with the path that I set in the script<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-5.png\"><img loading=\"lazy\" decoding=\"async\" width=\"896\" height=\"474\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-5.png\" alt=\"\" class=\"wp-image-8805\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-5.png 896w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-5-320x169.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-5-768x406.png 768w\" sizes=\"auto, (max-width: 896px) 100vw, 896px\" \/><\/a><figcaption>The questions text file is in the data folder, you will need also the pa-driven-tests folder to workW<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When you launch the script, you are asked to choose a txt file with the questions and answers<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-7.png\"><img loading=\"lazy\" decoding=\"async\" width=\"783\" height=\"514\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-7.png\" alt=\"\" class=\"wp-image-8812\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-7.png 783w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-7-320x210.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-7-768x504.png 768w\" sizes=\"auto, (max-width: 783px) 100vw, 783px\" \/><\/a><figcaption>prompt to choose the file with the answers, in this case text.txt<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">I put &#8211; as example &#8211; this two silly questions to show how to make the test<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-8.png\"><img loading=\"lazy\" decoding=\"async\" width=\"446\" height=\"468\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-8.png\" alt=\"\" class=\"wp-image-8813\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-8.png 446w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-8-320x336.png 320w\" sizes=\"auto, (max-width: 446px) 100vw, 446px\" \/><\/a><figcaption>the text file content of the exampel: one question, the right answer and 3 wrong answer and then an empty line and the following question<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Then the text will immediately show up<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-9.png\"><img loading=\"lazy\" decoding=\"async\" width=\"505\" height=\"503\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-9.png\" alt=\"\" class=\"wp-image-8814\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-9.png 505w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-9-320x319.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-9-150x150.png 150w\" sizes=\"auto, (max-width: 505px) 100vw, 505px\" \/><\/a><figcaption>The test is complete<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">At the end it will show you the right answers or the wrong ones<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-10.png\"><img loading=\"lazy\" decoding=\"async\" width=\"960\" height=\"682\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-10-960x682.png\" alt=\"\" class=\"wp-image-8815\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-10-960x682.png 960w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-10-320x227.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-10-768x546.png 768w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-10-321x229.png 321w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-10.png 1039w\" sizes=\"auto, (max-width: 960px) 100vw, 960px\" \/><\/a><figcaption>These answers were right<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">The repository with the code<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You can find the code <a href=\"https:\/\/github.com\/formazione\/pa-driver-tests\">here<\/a>:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><a href=\"https:\/\/github.com\/formazione\/pa-driver-tests\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-6.png\" alt=\"\" class=\"wp-image-8808\" width=\"840\" height=\"334\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-6.png 337w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-6-320x127.png 320w\" sizes=\"auto, (max-width: 840px) 100vw, 840px\" \/><\/a><figcaption>The github repository with the code<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"https:\/\/github.com\/formazione\/pa-driver-tests\">https:\/\/github.com\/formazione\/pa-driver-tests<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><!-- se vuoi mettere un testo scorrevole\r\n[hoops name=\"typeWriterGen\"]\r\n\r\npoi metti un id diverso per ogni testo nella stessa pagina\r\n\r\n<div id=\"div01\">\r\n<script>\r\n\r\ntypeWriterGen(\"div01\",\"Esempio di testo scorrevole\");\r\n<\/script>\r\n\r\n-->\r\n<style>\r\n.avatar {\r\n  vertical-align: middle;\r\n  width: 100px;\r\n  height: 100px;\r\n  border-radius: 50%;\r\n}\r\n<\/style>\r\n\r\n<hr>\r\n\r\n<!-- NEWSLETTER LINK -->\r\n<a href=\"https:\/\/docs.google.com\/forms\/d\/e\/1FAIpQLSf7TniIPCWHDzCSGh2dYZaCwDvi9yLKS5ovFdKuK1sdfOvwEg\/viewform\">\r\n<img decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2023\/08\/image-13.png\" class=\"avatar\">\r\nSubscribe to the <b>newsletter<\/b> for updates<\/a><br>\r\n\r\n<!-- TKINTER TEMPLATE LINK -->\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/tkinter-templates\/\">\r\n<img decoding=\"async\" src=\"https:\/\/i0.wp.com\/pythonprogramming.altervista.org\/wp-content\/uploads\/2023\/07\/image-26.png\" class=\"avatar\">\r\nTkinter templates<\/a><br>\r\n\r\n<!-- MY AVATAR PUT A LINK TO YOUTUBE CHANNEL-->\r\n<iframe loading=\"lazy\" frameborder=\"0\" src=\"https:\/\/itch.io\/embed\/711828\" width=\"552\" height=\"167\"><a href=\"https:\/\/pythonprogrammi.itch.io\/pysnake\">PySnake by PythonProgrammi<\/a><\/iframe>\r\n<br>\r\n<style>\r\n.avatar {\r\n  vertical-align: middle;\r\n  width: 100px;\r\n  height: 100px;\r\n  border-radius: 50%;\r\n}\r\n<\/style>\r\n\r\n\r\n<a href=\"https:\/\/www.youtube.com\/channel\/UCzbxq5e9gLiY-je2-br1rvg\">\r\n\t<img decoding=\"async\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/10\/avatar64x64.png\" alt=\"Avatar\" class=\"avatar\">\r\n\t My youtube channel<\/a><br>\r\n\r\n<br>\r\n\r\nTwitter: <a href=\"https:\/\/twitter.com\/pythonprogrammi\">@pythonprogrammi - python_pygame<\/a>\r\n<h3>Claude's Games<\/h3>\r\n<p><a href=\"https:\/\/pythonprogramming.altervista.org\/random-daily-game-1-arkanoid\/\">Arkanoid<\/a><br>\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/platform-2d-with-pygame-made-with-claude\/\">Platform 2d<\/a><\/p> <!-- videogames made with claude -->\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/artifacts-games-day-1-memory-game\/\">1. Memory game<\/a>\r\n<h4>Videos<\/h4>\r\n<a href=\"https:\/\/youtu.be\/ciLjWWw5pLY\">Speech recognition game<\/a>\r\n<h3>Pygame's Platform Game<\/h3>\r\n\r\n<a href=\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-5-sounds-and-mixer\/\"><img decoding=\"async\" src=\"https:\/\/i1.wp.com\/pythonprogramming.altervista.org\/wp-content\/uploads\/2020\/01\/climbercover.png?w=557&ssl=1\"\/ width=\"50%\"><\/a>\r\n<script>\r\nvar title = \"Platform Pygame\";\r\n\t\tvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-animation-of-a-sprite-v-1-3\/\",\"Animation 1.3\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-sprite-animation-v-2-better-coding-test-it-checking-fps-on-the-screen\/\",\"Animation 1.2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-how-to-display-the-frame-rate-fps-on-the-screen\/\",\"Display Frame rate\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-sprite-animation-update\/\",\"Animation 1.1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platformer-1\/\",\"Pygame Platform Game 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-platform-game-2\/\",\"Pygame Platform 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-3-recap-cheatsheet\/\",\"Pygame PLatform 3 - recap and some Cheat Sheet\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-4-background-and-stuffs\/\",\"Pygame Platform 4 - Background & organizing code\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platform-game-5-sounds-and-mixer\/\",\"Pygame Platform 5 - Sounds\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/platform-game-in-detail-part-1\/\",\"Game in detail part 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/map-maker-1-2\/\", \"Map maker 1.2\"]\r\n\t\t];\r\n\t\t<\/script>\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script>\r\n\r\n<h3>Other Pygame's posts<\/h3>\r\n\r\n<script>\r\nvar title = \"Pygame's Posts\"\r\nvar links = [\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-platformer-1\/\",\"Platform game 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/make-a-platform-game-with-pygame-dafluffypotato\/\",\"DaFluffyPotato Platform Tutorials\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-and-classic-arcade-games-pong\/\",\"Pong Game Full\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/python-draws-in-colors-app-to-draw-with-pygame\/\",\"PyGameGIF 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-draw-app-with-animation\/\",\"PyGameGIF 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pydraw-2-0-app-to-draw-gif\/\",\"PyDraw 2.0\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-drawing-2\/\",\"Draw with Pygame\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/animation-with-pygame\",\"Sprite animation 1\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/animation-on-pygame-2-free-characters-and-more-actions\/\",\"Sprite animation 2\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/starting-with-pygame\/\",\"Starting movements with Pygame\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-3-move-sprite\/\", \"Move a Sprite\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-4-fonts\/\",\"Text and Fonts\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-animate-a-sprite\/\", \"Animate a sprite\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pygame-and-mouse-events\/\",\"Mouse events\"],\r\n[\"https:\/\/pythonprogramming.altervista.org\/pgp-aka-pygamepresentation-project\/\",\"Pygame presentation\"],\r\n\t[\"https:\/\/pythonprogramming.altervista.org\/moving-the-player-in-pygame-with-key-get_pressed\/\",\"How to use key.get_pressed()\"]\r\n]\r\n<\/script>\r\n\r\n\r\n<script>\r\n\t\r\nif (typeof next2 != \"undefined\"){let next2 = 0;}\r\n\t\r\nnext2 = 0;\r\n\thtml = \"\";\/\/<b style='color:coral;font-size:1.2em'>Other posts about \" + title + \"<\/b><br>\";\r\nfor (address of links) \r\n{\r\n\r\n\tif (next2 == 1){\r\n\t\thtml += \"<div style='background:coral'>\";\r\n\t\thtml += \"Next link => <a href='\" + address[0] + \"'>\" + address[1] + \"<\/a>\";\r\n\t\thtml += \"<\/div><br>\";\r\n\t\tnext2 = 0;\r\n\t}\r\n\tif (address[0] == document.URL) {\r\n\t\tnext2 = 1;\r\n\t}\r\n}\r\n\r\nif (typeof next != \"undefined\") {let next = 0;}\r\nif (typeof addressStart != \"undefined\") {let addressStart = \"\";}\r\nnext = 0;\r\naddressStart = \"<a href='\";\r\nfor (address of links) {\r\n\tif (next == 1){\r\n\t\thtml += \">>>\" + addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t\tnext = 0;\r\n\t}\r\n\telse if (addressStart + address[0] != document.URL)\r\n\t{\r\n\t\thtml += addressStart + address[0] + \"'>\" + address[1] + \"<\/a><br>\";\r\n\t}\r\n\telse\r\n\t{\r\n\t\tnext = 1;\r\n\t\tnext_address = address[0]\r\n\t\tnext_title = address[1]\r\n\t\thtml += \"<span style='color:gray'>\" + address[1] + \"<\/span><br>\";\r\n\t}\r\n\r\n}\r\n\r\n\thtml += `<span style=\"font-size:8px\">Powered by <a href=\"https:\/\/pythonprogramming.altervista.org\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2673\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png\" alt=\"\" width=\"70\" height=\"25\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2.png 156w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2019\/06\/altervista2-150x56.png 150w\" sizes=\"auto, (max-width: 70px) 100vw, 70px\" \/>pythonprogramming.altervista.org<\/a><\/span>`\r\n\thtml = \"<div style='background:yellow'>\" + html + \"<\/div>\";\r\n\tdocument.write(html)\r\n<\/script><\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-4.png\"><img loading=\"lazy\" decoding=\"async\" width=\"800\" height=\"600\" src=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-4.png\" alt=\"\" class=\"wp-image-8799\" srcset=\"https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-4.png 800w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-4-320x240.png 320w, https:\/\/pythonprogramming.altervista.org\/wp-content\/uploads\/2021\/03\/image-4-768x576.png 768w\" sizes=\"auto, (max-width: 800px) 100vw, 800px\" \/><\/a><\/figure>\n","protected":false},"excerpt":{"rendered":"test maker\n<a class=\"moretag\" href=\"https:\/\/pythonprogramming.altervista.org\/make-an-html-quiz-easily-with-python\/\"> [...]<\/a>","protected":false},"author":1,"featured_media":8799,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_crdt_document":"","footnotes":""},"categories":[1,333,275],"tags":[],"class_list":["post-8795","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-examples","category-test","category-test-maker"],"avopt_banners_inside_post":true,"avopt_banners_on_page":true,"av_copy_from":"","av_sharing_message":"","av_sharing_allowed":true,"av_sharing_on":{"fb":[],"tw":[]},"av_allow_affiliate_banner":false,"av_allow_affiliate_multi_banner":false,"av_show_affiliation_buy_button":false,"av_post_rating":true,"av_have_post_rating_value":false,"av_is_artificial_intelligence_content":false,"_links":{"self":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/8795","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/comments?post=8795"}],"version-history":[{"count":8,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/8795\/revisions"}],"predecessor-version":[{"id":8816,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/posts\/8795\/revisions\/8816"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media\/8799"}],"wp:attachment":[{"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/media?parent=8795"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/categories?post=8795"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pythonprogramming.altervista.org\/wp-json\/wp\/v2\/tags?post=8795"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}