{"id":3945,"date":"2023-08-05T08:24:33","date_gmt":"2023-08-05T08:24:33","guid":{"rendered":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/?post_type=blog&#038;p=3945"},"modified":"2023-10-01T06:42:52","modified_gmt":"2023-10-01T06:42:52","slug":"basic-python-program-for-beginners","status":"publish","type":"blog","link":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/blog\/basic-python-program-for-beginners\/","title":{"rendered":"BASIC PYTHON PROGRAM FOR BEGINNERS"},"content":{"rendered":"\n<h3>Introduction<\/h3>\n<p>\n\tTo begin with, Python is the most in-demand programming language which is easiest to learn for beginners. This basic python program article is framed to help beginners to understand the basic concepts of python with programs and solutions. <a style=\"color: #e10707;\" href=\"https:\/\/www.credosystemz.com\/training-in-chennai\/best-python-training-in-chennai\/\" target=\"_blank\" rel=\"noopener\">Python certification course<\/a> in Chennai at Credo Systemz is a practical oriented training course which starts from the basic with the help of professional expert trainers.\n<\/p>\n\n<h3>Basic python programs<\/h3>\n<ul class=\"list\">\n<li>Python program to perform basic arithmetic operations<\/li>\t\n<li>\tPython program to find the factorial of a given number<\/li>\t\n<li>Python program to find the simple and compound interest<\/li>\t\n<li>\tPython program to check whether the given number is prime or composite<\/li>\t\n<li>\tPython program to find the biggest of three numbers<\/li>\t\n<li>\tPython Program to display the multiplication Table<\/li>\t\n<li>\tPython Program to Check Armstrong Number<\/li>\t\n<li>\tPython Program to Check Whether the given String is Palindrome or Not<\/li>\t\n<\/ul>\n\n\n<h3>Python program to perform basic arithmetic operations<\/h3>\n\n<h3>Basic Arithmetic operations<\/h3>\n<ul class=\"list\">\n<li> Addition<\/li>\t\n<li> Subtraction<\/li>\t\n<li> Multiplication<\/li>\t\n<li> Division<\/li>\t\n<\/ul>\n<strong>Program<\/strong>\n<pre>\n<code>\n#Getting input from user\nnumber1 = input(\"Enter the First number: \")\nnumber2 = input(\"Enter the Second number: \")\n # Addition\nsum = number1 + number2\n # To display the sum\nprint(\"Addition:\" ,sum)\n# Subtraction\nsub = number1 -number2\n# To display the subtraction\nprint(\"Subtraction:\" ,sub)\n# Multiplication\nmultiply = number1 *number2\n# To display the multiplication\nprint(\"Multiplication:\" ,multiply)\n# Division\ndivide = number1 + number2\n# To display the sum\nprint(\"Division:\" ,divide)\n<\/code><\/pre>\n\n<strong>Output<\/strong>\n<p>\n\t\nEnter the First number: 4<br><br>\nEnter the Second number: 2<br><br>\nAddition: 6<br><br>\nSubtraction: 2<br><br>\nMultiplication: 8<br><br>\nDivision: 2\n<\/p>\n<h3>Python program to find the factorial of a given number<\/h3>\nA factorial of a given number calculated by findingthe product of all the numbers from 1 to the user specified number.\n<h3 class=\"left-border\">Using traditional iterationmethod<\/h3>\n<pre>\n<code>\n# factorial of given number\ndef factorial(num):\n    ifnum< 0:\n        return 0\n    elifnum == 0 or num == 1:\n        return 1\n    else:\n        fact = 1\n        while(num> 1):\n            fact= fact * num\n            num=num - 1\n        return fact\n#Getting input from user\nnum = input(\"Enter the Given number: \")\nprint(\"Factorial:\",factorial(num))\n<\/code>\n<\/pre>\n\t\t\t<strong>Output<\/strong>\n\t\t\tEnter the Given number: 3<br><br>\nFactorial: 6\n\t\t\t<h3 class=\"left-border\">Using in-built function<\/h3>\n\n<pre>\n<code>\nimport math\n#Getting input from user\nnum = input(\"Enter the Given number: \")\n#in-built function\nfact=math.factorial(num)\nprint(\"Factorial of given number:\",fact)\n <\/code><\/pre>\n\t\t\t<strong>Output<\/strong>\nEnter the Given number: 4<br><br>\nFactorial of given number: 24\n\n\t<h3>Python program to find the simple and compound interest<\/h3>\n<pre><code>\nP = principle amount\nT = time period\nR = rate of interest\nA =amount \nT =time span\nSimple interest formula: \n(P x T x R)\/100\nCompound interest formula: \nA = P(1 + R\/100) t \nCompound Interest = A \u2013 P \n#Getting input from user\np = input(\"Enter the Principle amount: \")\nt = input(\"Enter the time period: \")\nr = input(\"Enter the rate of interest: \")\n#to calculate simple interest\nSI = (p * t * r)\/100\nprint('Simple Interest:', SI)\n#to calculate compound interest\nAmount = p * (pow((1 + r\/ 100), t))\nCI = Amount - principle\nprint(\"Compound Interest:\", CI)\n<\/code><\/pre>\n\t\t\t<strong>Output<\/strong>\n\t\tEnter the Principle amount: 5000<br><br>\nEnter the time period: 2<br><br>\nEnter the rate of interest: 5<br><br>\nSimple Interest: 500<br><br>\nCompound Interest: 5500\n<h3 class=\"left-border\">Python program to check whether the given number is prime or composite<\/h3>\n\nThe prime number is a whole number with two integral divisors i.e., divisible by 1 and itself. The composite number is a whole number with more than two integral divisors.\n<pre><code>\n#Getting input from user\nnum = int(input(\"Enter a number : \"))\n#to check prime or composite\nifnum == 0 or 1:\nprint(num, \"is a neither prime NOR composite number\")\nelifnum> 1:\nfori in range(2, num):\nif (num % i) == 0:\nprint(num, \"is NOT a prime number\")\nbreak\nelse:\nprint(num, \"is a PRIME number\")\nelse:\nprint(num, \"is a COMPOSITE number\")\n<\/code><\/pre>\n\t\t\t<strong>Output<\/strong>\nEnter a number: 3<br><br>\n3 is a PRIME number\n<h3 class=\"left-border\">Python program to find the biggest of three numbers<\/h3>\n<pre><code>\n# Getting input from user\nnum1 = int(input(\"Enter first number: \"))\nnum2 = int(input(\"Enter second number: \"))\nnum3 = int(input(\"Enter third number: \"))\n#to find the biggest number\nif (num1 >= num2) and (num1 >= num3):\nbig = num1\nelif (num2 >= num1) and (num2 >= num3):\nbig = num2\nelse:\nbig = num3\nprint(\"The largest of three numbers is\",big)\n<\/code><\/pre>\n\t\t\t<strong>Output<\/strong>\n\t\t\t\t\t\t\t\nEnter first number: 12<br><br>\nEnter second number: 17<br><br>\nEnter third number: 25<br><br>\nThe largest number is 25\n\n<h3>Python Program to Display the multiplication Table<\/h3>\nTo displays the multiplication table of variable num (from 1 to 10).\n<pre><code>\n# To take input from the user\nnumber = int(input(\"Enter the number for multiplication table : \"))\n# Iterate 10 times from i = 1 to 10\nfori in range(1, 11):\nprint(number, 'x', i, '=', number*i)\n<\/code><\/pre>\n\t\t\t<strong>Output<\/strong>\n\t\t\t\tEnter the number for multiplication table: 2<br><br>\n2 x 1 = 2<br><br>\n2 x 2 = 24<br><br>\n2 x 3 = 36<br><br>\n2 x 4 = 48<br><br>\n2 x 5 = 60<br><br>\n2 x 6 = 72<br><br>\n2 x 7 = 84<br><br>\n2 x 8 = 96<br><br>\n2 x 9 = 108<br><br>\n2 x 10 = 120\n\t\t\n<h3>Python Program to Check Armstrong Number<\/h3>\nArmstrong number is a number equal to the sum of the cubes of its own digits. For example, 370 is an Armstrong number since 153 = 1*1*1 + 5*5*5 + 3*3*3.\n<pre>\n<code>\n# Getinput from the user\nnum = int(input(\"Enter a number: \"))\nsum = 0\n# Tofind the sum of the cube of each digit\ntem = num\nwhile tem> 0:\ndigit = tem % 10\nsum += digit ** 3\ntem \/\/= 10\nifnum == sum:\nprint(num,\"is an Armstrong number\")\nelse:\nprint(num,\"is not an Armstrong number\")\n<\/code><\/pre>\n\t\t\t<strong>Output<\/strong> \n\t\t\t<p>\nEnter a number: 370<br><br>\n370 is an Armstrong number<br><br>\n\t\t\t\t\t\t<\/p>\n\t\t\t\t\t\t\n<h3>Python Program to Check Whether a Given String is Palindrome or Not<\/h3>\n________________________________________A palindrome is a string that is the same when read forward and backward as well.\nFor example: mom, madam,pop,radar\n<pre>\n<code>\n# Getting input from user\nstring=input((\"Enter a string:\"))\nif(string==string[::-1]):\n      print(\"The string is a palindrome\")\nelse:\n      print(\"Not a palindrome\")\n\t\t\t<\/code><\/pre>\n<strong>Output<\/strong><br><br>\nThe string is a palindrome.\n<h3>Conclusion<\/h3>\n\t\t\t<p>\nThese basic python programs helps to understand about how to write simple python programs, data types, operations and to learn, explore more.\n\t\t\t<\/p>\n<h3>Related Article<\/h3>\n<ul>\n<li><a href=\"https:\/\/www.credosystemz.com\/what-is-python-programming\/\"> What is Python Programming?<\/a><\/li>\n<li><a href=\"https:\/\/www.credosystemz.com\/main-differences-python-2-vs-python-3\/\">Python 2 Vs Python 3<\/a><\/li>\n<li><a href=\"https:\/\/www.credosystemz.com\/why-learn-python\/\">Why Learn Python Programming?<\/a><\/li>\n<\/ul>\n","protected":false},"featured_media":7838,"template":"","tags":[],"class_list":["post-3945","blog","type-blog","status-publish","has-post-thumbnail","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>IT Training Institute in chennai | Best Placement Training Institute<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:site_name\" content=\"IT Training Institute in chennai | Best Placement Training Institute\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"CollectionPage\",\"@id\":null,\"url\":\"\",\"name\":\"\",\"isPartOf\":{\"@id\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#website\"},\"breadcrumb\":{\"@id\":\"#breadcrumb\"},\"inLanguage\":\"en-US\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"#breadcrumb\",\"itemListElement\":[]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#website\",\"url\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/\",\"name\":\"IT Training Institute in chennai | Best Placement Training Institute\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#organization\",\"name\":\"IT Training Institute in chennai | Best Placement Training Institute\",\"url\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-content\/uploads\/2023\/01\/logo.png\",\"contentUrl\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-content\/uploads\/2023\/01\/logo.png\",\"width\":323,\"height\":50,\"caption\":\"IT Training Institute in chennai | Best Placement Training Institute\"},\"image\":{\"@id\":\"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#\/schema\/logo\/image\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"IT Training Institute in chennai | Best Placement Training Institute","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"og_locale":"en_US","og_type":"article","og_site_name":"IT Training Institute in chennai | Best Placement Training Institute","twitter_card":"summary_large_image","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"CollectionPage","@id":null,"url":"","name":"","isPartOf":{"@id":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#website"},"breadcrumb":{"@id":"#breadcrumb"},"inLanguage":"en-US"},{"@type":"BreadcrumbList","@id":"#breadcrumb","itemListElement":[]},{"@type":"WebSite","@id":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#website","url":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/","name":"IT Training Institute in chennai | Best Placement Training Institute","description":"","publisher":{"@id":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#organization","name":"IT Training Institute in chennai | Best Placement Training Institute","url":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-content\/uploads\/2023\/01\/logo.png","contentUrl":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-content\/uploads\/2023\/01\/logo.png","width":323,"height":50,"caption":"IT Training Institute in chennai | Best Placement Training Institute"},"image":{"@id":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-json\/wp\/v2\/blog\/3945","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-json\/wp\/v2\/blog"}],"about":[{"href":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-json\/wp\/v2\/types\/blog"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-json\/wp\/v2\/media\/7838"}],"wp:attachment":[{"href":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-json\/wp\/v2\/media?parent=3945"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webinfy.in\/demo\/credosystemz.com\/wp-json\/wp\/v2\/tags?post=3945"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}