{"id":3361,"date":"2024-03-26T08:57:34","date_gmt":"2024-03-26T03:27:34","guid":{"rendered":"https:\/\/www.rangakrish.com\/?p=3361"},"modified":"2024-03-26T08:57:34","modified_gmt":"2024-03-26T03:27:34","slug":"using-streamlit-to-create-multiple-choice-questions-mcq","status":"publish","type":"post","link":"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/","title":{"rendered":"Using Streamlit to Create Multiple Choice Questions (MCQ)"},"content":{"rendered":"<p>Is it possible to build a web application in <em><strong>Python<\/strong><\/em> to display (and evaluate) multiple-choice questions? Even more importantly, can we render <a href=\"https:\/\/www.latex-project.org\/#\" target=\"_blank\" rel=\"noopener\"><em><strong>\u201clatex\u201d<\/strong><\/em><\/a>\u00a0 equations as part of the <em><strong>MCQ<\/strong><\/em>?<\/p>\n<p>After briefly looking at <a href=\"https:\/\/nicegui.io\" target=\"_blank\" rel=\"noopener\"><em><strong>NiceGUI<\/strong><\/em><\/a>, <a href=\"https:\/\/flet.dev\" target=\"_blank\" rel=\"noopener\"><em><strong>Flet<\/strong><\/em><\/a>, <a href=\"https:\/\/solara.dev\" target=\"_blank\" rel=\"noopener\"><em><strong>Solara<\/strong><\/em><\/a>, <a href=\"https:\/\/kitware.github.io\/trame\/\" target=\"_blank\" rel=\"noopener\"><em><strong>Trame<\/strong><\/em><\/a>, and <a href=\"https:\/\/streamlit.io\" target=\"_blank\" rel=\"noopener\"><em><strong>Streamlit<\/strong><\/em><\/a>, I decided to go ahead with <em><strong>S<\/strong><strong>treamlit<\/strong><\/em> to build this web app.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>Even though this was my first attempt in using <em><strong>streamlit<\/strong><\/em>, I found it easy to work with since it has good documentation. I am sure my code could be improved, but I am not building a commercial tool, so it doesn\u2019t really matter.<\/p>\n<p>One thing that is crucial to my app is to render <em><strong>\u201cRadio\u201d<\/strong><\/em> buttons with <em><strong>latex<\/strong><\/em> <em><strong>equations<\/strong><\/em>. This is directly supported in <em><strong>streamlit<\/strong><\/em>; I don\u2019t have to do anything special. Here is the code that lays out UI components on the web page:<\/p>\n<figure id=\"attachment_3362\" aria-describedby=\"caption-attachment-3362\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1.png?ssl=1\"><img data-recalc-dims=\"1\" fetchpriority=\"high\" decoding=\"async\" data-attachment-id=\"3362\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/code1-9\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1.png\" data-orig-size=\"1464,724\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Rendering the Page\" data-image-description=\"&lt;p&gt;Rendering the Page&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Rendering the Page&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1-1024x506.png\" class=\"wp-image-3362\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1.png?resize=550%2C272&#038;ssl=1\" alt=\"Rendering the Page\" width=\"550\" height=\"272\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1.png?resize=300%2C148&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1.png?resize=1024%2C506&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1.png?resize=768%2C380&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code1.png?w=1464&amp;ssl=1 1464w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3362\" class=\"wp-caption-text\"><strong>Rendering the Page<\/strong><\/figcaption><\/figure>\n<p>The <em><strong>MCQ<\/strong><\/em> consists of multiple questions and I model this using two classes: <em><strong>Assignment<\/strong><\/em> models the collection of questions and <em><strong>Question<\/strong><\/em> represents each question in the assignment. The <em><strong>Assignment<\/strong><\/em> object is constructed from an <em><strong>Excel Worksheet<\/strong><\/em>, which contains the question, answer choices, and the expected answer. Here is the definition of the two classes:<\/p>\n<figure id=\"attachment_3363\" aria-describedby=\"caption-attachment-3363\" style=\"width: 550px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3363\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/code2-12\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2.png\" data-orig-size=\"1332,1298\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Assignment and Question Classes\" data-image-description=\"&lt;p&gt;Assignment and Question Classes&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Assignment and Question Classes&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2-1024x998.png\" class=\"wp-image-3363\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2.png?resize=550%2C536&#038;ssl=1\" alt=\"Assignment and Question Classes\" width=\"550\" height=\"536\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2.png?resize=300%2C292&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2.png?resize=1024%2C998&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2.png?resize=768%2C748&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code2.png?w=1332&amp;ssl=1 1332w\" sizes=\"(max-width: 550px) 100vw, 550px\" \/><\/a><figcaption id=\"caption-attachment-3363\" class=\"wp-caption-text\"><strong>Assignment and Question Classes<\/strong><\/figcaption><\/figure>\n<p><em><strong>Streamlit<\/strong><\/em> uses <em><strong>\u201csession state\u201d<\/strong><\/em> to share variables across runs. I found this quite useful. I use a few <em><strong>\u201ckeys\u201d<\/strong><\/em> in the program and these are initialized in the beginning:<\/p>\n<figure id=\"attachment_3364\" aria-describedby=\"caption-attachment-3364\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code3.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" data-attachment-id=\"3364\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/code3-7\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code3.png\" data-orig-size=\"828,576\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Initializing Session Variables\" data-image-description=\"&lt;p&gt;Initializing Session Variables&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Initializing Session Variables&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code3.png\" class=\"wp-image-3364\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code3.png?resize=400%2C278&#038;ssl=1\" alt=\"Initializing Session Variables\" width=\"400\" height=\"278\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code3.png?resize=300%2C209&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code3.png?resize=768%2C534&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/code3.png?w=828&amp;ssl=1 828w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-3364\" class=\"wp-caption-text\"><strong>Initializing Session Variables<\/strong><\/figcaption><\/figure>\n<p>To launch the program, type <em><strong>\u201cstreamlit run MCQ.py\u201d<\/strong><\/em> in the terminal. This launches the server and the page is opened in the browser.<\/p>\n<figure id=\"attachment_3365\" aria-describedby=\"caption-attachment-3365\" style=\"width: 450px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3365\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/output2-20\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1.png\" data-orig-size=\"1046,332\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Launching the Program\" data-image-description=\"&lt;p&gt;Launching the Program&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Launching the Program&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1-1024x325.png\" class=\"wp-image-3365\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1.png?resize=450%2C143&#038;ssl=1\" alt=\"Launching the Program\" width=\"450\" height=\"143\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1.png?resize=300%2C95&amp;ssl=1 300w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1.png?resize=1024%2C325&amp;ssl=1 1024w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1.png?resize=768%2C244&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output2-1.png?w=1046&amp;ssl=1 1046w\" sizes=\"(max-width: 450px) 100vw, 450px\" \/><\/a><figcaption id=\"caption-attachment-3365\" class=\"wp-caption-text\"><strong>Launching the Program<\/strong><\/figcaption><\/figure>\n<p>Here are the first three questions as they appear in the browser:<\/p>\n<figure id=\"attachment_3366\" aria-describedby=\"caption-attachment-3366\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3366\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/output1-17\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png\" data-orig-size=\"1118,1880\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Browser Page with MCQ\" data-image-description=\"&lt;p&gt;Browser Page with MCQ&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;Browser Page with MCQ&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1-609x1024.png\" class=\"wp-image-3366\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png?resize=400%2C673&#038;ssl=1\" alt=\"Browser Page with MCQ\" width=\"400\" height=\"673\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png?resize=178%2C300&amp;ssl=1 178w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png?resize=609%2C1024&amp;ssl=1 609w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png?resize=768%2C1291&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png?resize=913%2C1536&amp;ssl=1 913w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output1.png?w=1118&amp;ssl=1 1118w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-3366\" class=\"wp-caption-text\"><strong>Browser Page with MCQ<\/strong><\/figcaption><\/figure>\n<p>Notice that I am displaying a <em><strong>\u201csummary\u201d<\/strong><\/em> grid at the top. It initially shows the number of questions in the assignment. Once the <em><strong>\u201cSubmit\u201d<\/strong><\/em> button is clicked, the other fields in the grid will be filled.<\/p>\n<p>I am pleased with the display of equations in the problem description area as well as along side the Radio buttons. This is one of the main reasons for choosing to go with <em><strong>\u201cstreamlit\u201d<\/strong><\/em>.<\/p>\n<p>I can now select my answer choices and then click <em><strong>\u201cSubmit\u201d<\/strong><\/em> at the bottom of the page.<\/p>\n<figure id=\"attachment_3367\" aria-describedby=\"caption-attachment-3367\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3367\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/output3-14\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png\" data-orig-size=\"1196,1690\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"The Submit Button\" data-image-description=\"&lt;p&gt;The Submit Button&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;The Submit Button&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3-725x1024.png\" class=\"wp-image-3367\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png?resize=400%2C565&#038;ssl=1\" alt=\"The Submit Button\" width=\"400\" height=\"565\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png?resize=212%2C300&amp;ssl=1 212w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png?resize=725%2C1024&amp;ssl=1 725w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png?resize=768%2C1085&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png?resize=1087%2C1536&amp;ssl=1 1087w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output3.png?w=1196&amp;ssl=1 1196w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-3367\" class=\"wp-caption-text\"><strong>The Submit Button<\/strong><\/figcaption><\/figure>\n<p>This triggers the <em><strong>\u201csubmitClicked()\u201d<\/strong><\/em> method, which validates the given answers against the correct response stored in the <em><strong>Excel<\/strong><\/em> file. At this point, the browser displays the message <em><strong>\u201cYour answers have been submitted!\u201d<\/strong><\/em><span class=\"Apple-converted-space\">\u00a0 a<\/span>nd updates the table with remaining data. It also disables the <em><strong>Submit<\/strong><\/em> button and <em><strong>Radio<\/strong><\/em> buttons, preventing further changes to the answers.<\/p>\n<figure id=\"attachment_3368\" aria-describedby=\"caption-attachment-3368\" style=\"width: 400px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4.png?ssl=1\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"3368\" data-permalink=\"https:\/\/www.rangakrish.com\/index.php\/2024\/03\/26\/using-streamlit-to-create-multiple-choice-questions-mcq\/output4-7\/\" data-orig-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4.png\" data-orig-size=\"1174,1496\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"After Submit Button is Clicked\" data-image-description=\"&lt;p&gt;After Submit Button is Clicked&lt;\/p&gt;\n\" data-image-caption=\"&lt;p&gt;After Submit Button is Clicked&lt;\/p&gt;\n\" data-large-file=\"https:\/\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4-804x1024.png\" class=\"wp-image-3368\" src=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4.png?resize=400%2C510&#038;ssl=1\" alt=\"After Submit Button is Clicked\" width=\"400\" height=\"510\" srcset=\"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4.png?resize=235%2C300&amp;ssl=1 235w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4.png?resize=804%2C1024&amp;ssl=1 804w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4.png?resize=768%2C979&amp;ssl=1 768w, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/03\/output4.png?w=1174&amp;ssl=1 1174w\" sizes=\"(max-width: 400px) 100vw, 400px\" \/><\/a><figcaption id=\"caption-attachment-3368\" class=\"wp-caption-text\"><strong>After Submit Button is Clicked<\/strong><\/figcaption><\/figure>\n<p>Given that my main goal was to check if <em><strong>\u201cstreamlit\u201d<\/strong><\/em> can handle <em><strong>Latex<\/strong><\/em> text, I am happy that it satisfies my requirement.<span class=\"Apple-converted-space\"> Overall, it was an enjoyable experience building the app.<\/span><\/p>\n<p>You can download the <em><strong>Python<\/strong><\/em> source file and the sample data file <a href=\"https:\/\/www.rangakrish.com\/downloads\/Resources.zip\" target=\"_blank\" rel=\"noopener\"><em><strong>here<\/strong><\/em><\/a>.<span class=\"Apple-converted-space\">\u00a0<\/span><\/p>\n<p>Have a nice week!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Is it possible to build a web application in Python to display (and evaluate) multiple-choice questions? Even more importantly, can we render \u201clatex\u201d\u00a0 equations as part of the MCQ? After briefly looking at NiceGUI, Flet, Solara, Trame, and Streamlit, I decided to go ahead with Streamlit to build this web app.\u00a0 Even though this was [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[17,103],"tags":[387,208,386],"class_list":["post-3361","post","type-post","status-publish","format-standard","hentry","category-programming","category-python","tag-mcq","tag-python","tag-streamlit"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p9OLnF-Sd","jetpack-related-posts":[{"id":3199,"url":"https:\/\/www.rangakrish.com\/index.php\/2023\/09\/04\/simulating-python-zip-in-lisp\/","url_meta":{"origin":3361,"position":0},"title":"Simulating Python Zip in Lisp","author":"admin","date":"September 4, 2023","format":false,"excerpt":"The zip() function in Python is a convenient mechanism for iterating over multiple \u201citerables\u201d in parallel. Looping over lists is a common scenario. Here is the output generated by the above code: Common Lisp does not have such a feature built into the language or as part of the standard\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Python Zip() Feature","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2023\/09\/python-code-300x99.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":3399,"url":"https:\/\/www.rangakrish.com\/index.php\/2024\/06\/08\/kp-astrology-rest-server-part-2\/","url_meta":{"origin":3361,"position":1},"title":"KP Astrology REST Server: Part 2","author":"admin","date":"June 8, 2024","format":false,"excerpt":"In my earlier article, I had briefly described the REST server I wanted to build for Krishnamurti Padhdhati system of astrology. After a long time I have managed to complete the implementation and it is now ready for deployment. In this article, I will go over some of its features\u2026","rel":"","context":"In &quot;Astrology&quot;","block_context":{"text":"Astrology","link":"https:\/\/www.rangakrish.com\/index.php\/category\/astrology\/"},"img":{"alt_text":"KPRest Application Window","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2024\/06\/Start-300x174.jpg?resize=350%2C200&ssl=1","width":350,"height":200},"classes":[]},{"id":1560,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/05\/05\/python-integration-in-mathematica-12\/","url_meta":{"origin":3361,"position":2},"title":"Python Integration in Mathematica 12","author":"admin","date":"May 5, 2019","format":false,"excerpt":"Mathematica has had Python support since ver 11.2 through ExternalEvaluate[]. In ver 11.3 it was possible to input Python expression in a cell by beginning with \u201c>\u201d character. The good news is that Mathematica 12 has significantly enhanced this integration. Python Cells Let us start with the simplest way to\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"Function References","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/05\/External-Evaluate-4.png?resize=525%2C300&ssl=1 1.5x"},"classes":[]},{"id":558,"url":"https:\/\/www.rangakrish.com\/index.php\/2017\/07\/07\/clpython-python-in-common-lisp\/","url_meta":{"origin":3361,"position":3},"title":"CLPython &#8211; Python in Common Lisp","author":"admin","date":"July 7, 2017","format":false,"excerpt":"My work in the area of NLP requires\u00a0me to work with several frameworks across multiple languages such as Java, Python and Lisp. Sometime ago I got a chance to experiment with CLPython, an open-source implementation of Python in Common Lisp. Although CLPython is not under active development now, I found\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":912,"url":"https:\/\/www.rangakrish.com\/index.php\/2018\/04\/22\/question-answering-using-dependency-trees\/","url_meta":{"origin":3361,"position":4},"title":"Question Answering\u00a0Using Dependency Trees","author":"admin","date":"April 22, 2018","format":false,"excerpt":"A few weeks ago I had written about my brief experiment with Mathematica's new feature, which provides answers to questions based on given text. After that post, I spent some time thinking about how to implement something similar. In today's post, I want to show you what I have been\u2026","rel":"","context":"In &quot;LISP&quot;","block_context":{"text":"LISP","link":"https:\/\/www.rangakrish.com\/index.php\/category\/lisp\/"},"img":{"alt_text":"Dependency Tree","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2018\/04\/Deptree-example.png?resize=350%2C200","width":350,"height":200},"classes":[]},{"id":1594,"url":"https:\/\/www.rangakrish.com\/index.php\/2019\/06\/08\/using-nodejs-in-mathematica-12\/","url_meta":{"origin":3361,"position":5},"title":"Using NodeJS in Mathematica 12","author":"admin","date":"June 8, 2019","format":false,"excerpt":"In an earlier article, I had described Python integration in Mathematica 12. In addition to Python, NodeJS is also supported as a default \u201cexternal\u201d language. In today\u2019s article, I will focus on NodeJS integration. By the way, NodeJS support was introduced in Mathematica 11.2. Before using NodeJS with Mathematica 12,\u2026","rel":"","context":"In &quot;Mathematica&quot;","block_context":{"text":"Mathematica","link":"https:\/\/www.rangakrish.com\/index.php\/category\/mathematica\/"},"img":{"alt_text":"NodeJS Session Continued","src":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/www.rangakrish.com\/wp-content\/uploads\/2019\/06\/Session2.png?resize=700%2C400&ssl=1 2x"},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/comments?post=3361"}],"version-history":[{"count":0,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/posts\/3361\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/media?parent=3361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/categories?post=3361"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rangakrish.com\/index.php\/wp-json\/wp\/v2\/tags?post=3361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}