{"id":28684,"date":"2023-11-17T22:16:48","date_gmt":"2023-11-17T16:46:48","guid":{"rendered":"https:\/\/tocxten.com\/?page_id=28684"},"modified":"2023-11-17T22:37:43","modified_gmt":"2023-11-17T17:07:43","slug":"sample-lab-programs","status":"publish","type":"page","link":"https:\/\/tocxten.com\/index.php\/sample-lab-programs\/","title":{"rendered":"Sample Lab Programs"},"content":{"rendered":"\n<p class=\"has-medium-font-size\"><strong>1. Write a Python program to calculate the sum, product, division, multiplication, and modular division of two numbers entered by the user.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Input the two numbers from the user\r\nnum1 = float(input(\"Enter the first number: \")) \nnum2 = float(input(\"Enter the second number: \")) \n# Calculate the sum of the two numbers \nsum_result = num1 + num2\r\n\r\n# Calculate the product of the two numbers \nproduct_result = num1 * num2\r\n\r\n# Calculate the division of the two numbers \ndivision_result = num1 \/ num2\r\n\r\n# Calculate the multiplication of the two numbers \nmultiplication_result = num1 * num2\r\n\r\n# Calculate the modulus (remainder) of the two numbers \nmodulus_result = num1 % num2\r\n\r\n# Print the results\nprint(\"Sum:\", sum_result)\r\nprint(\"Product:\", product_result) \nprint(\"Division:\", division_result) \nprint(\"Multiplication:\", multiplication_result) \nprint(\"Modulus:\", modulus_result)\r\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">2. <strong>Write a Python program to check if a given number is even or odd.\u00a0\u00a0\u00a0\u00a0<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>number = int(input(\"Enter a number: \")) \nif number % 2 == 0:\n    print(number, \"is even.\") \nelse:\n    print(number, \"is odd.\")\n\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\">3<strong>. Write a Python program to convert temperature in Celsius to Fahrenheit.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>celsius = float(input(\"Enter temperature in Celsius: \")) \nfahrenheit = (celsius * 9\/5) + 32\nprint(\"Temperature in Fahrenheit:\", fahrenheit)\n <\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>4. Write a Python program to calculate the factorial of a given number.<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>number = int(input(\"Enter a number: \")) \nfactorial = 1\r\nif number &lt; 0:\r\n    print(\"Factorial cannot be calculated for negative numbers.\") \nelif number == 0:\r\n    print(\"The factorial of 0 is 1.\") \nelse:\r\n    for i in range(1, number + 1): \n        factorial *= i\r\nprint(\"The factorial of\", number, \"is\", factorial)\n\r\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>5.\u00a0 Write a Python program to find the area of a triangle given its base and height. <\/strong>\u00a0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>base = float(input(\"Enter the base of the triangle: \")) \nheight = float(input(\"Enter the height of the triangle: \")) \narea = (base * height) \/ 2\r\nprint(\"The area of the triangle is:\", area)\r\n\n<\/code><\/pre>\n\n\n\n<p class=\"has-medium-font-size\"><strong>\u00a0<\/strong>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n\n\n\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Write a Python program to calculate the sum, product, division, multiplication, and modular division of two numbers entered by the user. 2. Write a Python program to check if&#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-28684","page","type-page","status-publish","hentry"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/28684","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=28684"}],"version-history":[{"count":12,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/28684\/revisions"}],"predecessor-version":[{"id":28705,"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/pages\/28684\/revisions\/28705"}],"wp:attachment":[{"href":"https:\/\/tocxten.com\/index.php\/wp-json\/wp\/v2\/media?parent=28684"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}