{"id":1112,"date":"2023-10-13T15:33:46","date_gmt":"2023-10-13T10:03:46","guid":{"rendered":"https:\/\/moodle.sit.ac.in\/blog\/?p=1112"},"modified":"2024-05-13T23:37:27","modified_gmt":"2024-05-13T18:07:27","slug":"data-visualization-with-python-bcs358d","status":"publish","type":"post","link":"https:\/\/moodle.sit.ac.in\/blog\/data-visualization-with-python-bcs358d\/","title":{"rendered":"Data Visualization with Python &#8211; BCS358D"},"content":{"rendered":"\n<p>In this blog post, you will find solutions for the <strong>Data Visualization with Python (BCS358D)<\/strong> course work for the III semester of <strong>VTU<\/strong> university. To follow along, you will need to set up a Python programming environment. We recommend using the Anaconda Python Distribution with Spyder as the integrated development environment (IDE). You can find the lab syllabus on the university&#8217;s website or here.<\/p>\n\n\n\n<p><strong>Syllabus<\/strong><\/p>\n\n\n\n<div data-wp-interactive=\"core\/file\" class=\"wp-block-file\"><object data-wp-bind--hidden=\"!state.hasPdfPreview\" hidden class=\"wp-block-file__embed\" data=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/BCS358D.pdf\" type=\"application\/pdf\" style=\"width:100%;height:600px\" aria-label=\"Embed of BCS358D.\"><\/object><a id=\"wp-block-file--media-f231020e-c5eb-40e5-9fc3-cccebecc24fa\" href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/BCS358D.pdf\">BCS358D<\/a><a href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/BCS358D.pdf\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-f231020e-c5eb-40e5-9fc3-cccebecc24fa\">Download<\/a><\/div>\n\n\n\n<div class=\"group w-full text-gray-800 dark:text-gray-100 border-b border-black\/10 dark:border-gray-900\/50 bg-gray-50 dark:bg-[#444654]\">\n<div class=\"flex p-4 gap-4 text-base md:gap-6 md:max-w-2xl lg:max-w-[38rem] xl:max-w-3xl md:py-6 lg:px-0 m-auto\">\n<div class=\"relative flex w-[calc(100%-50px)] flex-col gap-1 md:gap-3 lg:w-[calc(100%-115px)]\">\n<div class=\"flex flex-grow flex-col gap-3\">\n<div class=\"min-h-[20px] flex items-start overflow-x-auto whitespace-pre-wrap break-words flex-col gap-4\">\n<div class=\"markdown prose w-full break-words dark:prose-invert light\">\n<p>For detailed instructions on setting up the Python programming environment on Ubuntu, please refer to my previous blog, which can be found below.<\/p>\n<p><blockquote class=\"wp-embedded-content\" data-secret=\"TdWXscWU7c\"><a href=\"https:\/\/moodle.sit.ac.in\/blog\/setting-up-anaconda-python-programming-environment\/\">Setting up Anaconda Python Programming Environment on Ubuntu<\/a><\/blockquote><iframe class=\"wp-embedded-content lazyload\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;Setting up Anaconda Python Programming Environment on Ubuntu&#8221; &#8212; MyBlogosphere\" data-src=\"https:\/\/moodle.sit.ac.in\/blog\/setting-up-anaconda-python-programming-environment\/embed\/#?secret=0sgcZs63IZ#?secret=TdWXscWU7c\" data-secret=\"TdWXscWU7c\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" data-load-mode=\"1\"><\/iframe><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n\n\n\n<p>If you are looking for step-by-step instructions on how to set up the Python programming environment on a Windows system, I have provided detailed guidance in my previous blog. You can access the blog below for all the information you need.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-myblogosphere wp-block-embed-myblogosphere\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"OQhf9fCNEO\"><a href=\"https:\/\/moodle.sit.ac.in\/blog\/a-step-by-step-guide-to-setting-up-anaconda-python-distribution-on-windows\/\">A Step-by-Step Guide to Setting up Anaconda Python Distribution on Windows<\/a><\/blockquote><iframe class=\"wp-embedded-content lazyload\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;A Step-by-Step Guide to Setting up Anaconda Python Distribution on Windows&#8221; &#8212; MyBlogosphere\" data-src=\"https:\/\/moodle.sit.ac.in\/blog\/a-step-by-step-guide-to-setting-up-anaconda-python-distribution-on-windows\/embed\/#?secret=mq3I8A7fPv#?secret=OQhf9fCNEO\" data-secret=\"OQhf9fCNEO\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<p>After getting the necessary development environment setup, Now lets focus on the solutions.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><span style=\"color: #ff0000;\">Question 1<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#01a\"><span style=\"color: #ff0000;\">Test Average<\/span><\/a><\/li>\n\n\n\n<li><a href=\"#01b\"><span style=\"color: #ff0000;\">Palindrome<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 2<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#02a\"><span style=\"color: #ff0000;\">Fibonacci Sequence<\/span><\/a><\/li>\n\n\n\n<li><a href=\"#02b\"><span style=\"color: #ff0000;\">Base Conversion<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 3<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#03a\"><span style=\"color: #ff0000;\">Sentence statistics<\/span><\/a><\/li>\n\n\n\n<li><a href=\"#03b\"><span style=\"color: #ff0000;\">String Similarity<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 4<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#04a\"><span style=\"color: #ff0000;\">Bar Plot using Matplotlib<\/span><\/a><\/li>\n\n\n\n<li><a href=\"#04b\"><span style=\"color: #ff0000;\">Scatter Plot using Matplotlib<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 5<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#05a\"><span style=\"color: #ff0000;\">Histogram Plot using Matplotlib<\/span><\/a><\/li>\n\n\n\n<li><a href=\"#05b\"><span style=\"color: #ff0000;\">Pie Chart using Matplotlib<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 6<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#06a\"><span style=\"color: #ff0000;\">Linear Plotting using Matplotlib<\/span><\/a><\/li>\n\n\n\n<li><a href=\"#06b\"><span style=\"color: #ff0000;\">Linear Plotting with line formatting using Matplotlib<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 7<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#07a\"><span style=\"color: #ff0000;\">Seaborn plots with Aesthetic functions<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 8<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#08a\"><span style=\"color: #ff0000;\">Bokeh line graph using Annotations and Legends<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 9<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#09a\"><span style=\"color: #ff0000;\">3D Plots using Plotly Libraries<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n\n\n\n<li><span style=\"color: #ff0000;\">Question 10<\/span>\n<ol class=\"wp-block-list\" style=\"list-style-type:lower-alpha\">\n<li><a href=\"#10a\"><span style=\"color: #ff0000;\">Time Series using Plotly Libraries<\/span><\/a><\/li>\n\n\n\n<li><a href=\"#10b\"><span style=\"color: #ff0000;\">Maps using Plotly Libraries.<\/span><\/a><\/li>\n<\/ol>\n<\/li>\n<\/ol>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 1 <\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"01a\">Calculation of Test Average<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Write a python program to find the best of two test average marks out of three test\u2019s marks accepted from the user.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Tue Feb 21 16:27:47 2023\n\n@author: putta\n&quot;&quot;&quot;\n\nm1 = int(input(&quot;Enter marks for test1 : &quot;))\nm2 = int(input(&quot;Enter marks for test2 : &quot;))\nm3 = int(input(&quot;Enter marks for test3 : &quot;))\n\n# if m1 &lt;= m2 and m1 &lt;= m3:\n#     avgMarks = (m2+m3)\/2\n# elif m2 &lt;= m1 and m2 &lt;= m3:\n#     avgMarks = (m1+m3)\/2\n# elif m3 &lt;= m1 and m2 &lt;= m2:\n#     avgMarks = (m1+m2)\/2    \n\nbest_of_two = sorted([m1, m2, m3], reverse=True)[:2]\naverage_best_of_two = sum(best_of_two)\/2\n    \nprint(&quot;Average of best two test marks out of three test\u2019s marks is&quot;, average_best_of_two);\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Tue Feb 21 16:27:47 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">m1 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter marks for test1 : &quot;<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">m2 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter marks for test2 : &quot;<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">m3 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter marks for test3 : &quot;<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># if m1 &lt;= m2 and m1 &lt;= m3:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#     avgMarks = (m2+m3)\/2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># elif m2 &lt;= m1 and m2 &lt;= m3:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#     avgMarks = (m1+m3)\/2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># elif m3 &lt;= m1 and m2 &lt;= m2:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#     avgMarks = (m1+m2)\/2    <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">best_of_two <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">sorted<\/span><span style=\"color: #E1E4E8\">([m1, m2, m3], <\/span><span style=\"color: #FFAB70\">reverse<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">True<\/span><span style=\"color: #E1E4E8\">)[:<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">average_best_of_two <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">sum<\/span><span style=\"color: #E1E4E8\">(best_of_two)<\/span><span style=\"color: #F97583\">\/<\/span><span style=\"color: #79B8FF\">2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Average of best two test marks out of three test\u2019s marks is&quot;<\/span><span style=\"color: #E1E4E8\">, average_best_of_two)<\/span><span style=\"color: #FDAEB7; font-style: italic\">;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python program is designed to calculate the average of the best two test marks out of three. The user is prompted to input the marks for three tests (test1, test2, and test3). The program then identifies the two highest test marks using the <strong>sorted<\/strong> function in descending order and selects the top two values. Finally, it calculates the average of these two highest marks and prints the result. This code is a concise way to determine the average performance based on the two best test scores out of three.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter marks for test1: 85\nEnter marks for test2: 92\nEnter marks for test3: 78\nAverage of best two test marks out of three test\u2019s marks is 90.0\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter marks for <\/span><span style=\"color: #B392F0\">test1<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #79B8FF\">85<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter marks for <\/span><span style=\"color: #B392F0\">test2<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #79B8FF\">92<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter marks for <\/span><span style=\"color: #B392F0\">test3<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #79B8FF\">78<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Average <\/span><span style=\"color: #F97583\">of<\/span><span style=\"color: #E1E4E8\"> best two test marks out <\/span><span style=\"color: #F97583\">of<\/span><span style=\"color: #E1E4E8\"> three test\u2019s marks is <\/span><span style=\"color: #79B8FF\">90.0<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"01b\">Palindrome Check &amp; Digit Occurrence Count<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Develop a Python program to check whether a given number is palindrome or not and also count the number of occurrences of each digit in the input number.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Tue Feb 21 16:35:54 2023\n\n@author: putta\n&quot;&quot;&quot;\n\nfrom collections import Counter\n\nvalue = input(&quot;Enter a value : &quot;)\nif value == value[::-1]:\n    print(&quot;Palindrome&quot;)\nelse:\n    print(&quot;Not Palindrome&quot;)\n    \ncounted_dict = Counter(value)\nfor key in sorted(counted_dict.keys()):\n    print(f'{key} appears {counted_dict[key]} times');\n\n&quot;&quot;&quot;\n#Alternate way to count appearances\nfor i in range(10):\n    if value.count(str(i)) &gt; 0:\n        print(f'{str(i)} appears {value.count(str(i))} times')\n&quot;&quot;&quot;\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Tue Feb 21 16:35:54 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">from<\/span><span style=\"color: #E1E4E8\"> collections <\/span><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> Counter<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">value <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter a value : &quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">if<\/span><span style=\"color: #E1E4E8\"> value <\/span><span style=\"color: #F97583\">==<\/span><span style=\"color: #E1E4E8\"> value[::<\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Palindrome&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">else<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Not Palindrome&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">counted_dict <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> Counter(value)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">for<\/span><span style=\"color: #E1E4E8\"> key <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">sorted<\/span><span style=\"color: #E1E4E8\">(counted_dict.keys()):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">f<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #79B8FF\">{<\/span><span style=\"color: #E1E4E8\">key<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\"> appears <\/span><span style=\"color: #79B8FF\">{<\/span><span style=\"color: #E1E4E8\">counted_dict[key]<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\"> times&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><span style=\"color: #FDAEB7; font-style: italic\">;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">#Alternate way to count appearances<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">for i in range(10):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    if value.count(str(i)) &gt; 0:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        print(f&#39;{str(i)} appears {value.count(str(i))} times&#39;)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script is a versatile program that performs two key tasks: palindrome checking and character counting.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Palindrome Check:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The user is prompted to input a value.<\/li>\n\n\n\n<li>The script determines whether the entered value is a palindrome, meaning it reads the same backward as forward.<\/li>\n\n\n\n<li>If the input is a palindrome, it prints &#8220;Palindrome&#8221;; otherwise, it prints &#8220;Not Palindrome.&#8221;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Character Count:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script utilizes the <code>Counter<\/code> class from the <code>collections<\/code> module to efficiently count the occurrences of each character in the input string.<\/li>\n\n\n\n<li>It then sorts the keys of the counted dictionary and prints each character along with the number of times it appears.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Alternate Character Count (commented-out):<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script provides an alternative method using a loop to count the occurrences of each digit (0 to 9) in the input string.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script is not only a quick and effective way to check for palindromes but also serves as a handy tool for analyzing the frequency of characters in a given input. The inclusion of alternative methods showcases the flexibility of the script, making it a valuable resource for both palindrome detection and character frequency analysis.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter a value: 987654\nNot Palindrome\n4 appears 1 times\n5 appears 1 times\n6 appears 1 times\n7 appears 1 times\n8 appears 1 times\n9 appears 1 times\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter a <\/span><span style=\"color: #B392F0\">value<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #79B8FF\">987654<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Not Palindrome<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">6<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">7<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">8<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">9<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter a value: 123321\nPalindrome\n1 appears 2 times\n2 appears 2 times\n3 appears 2 times\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter a <\/span><span style=\"color: #B392F0\">value<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #79B8FF\">123321<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Palindrome<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\"> appears <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> times<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 2<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"02a\">Fibonacci Sequence<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Defined as a function F as Fn = Fn-1 + Fn-2. Write a Python program which accepts a value for N (where N &gt;0) as input and pass this value to the function. Display suitable error message if the condition for input value is not followed.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Tue Feb 21 16:46:55 2023\n\n@author: putta\n&quot;&quot;&quot;\n\ndef fn(n):\n    if n &lt;= 2:\n        return n - 1\n    else:\n        return fn(n-1) + fn(n-2)\n\ntry:\n    num = int(input(&quot;Enter a number : &quot;))\n    if num &gt; 0:\n        print(f' fn({num}) = {fn(num)}')\n    else:\n        print(&quot;Input should be greater than 0&quot;)\nexcept ValueError:\n    print(&quot;Try with numeric value&quot;)\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Tue Feb 21 16:46:55 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">def<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">fn<\/span><span style=\"color: #E1E4E8\">(n):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">if<\/span><span style=\"color: #E1E4E8\"> n <\/span><span style=\"color: #F97583\">&lt;=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        <\/span><span style=\"color: #F97583\">return<\/span><span style=\"color: #E1E4E8\"> n <\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">else<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        <\/span><span style=\"color: #F97583\">return<\/span><span style=\"color: #E1E4E8\"> fn(n<\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">) <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> fn(n<\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">try<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    num <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter a number : &quot;<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">if<\/span><span style=\"color: #E1E4E8\"> num <\/span><span style=\"color: #F97583\">&gt;<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">f<\/span><span style=\"color: #9ECBFF\">&#39; fn(<\/span><span style=\"color: #79B8FF\">{<\/span><span style=\"color: #E1E4E8\">num<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\">) = <\/span><span style=\"color: #79B8FF\">{<\/span><span style=\"color: #E1E4E8\">fn(num)<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">else<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Input should be greater than 0&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">except<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">ValueError<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Try with numeric value&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script introduces a recursive implementation to calculate terms in the Fibonacci sequence. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Recursive Fibonacci Function:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script defines a function <code>fn<\/code> that calculates the nth term in the Fibonacci sequence.<\/li>\n\n\n\n<li>If the input <code>n<\/code> is 1 or 2, the function returns <code>n - 1<\/code>.<\/li>\n\n\n\n<li>For <code>n<\/code> greater than 2, the function recursively calls itself with <code>n-1<\/code> and <code>n-2<\/code> and returns the sum of the results.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>User Input and Output:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The user is prompted to enter a number.<\/li>\n\n\n\n<li>If a positive integer is provided, the script prints the result of calling the <code>fn<\/code> function with that number, representing the nth term in the Fibonacci sequence.<\/li>\n\n\n\n<li>If the entered value is not a positive integer, it prompts the user to enter a value greater than 0.<\/li>\n\n\n\n<li>If a non-numeric value is entered, it catches the <code>ValueError<\/code> and suggests trying with a numeric value.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as a simple yet illustrative example of a recursive function for computing Fibonacci sequence terms, offering insights into recursive algorithms and user input handling in Python.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter a number: 6\nfn(6) = 5\n\nEnter a number: -3\nInput should be greater than 0\n\nEnter a number: abc\nTry with numeric value\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter a <\/span><span style=\"color: #B392F0\">number<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #79B8FF\">6<\/span><\/span>\n<span class=\"line\"><span style=\"color: #B392F0\">fn<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">6<\/span><span style=\"color: #E1E4E8\">) <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">5<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter a <\/span><span style=\"color: #B392F0\">number<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #79B8FF\">3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Input should be greater than <\/span><span style=\"color: #79B8FF\">0<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter a <\/span><span style=\"color: #B392F0\">number<\/span><span style=\"color: #E1E4E8\">: abc<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Try <\/span><span style=\"color: #F97583\">with<\/span><span style=\"color: #E1E4E8\"> numeric value<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"02b\">Binary to Decimal &amp; Octal to Hexadecimal Conversion<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Develop a python program to convert binary to decimal, octal to hexadecimal using functions.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Tue Feb 21 20:57:52 2023\n\n@author: putta\n&quot;&quot;&quot;\n\n&quot;&quot;&quot;\ndef bin2Dec(val):\n    rev=val[::-1]\n    dec = 0\n    i = 0\n    for dig in rev:\n        dec += int(dig) * 2**i\n        i += 1\n    \n    return dec\n\n\ndef oct2Hex(val):\n    rev=val[::-1]\n    dec = 0\n    i = 0\n    for dig in rev:\n        dec += int(dig) * 8**i\n        i += 1\n    list=[]\n    while dec != 0:\n        list.append(dec%16)\n        dec = dec \/\/ 16\n        \n    nl=[]\n    for elem in list[::-1]:\n        if elem &lt;= 9:\n            nl.append(str(elem))\n        else:\n            nl.append(chr(ord('A') + (elem -10)))\n    hex = &quot;&quot;.join(nl)\n    \n    return hex\n\n\nbase = 2\nnum1 = input(&quot;Enter a binary number : &quot;)    \n# print(bin2Dec(num1))\nprint(int(num1, base))\n&quot;&quot;&quot;\n\n#A better implementation\ndef bin2Dec(val):\n    return int(val, 2)\n    \ndef oct2Hex(val):\n    return int(val, 8)\n\ntry:\n    num1 = input(&quot;Enter a binary number : &quot;)    \n    print(bin2Dec(num1))\nexcept ValueError:\n    print(&quot;Invalid literal in input with base 2&quot;)\n    \ntry:\n    num2 = input(&quot;Enter a octal number : &quot;)\n    print(oct2Hex(num2))\nexcept ValueError:\n    print(&quot;Invalid literal in input with base 8&quot;)\n\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Tue Feb 21 20:57:52 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">def bin2Dec(val):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    rev=val[::-1]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    dec = 0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    i = 0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    for dig in rev:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        dec += int(dig) * 2**i<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        i += 1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    return dec<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">def oct2Hex(val):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    rev=val[::-1]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    dec = 0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    i = 0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    for dig in rev:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        dec += int(dig) * 8**i<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        i += 1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    list=[]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    while dec != 0:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        list.append(dec%16)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        dec = dec \/\/ 16<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    nl=[]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    for elem in list[::-1]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        if elem &lt;= 9:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">            nl.append(str(elem))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        else:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">            nl.append(chr(ord(&#39;A&#39;) + (elem -10)))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    hex = &quot;&quot;.join(nl)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    return hex<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">base = 2<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">num1 = input(&quot;Enter a binary number : &quot;)    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\"># print(bin2Dec(num1))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">print(int(num1, base))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#A better implementation<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">def<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">bin2Dec<\/span><span style=\"color: #E1E4E8\">(val):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">return<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(val, <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">def<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">oct2Hex<\/span><span style=\"color: #E1E4E8\">(val):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">return<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(val, <\/span><span style=\"color: #79B8FF\">8<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">try<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    num1 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter a binary number : &quot;<\/span><span style=\"color: #E1E4E8\">)    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(bin2Dec(num1))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">except<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">ValueError<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Invalid literal in input with base 2&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">try<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    num2 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter a octal number : &quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(oct2Hex(num2))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">except<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">ValueError<\/span><span style=\"color: #E1E4E8\">:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Invalid literal in input with base 8&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This Python script includes two functions <strong>bin2Dec<\/strong> and <strong>oct2Hex<\/strong> for converting binary to decimal and octal to hexadecimal, respectively. The script takes user input for binary and octal numbers and converts them using these functions. Here&#8217;s a brief description:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Conversion Functions:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>bin2Dec<\/code> function converts a binary number to decimal using the <code>int()<\/code> function with base 2.<\/li>\n\n\n\n<li>The <code>oct2Hex<\/code> function converts an octal number to hexadecimal using the <code>int()<\/code> function with base 8.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>User Input Handling:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script includes <code>try-except<\/code> blocks to catch <code>ValueError<\/code> in case of invalid input.<\/li>\n\n\n\n<li>It prompts the user for a binary and an octal number, converts them, and prints the results.<\/li>\n\n\n\n<li>If an invalid input is detected, it prints an error message.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter a binary number: 101010\n42\n\nEnter an octal number: 755\n0x1FD\n\nEnter a binary number: 11011a\nInvalid literal in input with base 2\n\nEnter an octal number: 1298\nInvalid literal in input with base 8\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter a binary number: <\/span><span style=\"color: #79B8FF\">101010<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">42<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter an octal number: <\/span><span style=\"color: #79B8FF\">755<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">0x<\/span><span style=\"color: #79B8FF\">1FD<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter a binary number: <\/span><span style=\"color: #FDAEB7; font-style: italic\">11011a<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Invalid literal <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">with<\/span><span style=\"color: #E1E4E8\"> base <\/span><span style=\"color: #79B8FF\">2<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter an octal number: <\/span><span style=\"color: #79B8FF\">1298<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Invalid literal <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">with<\/span><span style=\"color: #E1E4E8\"> base <\/span><span style=\"color: #79B8FF\">8<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 3<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"03a\">Sentence Statistics<\/h3>\n\n\n\n<p>Write a Python program that accepts a sentence and find the number of words, digits, uppercase letters and lowercase letters.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Wed Feb 22 01:37:07 2023\n\n@author: putta\n&quot;&quot;&quot;\n\nimport string\n\nsentence = input(&quot;Enter a sentence : &quot;)\n\nwordList = sentence.strip().split(&quot; &quot;)\nprint(f'This sentence has {len(wordList)} words', end='\\n\\n')\n\ndigit_count = uppercase_count = lowercase_count = 0\n\nfor character in sentence:\n    if character in string.digits: \n        digit_count += 1\n    elif character in string.ascii_uppercase: \n        uppercase_count += 1\n    elif character in string.ascii_lowercase:\n        lowercase_count += 1\n\nprint(f'This sentence has {digit_count} digits',\n      f' {uppercase_count} upper case letters',\n      f' {lowercase_count} lower case letters', sep='\\n')\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Wed Feb 22 01:37:07 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> string<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">sentence <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter a sentence : &quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">wordList <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> sentence.strip().split(<\/span><span style=\"color: #9ECBFF\">&quot; &quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">f<\/span><span style=\"color: #9ECBFF\">&#39;This sentence has <\/span><span style=\"color: #79B8FF\">{len<\/span><span style=\"color: #E1E4E8\">(wordList)<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\"> words&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">end<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #79B8FF\">\\n\\n<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">digit_count <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> uppercase_count <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> lowercase_count <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">0<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">for<\/span><span style=\"color: #E1E4E8\"> character <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> sentence:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">if<\/span><span style=\"color: #E1E4E8\"> character <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> string.digits: <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        digit_count <\/span><span style=\"color: #F97583\">+=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">elif<\/span><span style=\"color: #E1E4E8\"> character <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> string.ascii_uppercase: <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        uppercase_count <\/span><span style=\"color: #F97583\">+=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">elif<\/span><span style=\"color: #E1E4E8\"> character <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> string.ascii_lowercase:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        lowercase_count <\/span><span style=\"color: #F97583\">+=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">1<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #F97583\">f<\/span><span style=\"color: #9ECBFF\">&#39;This sentence has <\/span><span style=\"color: #79B8FF\">{<\/span><span style=\"color: #E1E4E8\">digit_count<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\"> digits&#39;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">      <\/span><span style=\"color: #F97583\">f<\/span><span style=\"color: #9ECBFF\">&#39; <\/span><span style=\"color: #79B8FF\">{<\/span><span style=\"color: #E1E4E8\">uppercase_count<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\"> upper case letters&#39;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">      <\/span><span style=\"color: #F97583\">f<\/span><span style=\"color: #9ECBFF\">&#39; <\/span><span style=\"color: #79B8FF\">{<\/span><span style=\"color: #E1E4E8\">lowercase_count<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\"> lower case letters&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">sep<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #79B8FF\">\\n<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The above Python program is designed to analyse a user-inputted sentence, providing information on the number of words, digits, uppercase letters, and lowercase letters in the given text. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Word Count:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script splits the input sentence into words and prints the count of words in the sentence.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Character Analysis:<\/strong>\n<ul class=\"wp-block-list\">\n<li>It then iterates through each character in the sentence.<\/li>\n\n\n\n<li>The script counts the number of digits, uppercase letters, and lowercase letters using the <code>string<\/code> module.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Print Results:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Finally, it prints the counts of digits, uppercase letters, and lowercase letters in the given sentence.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as a versatile tool for quickly extracting key statistics from a user-provided sentence, offering insights into the composition of the text in terms of words and character types.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter a sentence : Rama went to Devaraja market to pick 2 kgs of vegetable\nThis sentence has 11 words\n\nThis sentence has 1 digits \n2 upper case letters \n42 lower case letters\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter a <\/span><span style=\"color: #B392F0\">sentence<\/span><span style=\"color: #E1E4E8\"> : Rama went to Devaraja market to pick <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> kgs <\/span><span style=\"color: #F97583\">of<\/span><span style=\"color: #E1E4E8\"> vegetable<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">This sentence has <\/span><span style=\"color: #79B8FF\">11<\/span><span style=\"color: #E1E4E8\"> words<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">This sentence has <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> digits <\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> upper <\/span><span style=\"color: #F97583\">case<\/span><span style=\"color: #E1E4E8\"> letters <\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">42<\/span><span style=\"color: #E1E4E8\"> lower <\/span><span style=\"color: #F97583\">case<\/span><span style=\"color: #E1E4E8\"> letters<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter a sentence: Python is Fun!\nThis sentence has 3 words\n\nThis sentence has 0 digits\n3 uppercase letters\n9 lowercase letters\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter a sentence: Python <\/span><span style=\"color: #F97583\">is<\/span><span style=\"color: #E1E4E8\"> Fun!<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">This sentence has <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\"> words<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">This sentence has <\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\"> digits<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\"> uppercase letters<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">9<\/span><span style=\"color: #E1E4E8\"> lowercase letters<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter a sentence: Hello, World! 123\nThis sentence has 3 words\n\nThis sentence has 3 digits\n1 uppercase letters\n12 lowercase letters\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter a sentence: Hello, World! <\/span><span style=\"color: #79B8FF\">123<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">This sentence has <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\"> words<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">This sentence has <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\"> digits<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> uppercase letters<\/span><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">12<\/span><span style=\"color: #E1E4E8\"> lowercase letters<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"03b\">String Similarity<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Write a Python program to find the string similarity between two given strings.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Wed Feb 22 01:48:17 2023\n\n@author: putta\n&quot;&quot;&quot;\n&quot;&quot;&quot;\nstr1 = input(&quot;Enter String 1 \\n&quot;).lower()\nstr2 = input(&quot;Enter String 2 \\n&quot;).lower()\n\n# if len(str2) &lt; len(str1):\n#     short = len(str2)\n#     long = len(str1)\n# else:\n#     short = len(str1)\n#     long = len(str2)\n\nstring_1_length = len(str1)\nstring_2_length = len(str2)\n\nshort_string_length, long_string_length = min(string_1_length, string_2_length), max(string_1_length, string_2_length) \n    \n\nmatch_count = 0\nfor i in range(short_string_length):\n    if str1[i] == str2[i]:\n        match_count += 1\n\nprint(&quot;Similarity between two said strings:&quot;)\nprint(match_count\/long_string_length)\n\n\n&quot;&quot;&quot;\n# An alternative solution to the same problem using Python libraries\n\nfrom difflib import SequenceMatcher\n\nstr1 = input(&quot;Enter String 1 : &quot;)\nstr2 = input(&quot;Enter String 2 : &quot;)\n\nsim = SequenceMatcher(None, str1, str2).ratio()\n\nprint(&quot;Similarity between strings \\&quot;&quot; + str1 + &quot;\\&quot; and \\&quot;&quot; + str2 + &quot;\\&quot; is : &quot;,sim)\n\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Wed Feb 22 01:48:17 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">str1 = input(&quot;Enter String 1 <\/span><span style=\"color: #79B8FF\">\\n<\/span><span style=\"color: #9ECBFF\">&quot;).lower()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">str2 = input(&quot;Enter String 2 <\/span><span style=\"color: #79B8FF\">\\n<\/span><span style=\"color: #9ECBFF\">&quot;).lower()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\"># if len(str2) &lt; len(str1):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">#     short = len(str2)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">#     long = len(str1)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\"># else:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">#     short = len(str1)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">#     long = len(str2)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">string_1_length = len(str1)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">string_2_length = len(str2)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">short_string_length, long_string_length = min(string_1_length, string_2_length), max(string_1_length, string_2_length) <\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    <\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">match_count = 0<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">for i in range(short_string_length):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">    if str1[i] == str2[i]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">        match_count += 1<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">print(&quot;Similarity between two said strings:&quot;)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">print(match_count\/long_string_length)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># An alternative solution to the same problem using Python libraries<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">from<\/span><span style=\"color: #E1E4E8\"> difflib <\/span><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> SequenceMatcher<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">str1 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter String 1 : &quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">str2 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">input<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Enter String 2 : &quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">sim <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> SequenceMatcher(<\/span><span style=\"color: #79B8FF\">None<\/span><span style=\"color: #E1E4E8\">, str1, str2).ratio()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">print<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;Similarity between strings <\/span><span style=\"color: #79B8FF\">\\&quot;<\/span><span style=\"color: #9ECBFF\">&quot;<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> str1 <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&quot;<\/span><span style=\"color: #79B8FF\">\\&quot;<\/span><span style=\"color: #9ECBFF\"> and <\/span><span style=\"color: #79B8FF\">\\&quot;<\/span><span style=\"color: #9ECBFF\">&quot;<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> str2 <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&quot;<\/span><span style=\"color: #79B8FF\">\\&quot;<\/span><span style=\"color: #9ECBFF\"> is : &quot;<\/span><span style=\"color: #E1E4E8\">,sim)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script is designed to compare the similarity between two user-inputted strings. The user is prompted to input two strings, and the script, after converting them to lowercase for case-insensitive comparison, calculates the similarity by counting the matching characters at corresponding positions. The similarity is then expressed as a ratio relative to the length of the longer string. Here&#8217;s a brief overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>User Input:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script prompts the user to enter two strings.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>String Comparison:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script then iterates through characters at corresponding positions and counts the matches.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Similarity Ratio:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The similarity between the two strings is calculated as the ratio of the count of matching characters to the length of the longer string.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Alternative Solution :<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script includes an alternative solution using the <code>SequenceMatcher<\/code> class from the <code>difflib<\/code> library, demonstrating a different approach to calculating string similarity.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script offers a straightforward way to measure the similarity between two strings and presents an alternative solution using Python libraries for a comparative understanding. It&#8217;s a useful tool for users interested in comparing the likeness of textual data.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"Enter String 1 : Python Exercises\nEnter String 2 : Python Exercise \nSimilarity between strings &quot;Python Exercises&quot; and &quot;Python Exercise&quot; is :  0.967741935483871\n\nEnter String 1 : Python Exercises\nEnter String 2 : Python Exercises\nSimilarity between strings &quot;Python Exercises&quot; and &quot;Python Exercises&quot; is :  1.0\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #E1E4E8\">Enter String <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> : Python Exercises<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter String <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> : Python Exercise <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Similarity between strings <\/span><span style=\"color: #9ECBFF\">&quot;Python Exercises&quot;<\/span><span style=\"color: #E1E4E8\"> and <\/span><span style=\"color: #9ECBFF\">&quot;Python Exercise&quot;<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">is<\/span><span style=\"color: #E1E4E8\"> :  <\/span><span style=\"color: #79B8FF\">0.967741935483871<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter String <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\"> : Python Exercises<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Enter String <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> : Python Exercises<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">Similarity between strings <\/span><span style=\"color: #9ECBFF\">&quot;Python Exercises&quot;<\/span><span style=\"color: #E1E4E8\"> and <\/span><span style=\"color: #9ECBFF\">&quot;Python Exercises&quot;<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">is<\/span><span style=\"color: #E1E4E8\"> :  <\/span><span style=\"color: #79B8FF\">1.0<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 4<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"04a\">Bar Plot using Matplotlib<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Write a Python program to Demonstrate how to Draw a Bar Plot using Matplotlib.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import matplotlib.pyplot as plt\n\n# Sample data for demonstration\ncategories = ['0-10', '10-20', '20-30', '30-40', '40-50']\nvalues = [55, 48, 25, 68, 90]\n\n# Create a bar plot\nplt.bar(categories, values, color='skyblue')\n\n# Add labels and title\nplt.xlabel('Overs')\nplt.ylabel('Runs')\nplt.title('Bar Plot Showing Runs scored in an ODI Match')\n\n# Display the plot\nplt.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Sample data for demonstration<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">categories <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #9ECBFF\">&#39;0-10&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;10-20&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;20-30&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;30-40&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;40-50&#39;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">values <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">55<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">48<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">25<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">68<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">90<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create a bar plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.bar(categories, values, <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;skyblue&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add labels and title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.xlabel(<\/span><span style=\"color: #9ECBFF\">&#39;Overs&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.ylabel(<\/span><span style=\"color: #9ECBFF\">&#39;Runs&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;Bar Plot Showing Runs scored in an ODI Match&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script utilizes the <code>matplotlib<\/code> library to create a bar plot showcasing runs scored in an ODI (One Day International) cricket match. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Sample Data:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script uses sample data representing runs scored in specific overs during an ODI cricket match.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Matplotlib Plotting:<\/strong>\n<ul class=\"wp-block-list\">\n<li>It utilizes the <code>matplotlib.pyplot<\/code> module to create a bar plot.<\/li>\n\n\n\n<li>The <code>bar<\/code> function is used to plot the data, where <code>categories<\/code> represent overs, and <code>values<\/code> represent runs scored.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Labels and Title:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script adds labels to the x-axis (<code>Overs<\/code>) and y-axis (<code>Runs<\/code>).<\/li>\n\n\n\n<li>It includes a title, &#8216;Bar Plot Showing Runs scored in an ODI Match,&#8217; to provide context to the plot.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> function is called to display the generated bar plot.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script is a straightforward example of using <code>matplotlib<\/code> to visualize data in a bar plot. It&#8217;s a valuable resource for individuals interested in creating basic data visualizations, particularly in the context of cricket statistics.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-00-39.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"612\" height=\"467\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-00-39.png?resize=612%2C467&#038;ssl=1\" alt=\"Bar Graph\" class=\"wp-image-1125 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-00-39.png?w=612&amp;ssl=1 612w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-00-39.png?resize=300%2C229&amp;ssl=1 300w\" data-sizes=\"(max-width: 612px) 100vw, 612px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 612px; --smush-placeholder-aspect-ratio: 612\/467;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"04b\">Scatter Plot using Matplotlib<\/h3>\n\n\n\n<p>Write a Python program to Demonstrate how to Draw a Scatter Plot using Matplotlib.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import matplotlib.pyplot as plt\nimport numpy as np\n\n# BRICS nations data (hypothetical)\ncountries = ['Brazil', 'Russia', 'India', 'China', 'South Africa']\npopulation = [213993437, 145912025, 1393409038, 1444216107, 61608912]  # Population in 2021\nper_capita_income = [9600, 11600, 2300, 11000, 6500]  # Per capita income in USD\n\n# Scale the population for circle size\ncircle_size = [pop \/ 1000000 for pop in population]  # Scaling down for better visualization\n\n# Assign different colors based on index\ncolors = np.arange(len(countries))\n\n# Create a scatter plot with varying circle sizes and colors\nscatter = plt.scatter(population, per_capita_income, s=circle_size, c=colors, cmap='viridis', alpha=0.7, label='BRICS Nations')\n\n# Annotate each point with the country name\nfor i, country in enumerate(countries):\n    plt.annotate(country, (population[i], per_capita_income[i]), textcoords=&quot;offset points&quot;, xytext=(0,5), ha='center')\n\n# Add colorbar\nplt.colorbar(scatter, label='Index')\n\n# Add labels and title\nplt.xlabel('Population')\nplt.ylabel('Per Capita Income (USD)')\nplt.title('Population vs Per Capita Income of BRICS Nations')\n\n# Display the plot\nplt.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> numpy <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> np<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># BRICS nations data (hypothetical)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">countries <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #9ECBFF\">&#39;Brazil&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Russia&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;India&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;China&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;South Africa&#39;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">population <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">213993437<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">145912025<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">1393409038<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">1444216107<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">61608912<\/span><span style=\"color: #E1E4E8\">]  <\/span><span style=\"color: #6A737D\"># Population in 2021<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">per_capita_income <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">9600<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">11600<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">2300<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">11000<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">6500<\/span><span style=\"color: #E1E4E8\">]  <\/span><span style=\"color: #6A737D\"># Per capita income in USD<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Scale the population for circle size<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">circle_size <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [pop <\/span><span style=\"color: #F97583\">\/<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">1000000<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">for<\/span><span style=\"color: #E1E4E8\"> pop <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> population]  <\/span><span style=\"color: #6A737D\"># Scaling down for better visualization<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Assign different colors based on index<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">colors <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.arange(<\/span><span style=\"color: #79B8FF\">len<\/span><span style=\"color: #E1E4E8\">(countries))<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create a scatter plot with varying circle sizes and colors<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">scatter <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> plt.scatter(population, per_capita_income, <\/span><span style=\"color: #FFAB70\">s<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">circle_size, <\/span><span style=\"color: #FFAB70\">c<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">colors, <\/span><span style=\"color: #FFAB70\">cmap<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;viridis&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">alpha<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">0.7<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;BRICS Nations&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Annotate each point with the country name<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">for<\/span><span style=\"color: #E1E4E8\"> i, country <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">enumerate<\/span><span style=\"color: #E1E4E8\">(countries):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    plt.annotate(country, (population[i], per_capita_income[i]), <\/span><span style=\"color: #FFAB70\">textcoords<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;offset points&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">xytext<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">), <\/span><span style=\"color: #FFAB70\">ha<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;center&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add colorbar<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.colorbar(scatter, <\/span><span style=\"color: #FFAB70\">label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Index&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add labels and title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.xlabel(<\/span><span style=\"color: #9ECBFF\">&#39;Population&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.ylabel(<\/span><span style=\"color: #9ECBFF\">&#39;Per Capita Income (USD)&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;Population vs Per Capita Income of BRICS Nations&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script employs the <code>matplotlib<\/code> library, along with <code>numpy<\/code>, to create a scatter plot visualizing population against per capita income for BRICS nations. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Sample Data:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script uses hypothetical data for BRICS nations, including population and per capita income.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Scaling for Visualization:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Circle sizes are scaled down from population values to enhance visualization.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Color Assignment:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Different colors are assigned based on the index of each country.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Scatter Plot:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>scatter<\/code> function is used to create a scatter plot with varying circle sizes and colors.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Annotations:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Each point on the plot is annotated with the country name for clarity.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Colorbar:<\/strong>\n<ul class=\"wp-block-list\">\n<li>A colorbar is added to the plot, providing a reference for the color index.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Labels and Title:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Labels for the x-axis, y-axis, and a title are included to provide context.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> function is called to display the generated scatter plot.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as an excellent example of using <code>matplotlib<\/code> for creating informative and visually appealing scatter plots, especially for comparing socio-economic indicators among different countries. It can be helpful for readers interested in data visualization and analysis.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-11-03.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"629\" height=\"472\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-11-03.png?resize=629%2C472&#038;ssl=1\" alt=\"\" class=\"wp-image-1129 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-11-03.png?w=629&amp;ssl=1 629w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-11-03.png?resize=300%2C225&amp;ssl=1 300w\" data-sizes=\"(max-width: 629px) 100vw, 629px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 629px; --smush-placeholder-aspect-ratio: 629\/472;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"05a\">Histogram Plot using Matplotlib<\/h3>\n\n\n\n<p>Write a Python program to Demonstrate how to Draw a Histogram Plot using Matplotlib.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import matplotlib.pyplot as plt\nimport numpy as np\n\n# Generate random student scores (example data)\nnp.random.seed(42)\nstudent_scores = np.random.normal(loc=70, scale=15, size=100)\n\n# Create a histogram plot\nplt.hist(student_scores, bins=20, color='skyblue', edgecolor='black')\n\n# Add labels and title\nplt.xlabel('Student Scores')\nplt.ylabel('Frequency')\nplt.title('Distribution of Student Scores')\n\n# Display the plot\nplt.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> numpy <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> np<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Generate random student scores (example data)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">np.random.seed(<\/span><span style=\"color: #79B8FF\">42<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">student_scores <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.random.normal(<\/span><span style=\"color: #FFAB70\">loc<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">70<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">scale<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">15<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">size<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">100<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create a histogram plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.hist(student_scores, <\/span><span style=\"color: #FFAB70\">bins<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">20<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;skyblue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">edgecolor<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;black&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add labels and title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.xlabel(<\/span><span style=\"color: #9ECBFF\">&#39;Student Scores&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.ylabel(<\/span><span style=\"color: #9ECBFF\">&#39;Frequency&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;Distribution of Student Scores&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script utilizes the <code>matplotlib<\/code> library and <code>numpy<\/code> to generate a histogram plot illustrating the distribution of student scores. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Random Data Generation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script generates example data representing student scores using a normal distribution (<code>np.random.normal<\/code>).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Histogram Plot:<\/strong>\n<ul class=\"wp-block-list\">\n<li>It creates a histogram plot using the <code>hist<\/code> function, where <code>student_scores<\/code> is the data array, <code>bins<\/code> determines the number of bins, and <code>color<\/code> sets the fill color while <code>edgecolor<\/code> sets the color of bin edges.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Labels and Title:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script adds labels to the x-axis (<code>Student Scores<\/code>) and y-axis (<code>Frequency<\/code>).<\/li>\n\n\n\n<li>A title, &#8216;Distribution of Student Scores,&#8217; is included to provide context to the plot.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> function is called to display the generated histogram plot.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as a simple yet effective demonstration of using <code>matplotlib<\/code> to visualize the distribution of a dataset, making it suitable for readers interested in introductory data visualization techniques. It&#8217;s especially valuable for those learning to interpret histograms in the context of student scores or similar datasets.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-16-38.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"629\" height=\"472\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-16-38.png?resize=629%2C472&#038;ssl=1\" alt=\"\" class=\"wp-image-1133 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-16-38.png?w=629&amp;ssl=1 629w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Screenshot-from-2023-10-13-02-16-38.png?resize=300%2C225&amp;ssl=1 300w\" data-sizes=\"(max-width: 629px) 100vw, 629px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 629px; --smush-placeholder-aspect-ratio: 629\/472;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"05b\">Pie Chart using Matplotlib<\/h3>\n\n\n\n<p>Write a Python program to Demonstrate how to Draw a Pie Chart using Matplotlib.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import matplotlib.pyplot as plt\n\n#Number of FIFA World Cup wins for different countries\ncountries = ['Brazil', 'Germany', 'Italy', 'Argentina', 'Uruguay', 'France', 'England', 'Spain']\nwins = [5, 4, 4, 3, 2, 2, 1, 1]  # Replace with actual data\n\n# Colors for each country\ncolors = ['yellow', 'magenta', 'green', 'blue', 'lightblue', 'blue', 'red', 'cyan']\n\nplt.pie(wins, labels=countries, autopct='%1.1f%%', colors=colors, startangle=90, explode=[0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2], shadow=True)\n\n# Add title\nplt.title('FIFA World Cup Wins by Country')\n\n# Display the plot\nplt.axis('equal')  # Equal aspect ratio ensures that the pie chart is circular.\nplt.show()\n\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#Number of FIFA World Cup wins for different countries<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">countries <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #9ECBFF\">&#39;Brazil&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Germany&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Italy&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Argentina&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Uruguay&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;France&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;England&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Spain&#39;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">wins <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">]  <\/span><span style=\"color: #6A737D\"># Replace with actual data<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Colors for each country<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">colors <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #9ECBFF\">&#39;yellow&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;magenta&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;green&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;blue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;lightblue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;blue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;red&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;cyan&#39;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.pie(wins, <\/span><span style=\"color: #FFAB70\">labels<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">countries, <\/span><span style=\"color: #FFAB70\">autopct<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #79B8FF\">%1.1f%%<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">colors<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">colors, <\/span><span style=\"color: #FFAB70\">startangle<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">90<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">explode<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">[<\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">], <\/span><span style=\"color: #FFAB70\">shadow<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">True<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;FIFA World Cup Wins by Country&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.axis(<\/span><span style=\"color: #9ECBFF\">&#39;equal&#39;<\/span><span style=\"color: #E1E4E8\">)  <\/span><span style=\"color: #6A737D\"># Equal aspect ratio ensures that the pie chart is circular.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script utilizes the <code>matplotlib<\/code> library to create a visually appealing pie chart representing the number of FIFA World Cup wins for different countries. Here&#8217;s a concise overview:<\/p>\n\n\n\n<p><strong>Data Representation:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The script uses hypothetical data representing the number of FIFA World Cup wins for different countries.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Pie Chart Creation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>It creates a pie chart using the <code>pie<\/code> function, where <code>wins<\/code> is the data array, <code>labels<\/code> are country names, and <code>autopct<\/code> formats the percentage display.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Colors and Styling:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Different colors are assigned to each country using the <code>colors<\/code> parameter.<\/li>\n\n\n\n<li>The pie chart is enhanced with features such as a start angle, explode effect, and shadow.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Title:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script adds a title to the pie chart, enhancing the overall context.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> function is called to display the generated pie chart.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as a clear and concise example of using <code>matplotlib<\/code> to create visually engaging pie charts, making it suitable for readers interested in representing categorical data, such as FIFA World Cup wins, in a graphical format.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_2.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1024\" height=\"476\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_2.png?resize=1024%2C476&#038;ssl=1\" alt=\"\" class=\"wp-image-1139 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_2.png?resize=1024%2C476&amp;ssl=1 1024w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_2.png?resize=300%2C139&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_2.png?resize=768%2C357&amp;ssl=1 768w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_2.png?w=1366&amp;ssl=1 1366w\" data-sizes=\"(max-width: 1000px) 100vw, 1000px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/476;\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Display values instead of percentages<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import matplotlib.pyplot as plt\n\n#Number of FIFA World Cup wins for different countries\ncountries = ['Brazil', 'Germany', 'Italy', 'Argentina', 'Uruguay', 'France', 'England', 'Spain']\nwins = [5, 4, 4, 3, 2, 2, 1, 1]  # Replace with actual data\n\n# Colors for each country\ncolors = ['yellow', 'magenta', 'green', 'blue', 'lightblue', 'blue', 'red', 'cyan']\n\ndef make_autopct(values):\n    def my_autopct(pct):\n        total = sum(values)\n        val = int(round(pct*total\/100.0))\n        return '{v:d}'.format(v=val)\n    return my_autopct\n    \n    \n# Create a pie chart\nplt.pie(wins, labels=countries, autopct=make_autopct(wins), colors=colors, startangle=90, explode=[0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2, 0.2], shadow=True)\n\n# Add title\nplt.title('FIFA World Cup Wins by Country')\n\n# Display the plot\nplt.axis('equal')  # Equal aspect ratio ensures that the pie chart is circular.\nplt.show()\n\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#Number of FIFA World Cup wins for different countries<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">countries <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #9ECBFF\">&#39;Brazil&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Germany&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Italy&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Argentina&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Uruguay&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;France&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;England&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;Spain&#39;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">wins <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">]  <\/span><span style=\"color: #6A737D\"># Replace with actual data<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Colors for each country<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">colors <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #9ECBFF\">&#39;yellow&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;magenta&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;green&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;blue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;lightblue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;blue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;red&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;cyan&#39;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">def<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">make_autopct<\/span><span style=\"color: #E1E4E8\">(values):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">def<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">my_autopct<\/span><span style=\"color: #E1E4E8\">(pct):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        total <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">sum<\/span><span style=\"color: #E1E4E8\">(values)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        val <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">round<\/span><span style=\"color: #E1E4E8\">(pct<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">total<\/span><span style=\"color: #F97583\">\/<\/span><span style=\"color: #79B8FF\">100.0<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        <\/span><span style=\"color: #F97583\">return<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #79B8FF\">{v<\/span><span style=\"color: #F97583\">:d<\/span><span style=\"color: #79B8FF\">}<\/span><span style=\"color: #9ECBFF\">&#39;<\/span><span style=\"color: #E1E4E8\">.format(<\/span><span style=\"color: #FFAB70\">v<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">val)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">return<\/span><span style=\"color: #E1E4E8\"> my_autopct<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create a pie chart<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.pie(wins, <\/span><span style=\"color: #FFAB70\">labels<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">countries, <\/span><span style=\"color: #FFAB70\">autopct<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">make_autopct(wins), <\/span><span style=\"color: #FFAB70\">colors<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">colors, <\/span><span style=\"color: #FFAB70\">startangle<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">90<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">explode<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">[<\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">0.2<\/span><span style=\"color: #E1E4E8\">], <\/span><span style=\"color: #FFAB70\">shadow<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">True<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;FIFA World Cup Wins by Country&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.axis(<\/span><span style=\"color: #9ECBFF\">&#39;equal&#39;<\/span><span style=\"color: #E1E4E8\">)  <\/span><span style=\"color: #6A737D\"># Equal aspect ratio ensures that the pie chart is circular.<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script, an extension of the previous pie chart example, enhances the pie chart&#8217;s autopct (automatic percentage display) to display actual win counts for each country. Here&#8217;s a concise overview:<\/p>\n\n\n\n<p><strong>Custom Autopct Function:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The script defines a custom <code>make_autopct<\/code> function that takes the values (win counts) as input.<\/li>\n\n\n\n<li>Inside this function, a nested function <code>my_autopct<\/code> calculates the actual win count based on the percentage.<\/li>\n<\/ul>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Enhanced Autopct in Pie Chart:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>autopct<\/code> parameter in the <code>pie<\/code> function is set to the custom autopct function, resulting in the display of actual win counts.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script creates and displays the pie chart with enhanced autopct for a more informative representation of the data.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script is a valuable addition for readers seeking to customize autopct in pie charts, providing a more detailed insight into the data being visualized.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_1.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"480\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_1.png?resize=640%2C480&#038;ssl=1\" alt=\"\" class=\"wp-image-1138 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_1.png?w=640&amp;ssl=1 640w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_1.png?resize=300%2C225&amp;ssl=1 300w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 640px; --smush-placeholder-aspect-ratio: 640\/480;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 6<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"06a\">Linear Plotting using Matplotlib<\/h3>\n\n\n\n<p>Write a Python program to illustrate Linear Plotting using Matplotlib.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import matplotlib.pyplot as plt\n\n# Hypothetical data: Run rate in an T20 cricket match\novers = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]\nruns_scored = [0,7,12,20,39,49,61,83,86,97,113,116,123,137,145,163,172,192,198,198,203]\n\n# Create a linear plot\nplt.plot(overs, runs_scored)\n\n# Add labels and title\nplt.xlabel('Overs')\nplt.ylabel('Runs scored')\nplt.title('Run scoring in an T20 Cricket Match')\n\n# Display the plot\nplt.grid(True)\nplt.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Hypothetical data: Run rate in an T20 cricket match<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">overs <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">6<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">7<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">8<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">9<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">10<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">11<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">12<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">13<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">14<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">15<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">16<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">17<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">18<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">19<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">20<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">runs_scored <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">7<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">12<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">20<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">39<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">49<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">61<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">83<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">86<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">97<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">113<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">116<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">123<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">137<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">145<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">163<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">172<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">192<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">198<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">198<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">203<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create a linear plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.plot(overs, runs_scored)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add labels and title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.xlabel(<\/span><span style=\"color: #9ECBFF\">&#39;Overs&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.ylabel(<\/span><span style=\"color: #9ECBFF\">&#39;Runs scored&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;Run scoring in an T20 Cricket Match&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.grid(<\/span><span style=\"color: #79B8FF\">True<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script utilizes the <code>matplotlib<\/code> library to create a linear plot representing the run rate in a hypothetical T20 cricket match. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Hypothetical Data:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script uses hypothetical data representing the number of runs scored in each over of a T20 cricket match.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Linear Plot:<\/strong>\n<ul class=\"wp-block-list\">\n<li>It creates a linear plot using the <code>plot<\/code> function, where <code>overs<\/code> is on the x-axis and <code>runs_scored<\/code> is on the y-axis.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Labels and Title:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script adds labels to the x-axis (<code>Overs<\/code>) and y-axis (<code>Runs scored<\/code>).<\/li>\n\n\n\n<li>A title, &#8216;Run Scoring in a T20 Cricket Match,&#8217; provides context to the plot.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Grid:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The plot includes a grid for better readability.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> function is called to display the generated linear plot.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as a straightforward example of using <code>matplotlib<\/code> to visualize run scoring trends in a T20 cricket match, making it suitable for readers interested in representing time-dependent data in a graphical format.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_3.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"480\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_3.png?resize=640%2C480&#038;ssl=1\" alt=\"\" class=\"wp-image-1143 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_3.png?w=640&amp;ssl=1 640w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_3.png?resize=300%2C225&amp;ssl=1 300w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 640px; --smush-placeholder-aspect-ratio: 640\/480;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"06b\">Linear Plotting with line formatting using Matplotlib<\/h3>\n\n\n\n<p>Write a Python program to illustrate liner plotting with line formatting using Matplotlib.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import matplotlib.pyplot as plt\n\n# Hypothetical data: Run rate in an T20 cricket match\novers = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]\nruns_scored = [0,7,12,20,39,49,61,83,86,97,113,116,123,137,145,163,172,192,198,198,203]\n\n# Create a linear plot\nplt.plot(overs, runs_scored, marker='X', linestyle='dashed',color='red', linewidth=2, markerfacecolor='blue', markersize=8)\n\n# Add labels and title\nplt.xlabel('Overs', color = 'green')\nplt.ylabel('Runs scored')\nplt.title('Run scoring in an T20 Cricket Match')\n\n# Display the plot\nplt.grid(True)\nplt.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Hypothetical data: Run rate in an T20 cricket match<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">overs <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">6<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">7<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">8<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">9<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">10<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">11<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">12<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">13<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">14<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">15<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">16<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">17<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">18<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">19<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">20<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">runs_scored <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> [<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">7<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">12<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">20<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">39<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">49<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">61<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">83<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">86<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">97<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">113<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">116<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">123<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">137<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">145<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">163<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">172<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">192<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">198<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">198<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #79B8FF\">203<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create a linear plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.plot(overs, runs_scored, <\/span><span style=\"color: #FFAB70\">marker<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;X&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">linestyle<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;dashed&#39;<\/span><span style=\"color: #E1E4E8\">,<\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;red&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">linewidth<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">markerfacecolor<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;blue&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">markersize<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">8<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Add labels and title<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.xlabel(<\/span><span style=\"color: #9ECBFF\">&#39;Overs&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;green&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.ylabel(<\/span><span style=\"color: #9ECBFF\">&#39;Runs scored&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;Run scoring in an T20 Cricket Match&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.grid(<\/span><span style=\"color: #79B8FF\">True<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script, an extension of the previous T20 cricket match run rate plot, customizes the appearance of the plot with specific markers, line styles, colors, and label styles. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Customized Plot Appearance:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>plot<\/code> function is customized with parameters such as <code>marker<\/code>, <code>linestyle<\/code>, <code>color<\/code>, <code>linewidth<\/code>, <code>markerfacecolor<\/code>, and <code>markersize<\/code> to control the appearance of the plot.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Labels and Title Styling:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script adds labels to the x-axis (<code>Overs<\/code>) and y-axis (<code>Runs scored<\/code>) with specific color styling.<\/li>\n\n\n\n<li>The title, &#8216;Run Scoring in a T20 Cricket Match,&#8217; maintains clarity.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Grid:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The plot includes a grid for better readability.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> function is called to display the generated customized linear plot.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script is an excellent example for readers looking to customize plot aesthetics in <code>matplotlib<\/code> for a more visually appealing representation of data. It&#8217;s especially helpful for those interested in enhancing the clarity and style of their data visualizations.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_4.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"640\" height=\"480\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_4.png?resize=640%2C480&#038;ssl=1\" alt=\"\" class=\"wp-image-1145 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_4.png?w=640&amp;ssl=1 640w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/Figure_4.png?resize=300%2C225&amp;ssl=1 300w\" data-sizes=\"(max-width: 640px) 100vw, 640px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 640px; --smush-placeholder-aspect-ratio: 640\/480;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 7<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"07a\">Seaborn plots with Aesthetic functions<\/h3>\n\n\n\n<p>Write a Python program which explains uses of customizing seaborn plots with Aesthetic functions.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import numpy as np\nimport matplotlib.pyplot as plt\nimport seaborn as sns\n\ndef sinplot(n=10):\n    x = np.linspace(0, 14, 100)\n    for i in range(1, n + 1):\n        plt.plot(x, np.sin(x + i * .5) * (n + 2 - i))\n\n        \nsns.set_theme()\n#sns.set_context(&quot;talk&quot;)\nsns.set_context(&quot;notebook&quot;, font_scale=1.5, rc={&quot;lines.linewidth&quot;: 2.5})\n\nsinplot()\nplt.title('Seaborn plots with Aesthetic functions')\nplt.show()\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> numpy <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> np<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> matplotlib.pyplot <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> plt<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> seaborn <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> sns<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">def<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #B392F0\">sinplot<\/span><span style=\"color: #E1E4E8\">(n<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">10<\/span><span style=\"color: #E1E4E8\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    x <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.linspace(<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">14<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">100<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #F97583\">for<\/span><span style=\"color: #E1E4E8\"> i <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">range<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">, n <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">1<\/span><span style=\"color: #E1E4E8\">):<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        plt.plot(x, np.sin(x <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> i <\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">.5<\/span><span style=\"color: #E1E4E8\">) <\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\"> (n <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #E1E4E8\"> i))<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">sns.set_theme()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#sns.set_context(&quot;talk&quot;)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">sns.set_context(<\/span><span style=\"color: #9ECBFF\">&quot;notebook&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">font_scale<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">1.5<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">rc<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">{<\/span><span style=\"color: #9ECBFF\">&quot;lines.linewidth&quot;<\/span><span style=\"color: #E1E4E8\">: <\/span><span style=\"color: #79B8FF\">2.5<\/span><span style=\"color: #E1E4E8\">})<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">sinplot()<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.title(<\/span><span style=\"color: #9ECBFF\">&#39;Seaborn plots with Aesthetic functions&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">plt.show()<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script utilizes the <code>seaborn<\/code> library, in conjunction with <code>numpy<\/code> and <code>matplotlib<\/code>, to create a series of sine wave plots with customized aesthetics. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Generation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script uses <code>numpy<\/code> to generate a series of sine wave plots.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Seaborn Integration:<\/strong>\n<ul class=\"wp-block-list\">\n<li><code>seaborn<\/code> is imported and configured with a default theme (<code>set_theme<\/code>).<\/li>\n\n\n\n<li>The context is set to &#8220;notebook&#8221; with customized font scaling and line width (<code>set_context<\/code>).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Customized Aesthetics:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>sinplot<\/code> function generates multiple sine wave plots with varying frequencies and amplitudes.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Title and Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script adds a title to the plot, &#8216;Seaborn Plots with Aesthetic Functions.&#8217;<\/li>\n\n\n\n<li>The <code>show<\/code> function is called to display the generated plots.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as an illustrative example of how <code>seaborn<\/code> can be used to enhance the aesthetics of data visualizations, providing readers with insights into customizing plot styles and themes for more visually appealing results. It&#8217;s particularly useful for those looking to leverage <code>seaborn<\/code> for improved aesthetics in their data analysis and visualization workflows.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/image.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"568\" height=\"449\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/image.png?resize=568%2C449&#038;ssl=1\" alt=\"\" class=\"wp-image-1152 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/image.png?w=568&amp;ssl=1 568w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/image.png?resize=300%2C237&amp;ssl=1 300w\" data-sizes=\"(max-width: 568px) 100vw, 568px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 568px; --smush-placeholder-aspect-ratio: 568\/449;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 8<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"08a\">Bokeh line graph using Annotations and Legends<\/h3>\n\n\n\n<p>Write a Python program to explain working with Bokeh line graph using Annotations and Legends.<br>a) Write a Python program for plotting different types of plots using Bokeh.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Sat Sep 30 02:17:24 2023\n\n@author: putta\n&quot;&quot;&quot;\n\nimport numpy as np\n\nfrom bokeh.layouts import gridplot\nfrom bokeh.plotting import figure, show\n\nx = np.linspace(0, 4*np.pi, 100)\ny = np.sin(x)\n\nTOOLS = &quot;pan,wheel_zoom,box_zoom,reset,save,box_select&quot;\n\np1 = figure(title=&quot;Example 1&quot;, tools=TOOLS)\n\np1.circle(x,   y, legend_label=&quot;sin(x)&quot;)\np1.circle(x, 2*y, legend_label=&quot;2*sin(x)&quot;, color=&quot;orange&quot;)\np1.circle(x, 3*y, legend_label=&quot;3*sin(x)&quot;, color=&quot;green&quot;)\n\np1.legend.title = 'Markers'\n\np2 = figure(title=&quot;Example 2&quot;, tools=TOOLS)\n\np2.circle(x, y, legend_label=&quot;sin(x)&quot;)\np2.line(x, y, legend_label=&quot;sin(x)&quot;)\n\np2.line(x, 2*y, legend_label=&quot;2*sin(x)&quot;,\n        line_dash=(4, 4), line_color=&quot;orange&quot;, line_width=2)\n\np2.square(x, 3*y, legend_label=&quot;3*sin(x)&quot;, fill_color=None, line_color=&quot;green&quot;)\np2.line(x, 3*y, legend_label=&quot;3*sin(x)&quot;, line_color=&quot;green&quot;)\n\np2.legend.title = 'Lines'\n\nshow(gridplot([p1, p2], ncols=2, width=400, height=400))\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Sat Sep 30 02:17:24 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> numpy <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> np<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">from<\/span><span style=\"color: #E1E4E8\"> bokeh.layouts <\/span><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> gridplot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">from<\/span><span style=\"color: #E1E4E8\"> bokeh.plotting <\/span><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> figure, show<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">x <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.linspace(<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">np.pi, <\/span><span style=\"color: #79B8FF\">100<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">y <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.sin(x)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #79B8FF\">TOOLS<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&quot;pan,wheel_zoom,box_zoom,reset,save,box_select&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p1 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> figure(<\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;Example 1&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">tools<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">TOOLS<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p1.circle(x,   y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p1.circle(x, <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;2*sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;orange&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p1.circle(x, <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;3*sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;green&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p1.legend.title <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;Markers&#39;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p2 <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> figure(<\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;Example 2&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">tools<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">TOOLS<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p2.circle(x, y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p2.line(x, y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p2.line(x, <\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;2*sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">        <\/span><span style=\"color: #FFAB70\">line_dash<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">4<\/span><span style=\"color: #E1E4E8\">), <\/span><span style=\"color: #FFAB70\">line_color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;orange&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">line_width<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p2.square(x, <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;3*sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">fill_color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">None<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">line_color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;green&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p2.line(x, <\/span><span style=\"color: #79B8FF\">3<\/span><span style=\"color: #F97583\">*<\/span><span style=\"color: #E1E4E8\">y, <\/span><span style=\"color: #FFAB70\">legend_label<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;3*sin(x)&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">line_color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;green&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">p2.legend.title <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #9ECBFF\">&#39;Lines&#39;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">show(gridplot([p1, p2], <\/span><span style=\"color: #FFAB70\">ncols<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">width<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">400<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">height<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">400<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script demonstrates the use of the Bokeh library to create interactive data visualizations with multiple plots. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Generation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script generates example data (<code>x<\/code> and <code>y<\/code>) using NumPy to represent sine waves.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Tools:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Bokeh&#8217;s interactive tools (<code>TOOLS<\/code>) are enabled for features like pan, zoom, reset, and save.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Multiple Plots:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Two separate plots (<code>p1<\/code> and <code>p2<\/code>) are created with different visualizations, including circles, lines, and markers.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Legend and Titles:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Legends are added to distinguish between different elements in the plots.<\/li>\n\n\n\n<li>Titles are provided for each plot.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Grid Layout:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>gridplot<\/code> function is used to arrange the plots in a grid layout.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> function is called to display the grid layout, enabling interactive exploration.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as an introduction to using Bokeh for creating interactive visualizations with multiple plots, making it suitable for readers interested in interactive data exploration and visualization techniques.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-default is-cropped wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot1.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"400\" height=\"400\" data-id=\"1155\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot1.png?resize=400%2C400&#038;ssl=1\" alt=\"\" class=\"wp-image-1155 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot1.png?w=400&amp;ssl=1 400w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot1.png?resize=300%2C300&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot1.png?resize=150%2C150&amp;ssl=1 150w\" data-sizes=\"(max-width: 400px) 100vw, 400px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 400px; --smush-placeholder-aspect-ratio: 400\/400;\" \/><\/a><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot2.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"400\" height=\"400\" data-id=\"1156\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot2.png?resize=400%2C400&#038;ssl=1\" alt=\"\" class=\"wp-image-1156 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot2.png?w=400&amp;ssl=1 400w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot2.png?resize=300%2C300&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/bokeh_plot2.png?resize=150%2C150&amp;ssl=1 150w\" data-sizes=\"(max-width: 400px) 100vw, 400px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 400px; --smush-placeholder-aspect-ratio: 400\/400;\" \/><\/a><\/figure>\n<\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Question 9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"09a\">3D Plots using Plotly Libraries<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Write a Python program to draw 3D Plots using Plotly Libraries.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import plotly.graph_objects as go\nimport numpy as np\n\n# Generate sample 3D data\nx = np.linspace(-5, 5, 100)\ny = np.linspace(-5, 5, 100)\nx, y = np.meshgrid(x, y)\nz = np.sin(np.sqrt(x**2 + y**2))\n\n# Create a 3D surface plot\nfig = go.Figure(data=[go.Surface(z=z, x=x, y=y)])\n\n# Customize layout\nfig.update_layout(scene=dict(\n                    xaxis_title='X Axis',\n                    yaxis_title='Y Axis',\n                    zaxis_title='Z Axis'),\n                margin=dict(l=0, r=0, b=0, t=40),\n                title='3D Surface Plot of sin(sqrt(x^2 + y^2))')\n\n# Display the 3D surface plot\nfig.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> plotly.graph_objects <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> go<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> numpy <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> np<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Generate sample 3D data<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">x <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.linspace(<\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">100<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">y <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.linspace(<\/span><span style=\"color: #F97583\">-<\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">5<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #79B8FF\">100<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">x, y <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.meshgrid(x, y)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">z <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> np.sin(np.sqrt(x<\/span><span style=\"color: #F97583\">**<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\"> <\/span><span style=\"color: #F97583\">+<\/span><span style=\"color: #E1E4E8\"> y<\/span><span style=\"color: #F97583\">**<\/span><span style=\"color: #79B8FF\">2<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create a 3D surface plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> go.Figure(<\/span><span style=\"color: #FFAB70\">data<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">[go.Surface(<\/span><span style=\"color: #FFAB70\">z<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">z, <\/span><span style=\"color: #FFAB70\">x<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">x, <\/span><span style=\"color: #FFAB70\">y<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">y)])<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Customize layout<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.update_layout(<\/span><span style=\"color: #FFAB70\">scene<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">dict<\/span><span style=\"color: #E1E4E8\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">                    <\/span><span style=\"color: #FFAB70\">xaxis_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;X Axis&#39;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">                    <\/span><span style=\"color: #FFAB70\">yaxis_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Y Axis&#39;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">                    <\/span><span style=\"color: #FFAB70\">zaxis_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Z Axis&#39;<\/span><span style=\"color: #E1E4E8\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">                <\/span><span style=\"color: #FFAB70\">margin<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">dict<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #FFAB70\">l<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">r<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">b<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">t<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">40<\/span><span style=\"color: #E1E4E8\">),<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">                <\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;3D Surface Plot of sin(sqrt(x^2 + y^2))&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Display the 3D surface plot<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>This program generates a 3D surface plot of the function <em><strong>z = sin(sqrt(x<sup>2<\/sup>+y<sup>2\u200b<\/sup>))<\/strong><\/em>. You can modify the function or provide your own data to create different types of 3D plots. The visualization will be interactive, allowing you to rotate and explore the plot.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot6.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"919\" height=\"360\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot6.png?resize=919%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-1179 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot6.png?w=919&amp;ssl=1 919w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot6.png?resize=300%2C118&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot6.png?resize=768%2C301&amp;ssl=1 768w\" data-sizes=\"(max-width: 919px) 100vw, 919px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 919px; --smush-placeholder-aspect-ratio: 919\/360;\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Another Example<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import plotly.express as px\ndf = px.data.gapminder().query(&quot;continent=='Asia'&quot;)\nfig = px.line_3d(df, x=&quot;gdpPercap&quot;, y=&quot;pop&quot;, z=&quot;year&quot;, color='country', title='Economic Evolution of Asian Countries Over Time')\nfig.show()\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> plotly.express <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> px<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">df <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> px.data.gapminder().query(<\/span><span style=\"color: #9ECBFF\">&quot;continent==&#39;Asia&#39;&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> px.line_3d(df, <\/span><span style=\"color: #FFAB70\">x<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;gdpPercap&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">y<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;pop&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">z<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;year&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;country&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Economic Evolution of Asian Countries Over Time&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.show()<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In this Python program, we leverage the power of Plotly Express to visualize the economic evolution of Asian countries over time. The dataset used is Gapminder, a comprehensive collection of global development indicators. The focus is specifically on the Asian continent.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Import Libraries:<\/strong>\n<ul class=\"wp-block-list\">\n<li>We start by importing the necessary libraries, including <code>plotly.express<\/code> for interactive visualizations.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Data Loading:<\/strong>\n<ul class=\"wp-block-list\">\n<li>We load the Gapminder dataset and filter it to include only Asian countries.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>3D Line Plot:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The key visualization is a 3D line plot created using <code>px.line_3d<\/code>.<\/li>\n\n\n\n<li>The x-axis represents the GDP per capita (<code>gdpPercap<\/code>), the y-axis represents the population (<code>pop<\/code>), and the z-axis represents the year (<code>year<\/code>).<\/li>\n\n\n\n<li>Each line corresponds to a different country, differentiated by color.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Exploration:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The resulting plot is interactive, allowing users to zoom, pan, and hover over data points to explore specific details.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Users can observe how GDP per capita and population have changed over the years for various Asian countries. The color-coded lines help distinguish between different nations.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot7.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"919\" height=\"360\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot7.png?resize=919%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-1183 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot7.png?w=919&amp;ssl=1 919w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot7.png?resize=300%2C118&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot7.png?resize=768%2C301&amp;ssl=1 768w\" data-sizes=\"(max-width: 919px) 100vw, 919px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 919px; --smush-placeholder-aspect-ratio: 919\/360;\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Question 10<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"10a\">Time Series using Plotly Libraries<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Write a Python program to draw Time Series using Plotly Libraries.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code -Example 1<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#!\/usr\/bin\/env python3\n# -*- coding: utf-8 -*-\n&quot;&quot;&quot;\nCreated on Mon Oct  2 15:23:19 2023\n\n@author: putta\n&quot;&quot;&quot;\n\nimport pandas as pd\nimport plotly.express as px\n\ndollar_conv = pd.read_csv('CUR_DLR_INR.csv')\n\nfig = px.line(dollar_conv, x='DATE', y='RATE', title='Dollar vs Rupee')\nfig.show()\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#!\/usr\/bin\/env python3<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># -*- coding: utf-8 -*-<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">Created on Mon Oct  2 15:23:19 2023<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">@author: putta<\/span><\/span>\n<span class=\"line\"><span style=\"color: #9ECBFF\">&quot;&quot;&quot;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> pandas <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> pd<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> plotly.express <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> px<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">dollar_conv <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> pd.read_csv(<\/span><span style=\"color: #9ECBFF\">&#39;CUR_DLR_INR.csv&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> px.line(dollar_conv, <\/span><span style=\"color: #FFAB70\">x<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;DATE&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">y<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;RATE&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Dollar vs Rupee&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.show()<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">CUR_DLR_INR.csv<\/h4>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-95998f11-2bcf-4976-94fa-93ec46cd7c70\" href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/CUR_DLR_INR.csv\">CUR_DLR_INR<\/a><a href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/CUR_DLR_INR.csv\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-95998f11-2bcf-4976-94fa-93ec46cd7c70\">Download<\/a><\/div>\n\n\n\n<p>The provided Python script showcases the use of the Plotly Express library to create an interactive line plot depicting the exchange rate between the US Dollar and the Indian Rupee over time. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Import:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script uses the Pandas library to read currency conversion data from a CSV file (&#8216;CUR_DLR_INR.csv&#8217;). You can download the csv file given above.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Plotly Express:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Plotly Express (<code>px<\/code>) is employed to create an interactive line plot with the exchange rate data.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Line Plot:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>line<\/code> function from Plotly Express is used to generate a line plot.<\/li>\n\n\n\n<li>The x-axis represents dates (&#8216;DATE&#8217;), and the y-axis represents exchange rates (&#8216;RATE&#8217;).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Title:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The plot is given a title, &#8216;Dollar vs Rupee,&#8217; for context.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> method is called on the figure (<code>fig<\/code>) to display the interactive plot.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script provides a quick and effective demonstration of using Plotly Express to visualize time-series data, making it suitable for readers interested in creating interactive and visually appealing line plots for financial or currency-related datasets.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"919\" height=\"360\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot.png?resize=919%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-1165 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot.png?w=919&amp;ssl=1 919w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot.png?resize=300%2C118&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot.png?resize=768%2C301&amp;ssl=1 768w\" data-sizes=\"(max-width: 919px) 100vw, 919px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 919px; --smush-placeholder-aspect-ratio: 919\/360;\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code -Example 2<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import pandas as pd\nimport plotly.express as px\n\nruns_scored = pd.read_csv('AusVsInd.csv')\nfig = px.line(runs_scored, x='Overs', y=['AUS', 'IND'], markers=True)\nfig.update_layout(title='Australia vs India ODI Match', xaxis_title='OVERS', yaxis_title='RUNS', legend_title='Country')\n\nfig.show()\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> pandas <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> pd<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> plotly.express <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> px<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">runs_scored <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> pd.read_csv(<\/span><span style=\"color: #9ECBFF\">&#39;AusVsInd.csv&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> px.line(runs_scored, <\/span><span style=\"color: #FFAB70\">x<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Overs&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">y<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">[<\/span><span style=\"color: #9ECBFF\">&#39;AUS&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;IND&#39;<\/span><span style=\"color: #E1E4E8\">], <\/span><span style=\"color: #FFAB70\">markers<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">True<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.update_layout(<\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Australia vs India ODI Match&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">xaxis_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;OVERS&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">yaxis_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;RUNS&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">legend_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Country&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.show()<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">AusVsInd.csv File<\/h4>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-8e63971d-51a1-4236-a204-517ce4a94bb4\" href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/AusVsInd.csv\">AusVsInd.csv<\/a><a href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/AusVsInd.csv\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-8e63971d-51a1-4236-a204-517ce4a94bb4\">Download<\/a><\/div>\n\n\n\n<p>The provided Python script utilizes the Plotly Express library to create an interactive line plot comparing the runs scored by Australia (AUS) and India (IND) over a series of overs in an ODI cricket match. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Import:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script uses Pandas to read runs scored data from a CSV file (&#8216;AusVsInd.csv&#8217;).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Plotly Express:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Plotly Express (<code>px<\/code>) is employed to create an interactive line plot.<\/li>\n\n\n\n<li>The x-axis represents overs (&#8216;Overs&#8217;), and the y-axis represents runs scored by Australia and India.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Markers:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Markers are added to the plot for each data point to enhance visibility.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Customized Layout:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The layout is customized with a title (&#8216;Australia vs India ODI Match&#8217;), x-axis label (&#8216;OVERS&#8217;), y-axis label (&#8216;RUNS&#8217;), and legend title (&#8216;Country&#8217;).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> method is called on the figure (<code>fig<\/code>) to display the interactive plot.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as an excellent example for readers interested in using Plotly Express for comparing and visualizing data, particularly in the context of sports analytics or cricket match statistics. The interactive features make it easy for users to explore the data interactively.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot2.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"919\" height=\"360\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot2.png?resize=919%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-1168 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot2.png?w=919&amp;ssl=1 919w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot2.png?resize=300%2C118&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot2.png?resize=768%2C301&amp;ssl=1 768w\" data-sizes=\"(max-width: 919px) 100vw, 919px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 919px; --smush-placeholder-aspect-ratio: 919\/360;\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Bar Graph for runs scored every  over<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"#Bar Graph of Runs scored every Over\nimport pandas as pd\nimport plotly.express as px\n\nruns_scored = pd.read_csv('AusVsInd.csv')\n\nfig = px.bar(runs_scored, x='Overs', y=['AUS_RPO', 'IND_RPO'], barmode='group')\nfig.update_layout(title='Australia vs India ODI Match', xaxis_title='OVERS', yaxis_title='RUNS', legend_title='Country')\n\nfig.show()\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #6A737D\">#Bar Graph of Runs scored every Over<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> pandas <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> pd<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> plotly.express <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> px<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">runs_scored <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> pd.read_csv(<\/span><span style=\"color: #9ECBFF\">&#39;AusVsInd.csv&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> px.bar(runs_scored, <\/span><span style=\"color: #FFAB70\">x<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Overs&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">y<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">[<\/span><span style=\"color: #9ECBFF\">&#39;AUS_RPO&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&#39;IND_RPO&#39;<\/span><span style=\"color: #E1E4E8\">], <\/span><span style=\"color: #FFAB70\">barmode<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;group&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.update_layout(<\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Australia vs India ODI Match&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">xaxis_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;OVERS&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">yaxis_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;RUNS&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">legend_title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;Country&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.show()<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>The provided Python script uses the Plotly Express library to create an interactive grouped bar graph comparing the runs per over (RPO) scored by Australia (AUS) and India (IND) in an ODI cricket match. Here&#8217;s a concise overview:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Data Import:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The script uses Pandas to read runs scored data from a CSV file (&#8216;AusVsInd.csv&#8217;).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Plotly Express:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Plotly Express (<code>px<\/code>) is employed to create an interactive grouped bar graph.<\/li>\n\n\n\n<li>The x-axis represents overs (&#8216;Overs&#8217;), and the y-axis represents runs per over scored by Australia and India.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Grouped Bars:<\/strong>\n<ul class=\"wp-block-list\">\n<li>Bars are grouped for each over, and the bar mode is set to &#8216;group&#8217; to display bars side by side.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Customized Layout:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The layout is customized with a title (&#8216;Australia vs India ODI Match&#8217;), x-axis label (&#8216;OVERS&#8217;), y-axis label (&#8216;RUNS&#8217;), and legend title (&#8216;Country&#8217;).<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Display:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The <code>show<\/code> method is called on the figure (<code>fig<\/code>) to display the interactive grouped bar graph.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>This script serves as an illustrative example for readers interested in using Plotly Express to visualize and compare runs scored per over by different teams in a cricket match. The interactive nature of the graph allows users to explore the data interactively.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot3.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"919\" height=\"360\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot3.png?resize=919%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-1172 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot3.png?w=919&amp;ssl=1 919w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot3.png?resize=300%2C118&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot3.png?resize=768%2C301&amp;ssl=1 768w\" data-sizes=\"(max-width: 919px) 100vw, 919px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 919px; --smush-placeholder-aspect-ratio: 919\/360;\" \/><\/a><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"10b\">Maps using Plotly Libraries<\/h3>\n\n\n\n<p class=\"has-text-align-justify\">Write a Python program for creating Maps using Plotly Libraries.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code -Example 1<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import plotly.express as px\nimport pandas as pd\n\n\n# Import data from GitHub\ndata = pd.read_csv('https:\/\/raw.githubusercontent.com\/plotly\/datasets\/master\/gapminder_with_codes.csv')\n\n\n# Create basic choropleth map\nfig = px.choropleth(data, locations='iso_alpha', color='gdpPercap', hover_name='country',\n                    projection='natural earth', title='GDP per Capita by Country')\nfig.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> plotly.express <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> px<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> pandas <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> pd<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Import data from GitHub<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">data <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> pd.read_csv(<\/span><span style=\"color: #9ECBFF\">&#39;https:\/\/raw.githubusercontent.com\/plotly\/datasets\/master\/gapminder_with_codes.csv&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\"># Create basic choropleth map<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> px.choropleth(data, <\/span><span style=\"color: #FFAB70\">locations<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;iso_alpha&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;gdpPercap&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">hover_name<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;country&#39;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">                    <\/span><span style=\"color: #FFAB70\">projection<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;natural earth&#39;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&#39;GDP per Capita by Country&#39;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>In this Python program, we utilize Plotly Express to create an interactive choropleth map visualizing GDP per Capita by country. The dataset used is sourced from Gapminder, providing a comprehensive view of economic indicators globally.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Import Libraries:<\/strong>\n<ul class=\"wp-block-list\">\n<li>We start by importing the necessary libraries, including <code>plotly.express<\/code> for easy and interactive visualizations.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Data Loading:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The program fetches data from a CSV file hosted on GitHub using <code>pd.read_csv<\/code>. The dataset includes information about countries, their ISO codes, and GDP per Capita.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Choropleth Map:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The choropleth map is created using <code>px.choropleth<\/code>.<\/li>\n\n\n\n<li>Key parameters include:\n<ul class=\"wp-block-list\">\n<li><code>locations<\/code>: ISO codes of countries.<\/li>\n\n\n\n<li><code>color<\/code>: GDP per Capita, determining the color intensity on the map.<\/li>\n\n\n\n<li><code>hover_name<\/code>: Country names appearing on hover.<\/li>\n\n\n\n<li><code>projection<\/code>: &#8216;natural earth&#8217; projection for a global view.<\/li>\n\n\n\n<li><code>title<\/code>: The title of the map.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Exploration:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The resulting choropleth map is interactive, enabling users to hover over countries to see GDP per Capita values.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Users can explore and compare GDP per Capita across different countries. Darker colors indicate higher GDP per Capita. This program demonstrates the simplicity and power of Plotly Express for creating data-driven visualizations. The choropleth map offers an intuitive way to understand global economic disparities. Feel free to customize the description based on additional details you&#8217;d like to highlight or any specific insights you&#8217;ve gained from the visualization.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-full\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot8.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"919\" height=\"360\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot8.png?resize=919%2C360&#038;ssl=1\" alt=\"\" class=\"wp-image-1186 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot8.png?w=919&amp;ssl=1 919w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot8.png?resize=300%2C118&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot8.png?resize=768%2C301&amp;ssl=1 768w\" data-sizes=\"(max-width: 919px) 100vw, 919px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 919px; --smush-placeholder-aspect-ratio: 919\/360;\" \/><\/a><\/figure>\n\n\n\n<h4 class=\"wp-block-heading\">Python Code -Example 2<\/h4>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:block;padding:16px 0 0 16px;margin-bottom:-1px;width:100%;text-align:left;background-color:#24292e\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"54\" height=\"14\" viewBox=\"0 0 54 14\"><g fill=\"none\" fill-rule=\"evenodd\" transform=\"translate(1 1)\"><circle cx=\"6\" cy=\"6\" r=\"6\" fill=\"#FF5F56\" stroke=\"#E0443E\" stroke-width=\".5\"><\/circle><circle cx=\"26\" cy=\"6\" r=\"6\" fill=\"#FFBD2E\" stroke=\"#DEA123\" stroke-width=\".5\"><\/circle><circle cx=\"46\" cy=\"6\" r=\"6\" fill=\"#27C93F\" stroke=\"#1AAB29\" stroke-width=\".5\"><\/circle><\/g><\/svg><\/span><span role=\"button\" tabindex=\"0\" data-code=\"import json\nimport numpy as np\nimport pandas as pd\nimport plotly.express as px\n\n#Uncomment below lines to render map on your browser\n#import plotly.io as pio\n#pio.renderers.default = 'browser'\n\nindia_states = json.load(open(&quot;states_india.geojson&quot;, &quot;r&quot;))\n\ndf = pd.read_csv(&quot;india_census.csv&quot;)\n\nstate_id_map = {}\nfor feature in india_states[&quot;features&quot;]:\n    feature[&quot;id&quot;] = feature[&quot;properties&quot;][&quot;state_code&quot;]\n    state_id_map[feature[&quot;properties&quot;][&quot;st_nm&quot;]] = feature[&quot;id&quot;]\n\ndf = pd.read_csv(&quot;india_census.csv&quot;)\ndf[&quot;Density&quot;] = df[&quot;Density[a]&quot;].apply(lambda x: int(x.split(&quot;\/&quot;)[0].replace(&quot;,&quot;, &quot;&quot;)))\ndf[&quot;id&quot;] = df[&quot;State or union territory&quot;].apply(lambda x: state_id_map[x])\n\n#print(df.head())\t    \nfig = px.choropleth(\n    df,\n    locations=&quot;id&quot;,\n    geojson=india_states,\n    color=&quot;Population&quot;,\n    hover_name=&quot;State or union territory&quot;,\n    hover_data=[&quot;Density&quot;, &quot;Sex ratio&quot;, &quot;Population&quot;],\n    title=&quot;India Population Statewise&quot;,\n)\nfig.update_geos(fitbounds=&quot;locations&quot;, visible=False)\nfig.show()\n\" style=\"color:#e1e4e8;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki github-dark\" style=\"background-color: #24292e\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> json<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> numpy <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> np<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> pandas <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> pd<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">import<\/span><span style=\"color: #E1E4E8\"> plotly.express <\/span><span style=\"color: #F97583\">as<\/span><span style=\"color: #E1E4E8\"> px<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#Uncomment below lines to render map on your browser<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#import plotly.io as pio<\/span><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#pio.renderers.default = &#39;browser&#39;<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">india_states <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> json.load(<\/span><span style=\"color: #79B8FF\">open<\/span><span style=\"color: #E1E4E8\">(<\/span><span style=\"color: #9ECBFF\">&quot;states_india.geojson&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&quot;r&quot;<\/span><span style=\"color: #E1E4E8\">))<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">df <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> pd.read_csv(<\/span><span style=\"color: #9ECBFF\">&quot;india_census.csv&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">state_id_map <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> {}<\/span><\/span>\n<span class=\"line\"><span style=\"color: #F97583\">for<\/span><span style=\"color: #E1E4E8\"> feature <\/span><span style=\"color: #F97583\">in<\/span><span style=\"color: #E1E4E8\"> india_states[<\/span><span style=\"color: #9ECBFF\">&quot;features&quot;<\/span><span style=\"color: #E1E4E8\">]:<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    feature[<\/span><span style=\"color: #9ECBFF\">&quot;id&quot;<\/span><span style=\"color: #E1E4E8\">] <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> feature[<\/span><span style=\"color: #9ECBFF\">&quot;properties&quot;<\/span><span style=\"color: #E1E4E8\">][<\/span><span style=\"color: #9ECBFF\">&quot;state_code&quot;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    state_id_map[feature[<\/span><span style=\"color: #9ECBFF\">&quot;properties&quot;<\/span><span style=\"color: #E1E4E8\">][<\/span><span style=\"color: #9ECBFF\">&quot;st_nm&quot;<\/span><span style=\"color: #E1E4E8\">]] <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> feature[<\/span><span style=\"color: #9ECBFF\">&quot;id&quot;<\/span><span style=\"color: #E1E4E8\">]<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">df <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> pd.read_csv(<\/span><span style=\"color: #9ECBFF\">&quot;india_census.csv&quot;<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">df[<\/span><span style=\"color: #9ECBFF\">&quot;Density&quot;<\/span><span style=\"color: #E1E4E8\">] <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> df[<\/span><span style=\"color: #9ECBFF\">&quot;Density[a]&quot;<\/span><span style=\"color: #E1E4E8\">].apply(<\/span><span style=\"color: #F97583\">lambda<\/span><span style=\"color: #E1E4E8\"> x: <\/span><span style=\"color: #79B8FF\">int<\/span><span style=\"color: #E1E4E8\">(x.split(<\/span><span style=\"color: #9ECBFF\">&quot;\/&quot;<\/span><span style=\"color: #E1E4E8\">)[<\/span><span style=\"color: #79B8FF\">0<\/span><span style=\"color: #E1E4E8\">].replace(<\/span><span style=\"color: #9ECBFF\">&quot;,&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&quot;&quot;<\/span><span style=\"color: #E1E4E8\">)))<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">df[<\/span><span style=\"color: #9ECBFF\">&quot;id&quot;<\/span><span style=\"color: #E1E4E8\">] <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> df[<\/span><span style=\"color: #9ECBFF\">&quot;State or union territory&quot;<\/span><span style=\"color: #E1E4E8\">].apply(<\/span><span style=\"color: #F97583\">lambda<\/span><span style=\"color: #E1E4E8\"> x: state_id_map[x])<\/span><\/span>\n<span class=\"line\"><\/span>\n<span class=\"line\"><span style=\"color: #6A737D\">#print(df.head())\t    <\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig <\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\"> px.choropleth(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    df,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #FFAB70\">locations<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;id&quot;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #FFAB70\">geojson<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">india_states,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #FFAB70\">color<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;Population&quot;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #FFAB70\">hover_name<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;State or union territory&quot;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #FFAB70\">hover_data<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #E1E4E8\">[<\/span><span style=\"color: #9ECBFF\">&quot;Density&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&quot;Sex ratio&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #9ECBFF\">&quot;Population&quot;<\/span><span style=\"color: #E1E4E8\">],<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">    <\/span><span style=\"color: #FFAB70\">title<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;India Population Statewise&quot;<\/span><span style=\"color: #E1E4E8\">,<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.update_geos(<\/span><span style=\"color: #FFAB70\">fitbounds<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #9ECBFF\">&quot;locations&quot;<\/span><span style=\"color: #E1E4E8\">, <\/span><span style=\"color: #FFAB70\">visible<\/span><span style=\"color: #F97583\">=<\/span><span style=\"color: #79B8FF\">False<\/span><span style=\"color: #E1E4E8\">)<\/span><\/span>\n<span class=\"line\"><span style=\"color: #E1E4E8\">fig.show()<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">CSV File<\/h4>\n\n\n\n<div class=\"wp-block-file\"><a id=\"wp-block-file--media-612765c8-77b1-4745-8f3b-2a7027298c72\" href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/india_census.csv\">india_census.csv<\/a><a href=\"https:\/\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/india_census.csv\" class=\"wp-block-file__button wp-element-button\" download aria-describedby=\"wp-block-file--media-612765c8-77b1-4745-8f3b-2a7027298c72\">Download<\/a><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">JSON File <\/h4>\n\n\n\n<p>You can obtain the JSON file used in this program by clicking on the button below.<\/p>\n\n\n\n<div class=\"wp-block-buttons is-layout-flex wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/t.ly\/QltWx\">Download JSON File<\/a><\/div>\n<\/div>\n\n\n\n<p>In this Python program, we leverage Plotly Express to create an insightful choropleth map that visualizes key demographic indicators across states and union territories in India. The data is sourced from India&#8217;s census, providing a comprehensive overview of population distribution, density, and sex ratio.<\/p>\n\n\n\n<p><strong>Program Overview:<\/strong><\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong>Import Libraries:<\/strong>\n<ul class=\"wp-block-list\">\n<li>We begin by importing necessary libraries, including <code>json<\/code> for handling GeoJSON data, <code>numpy<\/code> for numerical operations, <code>pandas<\/code> for data manipulation, and <code>plotly.express<\/code> for creating interactive visualizations.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Load GeoJSON and Census Data:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The GeoJSON file representing Indian states is loaded, and census data is read from a CSV file containing information about population, density, and sex ratio.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Data Preparation:<\/strong>\n<ul class=\"wp-block-list\">\n<li>We create a mapping between state names and their corresponding IDs for seamless integration with GeoJSON features.<\/li>\n\n\n\n<li>Additional data preprocessing includes converting density values to integers and creating a unique identifier (<code>id<\/code>) for each state.<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Choropleth Map:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The choropleth map is generated using <code>px.choropleth<\/code>. Key parameters include:\n<ul class=\"wp-block-list\">\n<li><code>locations<\/code>: State IDs for mapping.<\/li>\n\n\n\n<li><code>geojson<\/code>: GeoJSON data for Indian states.<\/li>\n\n\n\n<li><code>color<\/code>: Population, determining color intensity on the map.<\/li>\n\n\n\n<li><code>hover_name<\/code>: State names for hover information.<\/li>\n\n\n\n<li><code>hover_data<\/code>: Additional information displayed on hover, including density, sex ratio, and population.<\/li>\n\n\n\n<li><code>title<\/code>: Title of the map.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li><strong>Interactive Exploration:<\/strong>\n<ul class=\"wp-block-list\">\n<li>The resulting choropleth map is interactive, allowing users to hover over states to explore population demographics.<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n\n\n\n<p>Users can explore and compare population distribution, density, and sex ratio across different states and union territories in India. This program demonstrates the power of Plotly Express for creating meaningful and interactive visualizations. The choropleth map provides valuable insights into the demographic landscape of India.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><a href=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot9-1.png?ssl=1\"><img data-recalc-dims=\"1\" decoding=\"async\" width=\"1024\" height=\"465\" data-src=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot9-1.png?resize=1024%2C465&#038;ssl=1\" alt=\"\" class=\"wp-image-1191 lazyload\" data-srcset=\"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot9-1.png?resize=1024%2C465&amp;ssl=1 1024w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot9-1.png?resize=300%2C136&amp;ssl=1 300w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot9-1.png?resize=768%2C349&amp;ssl=1 768w, https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/newplot9-1.png?w=1350&amp;ssl=1 1350w\" data-sizes=\"(max-width: 1000px) 100vw, 1000px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/465;\" \/><\/a><\/figure>\n\n\n\n<p>If you are also looking for other Lab Manuals, head over to my following blog :<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-wp-embed is-provider-myblogosphere wp-block-embed-myblogosphere\"><div class=\"wp-block-embed__wrapper\">\n<blockquote class=\"wp-embedded-content\" data-secret=\"AG3xDDneGc\"><a href=\"https:\/\/moodle.sit.ac.in\/blog\/vtu-lab-manuals-using-foss\/\">VTU Lab Manuals using FOSS<\/a><\/blockquote><iframe class=\"wp-embedded-content lazyload\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;VTU Lab Manuals using FOSS&#8221; &#8212; MyBlogosphere\" data-src=\"https:\/\/moodle.sit.ac.in\/blog\/vtu-lab-manuals-using-foss\/embed\/#?secret=YS93t89zHd#?secret=AG3xDDneGc\" data-secret=\"AG3xDDneGc\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" data-load-mode=\"1\"><\/iframe>\n<\/div><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n","protected":false},"excerpt":{"rendered":"<p>In this blog post, you will find solutions for the Data Visualization with Python (BCS358D) course work for the III semester of VTU university. To follow along, you will need to set up a Python programming environment. We recommend using the Anaconda Python Distribution with Spyder as the integrated development environment (IDE). You can find [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1199,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","_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":[3],"tags":[149,118,140,134,136,78,135,26,142,152,35,141,77,147,146,143,138,139,40,150,144,137,151,148,81,145,43],"class_list":["post-1112","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-programming","tag-3rd-sem-cse","tag-3rd-semester","tag-bar-plot","tag-bcs358d","tag-bokeh","tag-cse","tag-data-visualization-with-python","tag-foss","tag-histogram","tag-jupyter-notebook","tag-lab-manual","tag-linear-plot","tag-matplotlib","tag-numpy","tag-pandas","tag-pie-chart","tag-plotly","tag-plotly-express","tag-python","tag-python-program","tag-scatter-plot","tag-seaborn","tag-second-year-vtu","tag-solution-manual","tag-spyder","tag-visualization","tag-vtu"],"aioseo_notices":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/moodle.sit.ac.in\/blog\/wp-content\/uploads\/2023\/10\/DataV.png?fit=1000%2C452&ssl=1","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/posts\/1112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/comments?post=1112"}],"version-history":[{"count":61,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/posts\/1112\/revisions"}],"predecessor-version":[{"id":2301,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/posts\/1112\/revisions\/2301"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/media\/1199"}],"wp:attachment":[{"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/media?parent=1112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/categories?post=1112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/moodle.sit.ac.in\/blog\/wp-json\/wp\/v2\/tags?post=1112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}