{"id":28803,"date":"2023-11-19T17:04:01","date_gmt":"2023-11-19T11:34:01","guid":{"rendered":"https:\/\/tocxten.com\/?page_id=28803"},"modified":"2023-11-19T17:04:59","modified_gmt":"2023-11-19T11:34:59","slug":"data-visualization-lab-programs","status":"publish","type":"page","link":"https:\/\/tocxten.com\/index.php\/data-visualization-lab-programs\/","title":{"rendered":"Data Visualization : Lab Programs"},"content":{"rendered":"\n<p class=\"has-medium-font-size\"><strong>1) A) Write a python program to find the best of two test average marks out of three test\u2019s marks accepted from the user<\/strong>.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Source Code <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code has-medium-font-size\"><code>mark1 = int(input(\"Enter the marks in the first test:\")) \nmark2 = int(input(\"Enter the marks in second test: \")) \nmark3 = int(input(\"Enter the marks in third test: \"))\n\nif (mark1 &gt; mark2):\n\tif (mark2 &gt; mark3): \n\t\ttotal_marks = mark1 + mark2\n\telse:\n\t\ttotal_marks = mark1 + mark3 \nelif (mark1 &gt; mark3):\n\ttotal_marks = mark1 + mark2 \nelse:\n\ttotal_marks = mark2 + mark3\n\nAverage_marks = total_marks \/ 2\nprint(\"The average of the best two test marks is:\", Average_marks)<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter the marks in the first test:18 \nEnter the marks in second test: 19 \nEnter the marks in third test: 24\nThe average of the best two test marks is: 21.5\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>1B) 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.<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Source Code<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>num = int(input(\"Enter a number: \")) \ntemp1 = num\nreverse = 0 \nwhile temp1 &gt; 0:\n    remainder = temp1 % 10\n    reverse = (reverse * 10) + remainder \n    temp1 = temp1 \/\/ 10\nif num == reverse:\n    print('The Entered Number %d is Palindrome'%(num)) \nelse:\n    print(\"The Entered Number %d is Not a Palindrome\"%(num)) \nprint(\"Digit\\t Frequency\")\nfor i in range(0,10): \n    count=0 \n    temp2=num\n    while temp2&gt;0:\n       digit=temp2%10 \n       if digit==i:\n          count=count+1 \n       temp2=temp2\/\/10\nif count&gt;0:\n    print(i,\"\\t\",count)\n\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Output:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter a number: 3663\nThe Entered Number 3663 is Palindrome Digit\tFrequency\n3\t2\n6\t2\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"> <strong>2) A) 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.<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Source Code <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Function for nth Fibonacci number \ndef Fibonacci(n):\n    if n == 1: \n        return 0\n    elif n==2: \n        return 1\n    else:\n        return Fibonacci(n-1) + Fibonacci(n-2)\n\ncount = 1\nN = int(input(\"Enter a value of N : \")) \nif N&lt;=0:\n    print(\"Invalid Input: Enter a value of N (&gt;0)\") \nelse:\n    print(\"Fibonacci sequence : \") \n    while count &lt;= N:\n        print(Fibonacci(count),end=' ') \n        count = count + 1<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter a value of N : 5\nFibonacci sequence : \n0 1 1 2 3 <\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>2B) Develop a python program to convert binary to decimal, octal to hexadecimal using functions.<\/strong><\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Source Code <\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>def binary_to_decimal(binary): \n    decimal = 0\n    power = 0\n    while binary != 0: \n        last_digit = binary % 10\n        decimal += last_digit * (2 ** power) \n        binary \/\/= 10\n        power += 1 \n    return decimal\n\ndef octal_to_hexadecimal(octal): \n    decimal = 0\n    power = 0 \n    while octal &gt; 0:\n        digit = octal % 10\n        decimal += digit * (8 ** power) \n        octal \/\/= 10\n        power += 1\n    conversion_table = {10: 'A', 11: 'B', 12: 'C', 13: 'D', 14: 'E', 15: 'F'}\n    hexadecimal = \"\" \n    while (decimal &gt; 0):\n        remainder = decimal % 16 \n        if remainder &gt;= 10:\n            hexadecimal = conversion_table&#91;remainder] + hexadecimal \n        else:\n            hexadecimal = str(remainder) + hexadecimal \n        decimal = decimal \/\/ 16\n    return hexadecimal\n\nbinary = int(input(\"Enter a binary number: \")) \ndecimal = binary_to_decimal(binary) \nprint(\"Decimal equivalent:\", decimal)\noctal = int(input(\"Enter an octal number: \")) \nhexadecimal = octal_to_hexadecimal(octal) \nprint(\"Hexadecimal equivalent:\", hexadecimal)<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter a binary number: 100\nDecimal equivalent: 4\nEnter an octal number: 7302\nHexadecimal equivalent: EC2<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>3A) Write a Python program that accepts a sentence and find the number of words, digits, uppercase letters and lowercase letters.<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sentence = input(\"Enter a sentence: \") \n(words, digits, upper, lower) = (0, 0, 0, 0) \nl_w = sentence.split()\nwords = len(l_w) \nfor ch in sentence: \n    if ch.isdigit():\n        digits = digits + 1 \n    elif ch.isupper():\n        upper = upper + 1 \n    elif ch.islower():\n        lower = lower + 1\nprint (\"No of Words: \", words) \nprint (\"No of Digits: \", digits)\nprint (\"No of Uppercase letters: \", upper) \nprint (\"No of Lowercase letters: \", lower)<\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Enter a sentence: TOCXTEN Mysuru 573118\nNo of Words:  3\nNo of Digits:  6\nNo of Uppercase letters:  8\nNo of Lowercase letters:  5<\/code><\/pre>\n\n\n\n<p>3<strong>B)<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>4<strong>A)<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>4 <strong>B)<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p><strong>5 A)<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>5<strong>B)<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>6<strong>A)<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>6 <strong>B)<\/strong><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>8 <strong>)<\/strong> <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>9 <strong>)<\/strong> <\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>10 <strong>)<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>7 <strong>)<\/strong><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>Source Code <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>Output<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><\/code><\/pre>\n\n\n\n<p>7 <strong>)<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>1) A) Write a python program to find the best of two test average marks out of three test\u2019s marks accepted from the user. Source Code Output: 1B) Develop a&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":"","_links_to":"","_links_to_target":""},"class_list":["post-28803","page","type-page","status-publish","hentry"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/28803","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/comments?post=28803"}],"version-history":[{"count":1,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/28803\/revisions"}],"predecessor-version":[{"id":28806,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/28803\/revisions\/28806"}],"wp:attachment":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/media?parent=28803"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}