{"id":16679,"date":"2023-06-05T09:29:02","date_gmt":"2023-06-05T09:29:02","guid":{"rendered":"https:\/\/www.prepbytes.com\/blog\/?p=16679"},"modified":"2023-07-04T09:49:17","modified_gmt":"2023-07-04T09:49:17","slug":"python-program-to-find-the-sum-of-digits-of-the-number","status":"publish","type":"post","link":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/","title":{"rendered":"Python Program To Find The Sum Of Digits Of The Number"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg\" alt=\"\" \/><\/p>\n<p>The sum of digits of a number refers to the total value obtained by adding up each individual digit in the number. For example, the sum of digits in the number 123 would be 1 + 2 + 3 = 6.<\/p>\n<p>In Python, there are several methods to calculate the sum of digits of a number. One common approach is to convert the number into a string and then iterate through each character (digit) in the string. By converting each digit back to an integer, you can accumulate their values to obtain the final sum.<br \/>\nFor example ,if we have number 456 then sum of digits should be 15. <\/p>\n<h2>Ways to find the sum of digits of the number<\/h2>\n<p>We have different methods to find the sum of the digits of the number.<\/p>\n<h3>Method 1 &#8211; Using Recursion<\/h3>\n<p>Recursion is the process of defining a problem or an issue&#8217;s solution in terms of a more basic form of the original problem. The recursive function is the name of the related function. Recursion usage does away with the need for loops in programming.<\/p>\n<p><strong>The algorithm is as follows:<\/strong><br \/>\nStep 1: Create a function that computes the sum of digits using the parameter n.<br \/>\nStep 2: Check to see whether n is less than 10 and then return n.<br \/>\nStep 3: To determine the residual (n percent 10) if not, divide the number by 10.<br \/>\nStep 4: Recursively invoke the function with the argument (n\/10).<br \/>\nStep 5: combine the remaining value with the function&#8217;s output.<br \/>\nStep 6: Gather user input.<br \/>\nStep 7: Call the sum of digits function to determine a number&#8217;s total digits, giving an input argument.<\/p>\n<h3>Implementation<\/h3>\n<pre><code>def sumDigits(no):\n    return 0 if no == 0 else int(no % 10) + sumDigits(int(no \/ 10)) \n\nn = 569\nprint(sumDigits(n))<\/code><\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre><code>20<\/code><\/pre>\n<h3>Method 2 &#8211; using Sum() method<\/h3>\n<p>Python&#8217;s sum() function is used to calculate a number&#8217;s digit sum in a list.<\/p>\n<p>Use the str() function to convert the number to a string, then the strip() and map() methods to turn the string into a list of integers. After that, use the sum() function to calculate the total.<\/p>\n<p><strong>The Algorithm steps are as follows:<\/strong><br \/>\nStep 1:Create a function that computes the sum of digits using the parameter n.<br \/>\nStep 2: Using the str() function, the integer is transformed into a string.<br \/>\nStep 3: Next, using the map() and strip() methods, the text is transformed into a list of the specified number&#8217;s digits.<br \/>\nStep 4: To determine the entire sum of digits, the sum() technique is used.<\/p>\n<p><strong>Implementation<\/strong><br \/>\ndef getSum(n):<\/p>\n<pre><code>    strr = str(n)\n    list_of_number = list(map(int, strr.strip()))\n    return sum(list_of_number)\n\nn = 569\nprint(getSum(n))<\/code><\/pre>\n<p><strong>Output<\/strong><\/p>\n<pre><code>20<\/code><\/pre>\n<h3>Method 3 &#8211; Using Iteration<\/h3>\n<p>To compute a number&#8217;s digit sum, loops will be used. Loops are used to run a certain piece of code repeatedly. For loop, while, and do-while are a few examples of looping statements.<\/p>\n<p>An integer&#8217;s rightmost digit can be discovered by dividing it by 10 until it equals 0. The last digit will be the one on the right. To get the reminder, use the remaining operator &quot;percent&quot;. To retrieve a number&#8217;s whole digit count, multiply the computed quotient by 10. We use &quot;\/\/&quot; to determine the number&#8217;s quotient.<\/p>\n<p><strong>The Algorithm steps are as follows:<\/strong><br \/>\nStep 1: Create a function that uses the argument n to find the sum as the first step.<br \/>\nStep 2: Declare a variable sum to hold the digit sum in step two.<br \/>\nStep 3: Construct a loop that will continue to execute until n is larger than 0.<br \/>\nStep 4: Add the sum variable (n percent 10) to the remaining value returned by.<br \/>\nStep 5: Change n to n\/10.<br \/>\nStep 6: Call the function that was previously defined, passing the input as a parameter.<br \/>\nStep 7: Print the function&#8217;s return values&#8217; total value.<\/p>\n<h4>Implementation<\/h4>\n\t\t\t\t\t\t<style>\r\n\t\t\t\t\r\n\t\t\t\t\t#tab_container_16674 {\r\n\toverflow:hidden;\r\n\tdisplay:block;\r\n\twidth:100%;\r\n\tborder:0px solid #ddd;\r\n\tmargin-bottom:30px;\r\n\t}\r\n\r\n#tab_container_16674 .tab-content{\r\n\tpadding:20px;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n\tmargin-top: 0px;\r\n\tbackground-color:#ffffff !important;\r\n\tcolor: #000000 !important;\r\n\tfont-size:16px !important;\r\n\tfont-family: Open Sans !important;\r\n\t\r\n\t\tborder: 1px solid #e6e6e6 !important;\r\n\t}\r\n#tab_container_16674 .wpsm_nav-tabs {\r\n    border-bottom: 0px solid #ddd;\r\n}\r\n#tab_container_16674 .wpsm_nav-tabs > li.active > a, #tab_container_16674 .wpsm_nav-tabs > li.active > a:hover, #tab_container_16674 .wpsm_nav-tabs > li.active > a:focus {\r\n\tcolor: #000000 !important;\r\n\tcursor: default;\r\n\tbackground-color: #ffffff !important;\r\n\tborder: 1px solid #e6e6e6 !important;\r\n}\r\n\r\n#tab_container_16674 .wpsm_nav-tabs > li > a {\r\n    margin-right: 0px !important; \r\n    line-height: 1.42857143 !important;\r\n    border: 1px solid #d5d5d5 !important;\r\n    border-radius: 0px 0px 0 0 !important; \r\n\tbackground-color: #e8e8e8 !important;\r\n\tcolor: #000000 !important;\r\n\tpadding: 15px 18px 15px 18px !important;\r\n\ttext-decoration: none !important;\r\n\tfont-size: 14px !important;\r\n\ttext-align:center !important;\r\n\tfont-family: Open Sans !important;\r\n}\r\n#tab_container_16674 .wpsm_nav-tabs > li > a:focus {\r\noutline: 0px !important;\r\n}\r\n\r\n#tab_container_16674 .wpsm_nav-tabs > li > a:before {\r\n\tdisplay:none !important;\r\n}\r\n#tab_container_16674 .wpsm_nav-tabs > li > a:after {\r\n\tdisplay:none !important ;\r\n}\r\n#tab_container_16674 .wpsm_nav-tabs > li{\r\npadding:0px !important ;\r\nmargin:0px;\r\n}\r\n\r\n#tab_container_16674 .wpsm_nav-tabs > li > a:hover , #tab_container_16674 .wpsm_nav-tabs > li > a:focus {\r\n    color: #000000 !important;\r\n    background-color: #e8e8e8 !important;\r\n\tborder: 1px solid #d5d5d5 !important;\r\n\t\r\n}\r\n#tab_container_16674 .wpsm_nav-tabs > li > a .fa{\r\n\r\nmargin-right:5px !important;\r\n\r\nmargin-left:5px !important;\r\n\r\n\r\n}\r\n\r\n\t\t#tab_container_16674 .wpsm_nav-tabs a{\r\n\t\t\tbackground-image: none;\r\n\t\t\tbackground-position: 0 0;\r\n\t\t\tbackground-repeat: repeat-x;\r\n\t\t}\r\n\t\t\t\r\n\r\n\r\n#tab_container_16674 .wpsm_nav-tabs > li {\r\n    float: left;\r\n    margin-bottom: -1px !important;\r\n\tmargin-right:0px !important; \r\n}\r\n\r\n\r\n#tab_container_16674 .tab-content{\r\noverflow:hidden !important;\r\n}\r\n\r\n\r\n@media (min-width: 769px) {\r\n\r\n\t#tab_container_16674 .wpsm_nav-tabs > li{\r\n\t\tfloat:left !important ;\r\n\t\t\t\tmargin-right:-1px !important;\r\n\t\t\t\t\t}\r\n\t#tab_container_16674 .wpsm_nav-tabs{\r\n\t\tfloat:none !important;\r\n\t\tmargin:0px !important;\r\n\t}\r\n\r\n\t#tab_container_16674 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16674 .wpsm_nav{\r\n\t\t\t}\r\n\r\n}\r\n\r\n\r\n\r\n@media (max-width: 768px) {\r\n\t#tab_container_16674 .wpsm_nav-tabs > li {\r\n\t\t\t\t\r\n\t}\r\n\t#tab_container_16674 .wpsm_nav{\r\n\t\t\t}\r\n}\r\n\r\n\r\n\t.wpsm_nav-tabs li:before{\r\n\t\tdisplay:none !important;\r\n\t}\r\n\r\n\t@media (max-width: 768px) {\r\n\t\t\t\t\r\n\t\t\t\t.wpsm_nav-tabs{\r\n\t\t\tmargin-left:0px !important;\r\n\t\t\tmargin-right:0px !important; \r\n\t\t\t\r\n\t\t}\r\n\t\t\t\t#tab_container_16674 .wpsm_nav-tabs > li{\r\n\t\t\tfloat:none !important;\r\n\t\t}\r\n\t\t\t\r\n\t}\t\t\t\t<\/style>\r\n\t\t\t\t<div id=\"tab_container_16674\" >\r\n\t \r\n\t\t\t\t\t<ul class=\"wpsm_nav wpsm_nav-tabs\" role=\"tablist\" id=\"myTab_16674\">\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t<li role=\"presentation\"  class=\"active\"  onclick=\"do_resize()\">\r\n\t\t\t\t\t\t\t\t<a href=\"#tabs_desc_16674_1\" aria-controls=\"tabs_desc_16674_1\" role=\"tab\" data-toggle=\"tab\">\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<i class=\"fa fa-code\"><\/i> \t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t<span>Python<\/span>\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t\t\r\n\t\t\t\t\t\t\t\t<\/a>\r\n\t\t\t\t\t\t\t<\/li>\r\n\t\t\t\t\t\t\t\t\t\t\t <\/ul>\r\n\r\n\t\t\t\t\t  <!-- Tab panes -->\r\n\t\t\t\t\t  <div class=\"tab-content\" id=\"tab-content_16674\">\r\n\t\t\t\t\t\t\t\t\t\t\t\t <div role=\"tabpanel\" class=\"tab-pane  in active \" id=\"tabs_desc_16674_1\">\r\n\t\t\t\t\t\t\t\t<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\">def getSum(n):\r\n    \r\n    sum = 0\r\n    while (n != 0):\r\n       \r\n        sum = sum + (n % 10)\r\n        n = n\/\/10\r\n       \r\n    return sum\r\n   \r\nn = 569\r\nprint(getSum(n))<\/pre>\r\n&nbsp;\t\t\t\t\t\t <\/div>\r\n\t\t\t\t\t\t\t\r\n\t\t\t\t\t <\/div>\r\n\t\t\t\t\t \r\n\t\t\t\t <\/div>\r\n <script>\r\n\t\tjQuery(function () {\r\n\t\t\tjQuery('#myTab_16674 a:first').tab('show')\r\n\t\t});\r\n\t\t\r\n\t\t\t\tjQuery(function(){\r\n\t\t\tvar b=\"fadeIn\";\r\n\t\t\tvar c;\r\n\t\t\tvar a;\r\n\t\t\td(jQuery(\"#myTab_16674 a\"),jQuery(\"#tab-content_16674\"));function d(e,f,g){\r\n\t\t\t\te.click(function(i){\r\n\t\t\t\t\ti.preventDefault();\r\n\t\t\t\t\tjQuery(this).tab(\"show\");\r\n\t\t\t\t\tvar h=jQuery(this).data(\"easein\");\r\n\t\t\t\t\tif(c){c.removeClass(a);}\r\n\t\t\t\t\tif(h){f.find(\"div.active\").addClass(\"animated \"+h);a=h;}\r\n\t\t\t\t\telse{if(g){f.find(\"div.active\").addClass(\"animated \"+g);a=g;}else{f.find(\"div.active\").addClass(\"animated \"+b);a=b;}}c=f.find(\"div.active\");\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t});\r\n\t\t\r\n\r\n\t\tfunction do_resize(){\r\n\r\n\t\t\tvar width=jQuery( '.tab-content .tab-pane iframe' ).width();\r\n\t\t\tvar height=jQuery( '.tab-content .tab-pane iframe' ).height();\r\n\r\n\t\t\tvar toggleSize = true;\r\n\t\t\tjQuery('iframe').animate({\r\n\t\t\t    width: toggleSize ? width : 640,\r\n\t\t\t    height: toggleSize ? height : 360\r\n\t\t\t  }, 250);\r\n\r\n\t\t\t  toggleSize = !toggleSize;\r\n\t\t}\r\n\r\n\r\n\t<\/script>\r\n\t\t\t\t\r\n\t\t\t\n<p><strong>Output<\/strong><\/p>\n<pre><code>20<\/code><\/pre>\n<p><strong>Conclusion<\/strong><br \/>\nIn conclusion, finding the sum of the digits of a number is a common task in programming. Python provides various methods to solve this problem, including converting the number to a string and iterating through each digit, using mathematical operations like modulo and integer division to extract digits, or employing recursion to break down the number into smaller parts.<\/p>\n<p>The choice of method depends on the specific requirements of the problem and personal preference. These methods allow you to efficiently compute the sum of digits and can be applied to various scenarios where digit manipulation is required.<\/p>\n<p>By understanding these techniques, you can effectively find the sum of digits in a number and utilize this knowledge in your Python programming endeavours.<\/p>\n<h2>Frequently Asked Questions<\/h2>\n<p><strong>Q1. Can I find the sum of digits without converting the number to a string?<\/strong><br \/>\nYes, you can find the sum of digits without converting the number to a string. One way is to repeatedly divide the number by 10, extract the remainder (which represents the rightmost digit), and accumulate the sum. This process can be repeated until the number becomes zero. <\/p>\n<p><strong>Q2. How can I handle negative numbers when finding the sum of digits?<\/strong><br \/>\nWhen dealing with negative numbers, you can either consider the absolute value (magnitude) of the number and find the sum of digits as usual, or you can include the negative sign as part of the sum. If you choose to include the negative sign, you can extract it separately and treat it as a digit to be included in the sum. <\/p>\n<p><strong>Q3. Can I find the sum of the digits of a floating-point number?<\/strong><br \/>\nThe sum of digits concept is typically applied to integer numbers rather than floating-point numbers. However, if you wish to find the sum of digits in the integer part of a floating-point number, you can extract the integer part using the floor division (\/\/) operator or the int() function. Once you have the integer part, you can apply the methods mentioned earlier to find the sum of its digits.<\/p>\n<p><strong>Q4.Is there a limit to the size of the number for finding the sum of digits?<\/strong><br \/>\nThe methods discussed for finding the sum of digits in Python can be applied to numbers of any size. However, keep in mind that as the size of the number increases, the computational resources and time required may also increase. Extremely large numbers may pose challenges due to memory limitations or processing time. Therefore, it is important to consider the efficiency of your chosen method when dealing with large numbers.<\/p>\n<p><strong>Q5. Can I find the sum of digits for numbers in bases other than decimal (base 10)?<\/strong><br \/>\nYes, the concept of finding the sum of digits can be applied to numbers in bases other than decimal. The process remains similar, but the base of the number determines the range of digits (0 to base-1).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The sum of digits of a number refers to the total value obtained by adding up each individual digit in the number. For example, the sum of digits in the number 123 would be 1 + 2 + 3 = 6. In Python, there are several methods to calculate the sum of digits of a [&hellip;]<\/p>\n","protected":false},"author":52,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[154],"tags":[],"class_list":["post-16679","post","type-post","status-publish","format-standard","hentry","category-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.8 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python Program To Find The Sum Of Digits Of The Number<\/title>\n<meta name=\"description\" content=\"Python Program To Find The Sum Of Digits Of The Number refers to the total value obtained by adding up each individual digit in the number.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Program To Find The Sum Of Digits Of The Number\" \/>\n<meta property=\"og:description\" content=\"Python Program To Find The Sum Of Digits Of The Number refers to the total value obtained by adding up each individual digit in the number.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/\" \/>\n<meta property=\"og:site_name\" content=\"PrepBytes Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/prepbytes0211\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-06-05T09:29:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-07-04T09:49:17+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg\" \/>\n<meta name=\"author\" content=\"Prepbytes\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Prepbytes\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/\"},\"author\":{\"name\":\"Prepbytes\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\"},\"headline\":\"Python Program To Find The Sum Of Digits Of The Number\",\"datePublished\":\"2023-06-05T09:29:02+00:00\",\"dateModified\":\"2023-07-04T09:49:17+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/\"},\"wordCount\":1072,\"commentCount\":0,\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg\",\"articleSection\":[\"Python\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/\",\"url\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/\",\"name\":\"Python Program To Find The Sum Of Digits Of The Number\",\"isPartOf\":{\"@id\":\"http:\/\/43.205.93.38\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg\",\"datePublished\":\"2023-06-05T09:29:02+00:00\",\"dateModified\":\"2023-07-04T09:49:17+00:00\",\"description\":\"Python Program To Find The Sum Of Digits Of The Number refers to the total value obtained by adding up each individual digit in the number.\",\"breadcrumb\":{\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage\",\"url\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg\",\"contentUrl\":\"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"http:\/\/43.205.93.38\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\",\"item\":\"https:\/\/prepbytes.com\/blog\/category\/python\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Python Program To Find The Sum Of Digits Of The Number\"}]},{\"@type\":\"WebSite\",\"@id\":\"http:\/\/43.205.93.38\/#website\",\"url\":\"http:\/\/43.205.93.38\/\",\"name\":\"PrepBytes Blog\",\"description\":\"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING\",\"publisher\":{\"@id\":\"http:\/\/43.205.93.38\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"http:\/\/43.205.93.38\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"http:\/\/43.205.93.38\/#organization\",\"name\":\"Prepbytes\",\"url\":\"http:\/\/43.205.93.38\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"contentUrl\":\"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp\",\"width\":160,\"height\":160,\"caption\":\"Prepbytes\"},\"image\":{\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/prepbytes0211\/\",\"https:\/\/www.instagram.com\/prepbytes\/\",\"https:\/\/www.linkedin.com\/company\/prepbytes\/\",\"https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA\"]},{\"@type\":\"Person\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e\",\"name\":\"Prepbytes\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"http:\/\/43.205.93.38\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g\",\"caption\":\"Prepbytes\"},\"url\":\"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Program To Find The Sum Of Digits Of The Number","description":"Python Program To Find The Sum Of Digits Of The Number refers to the total value obtained by adding up each individual digit in the number.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/","og_locale":"en_US","og_type":"article","og_title":"Python Program To Find The Sum Of Digits Of The Number","og_description":"Python Program To Find The Sum Of Digits Of The Number refers to the total value obtained by adding up each individual digit in the number.","og_url":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/","og_site_name":"PrepBytes Blog","article_publisher":"https:\/\/www.facebook.com\/prepbytes0211\/","article_published_time":"2023-06-05T09:29:02+00:00","article_modified_time":"2023-07-04T09:49:17+00:00","og_image":[{"url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg","type":"","width":"","height":""}],"author":"Prepbytes","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Prepbytes","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#article","isPartOf":{"@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/"},"author":{"name":"Prepbytes","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e"},"headline":"Python Program To Find The Sum Of Digits Of The Number","datePublished":"2023-06-05T09:29:02+00:00","dateModified":"2023-07-04T09:49:17+00:00","mainEntityOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/"},"wordCount":1072,"commentCount":0,"publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg","articleSection":["Python"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/","url":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/","name":"Python Program To Find The Sum Of Digits Of The Number","isPartOf":{"@id":"http:\/\/43.205.93.38\/#website"},"primaryImageOfPage":{"@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage"},"image":{"@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage"},"thumbnailUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg","datePublished":"2023-06-05T09:29:02+00:00","dateModified":"2023-07-04T09:49:17+00:00","description":"Python Program To Find The Sum Of Digits Of The Number refers to the total value obtained by adding up each individual digit in the number.","breadcrumb":{"@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#primaryimage","url":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg","contentUrl":"https:\/\/prepbytes-misc-images.s3.ap-south-1.amazonaws.com\/assets\/1685949194069-Python%20Program%20to%20find%20the%20sum%20of%20digits%20of%20the%20number.jpg"},{"@type":"BreadcrumbList","@id":"https:\/\/prepbytes.com\/blog\/python-program-to-find-the-sum-of-digits-of-the-number\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"http:\/\/43.205.93.38\/"},{"@type":"ListItem","position":2,"name":"Python","item":"https:\/\/prepbytes.com\/blog\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Program To Find The Sum Of Digits Of The Number"}]},{"@type":"WebSite","@id":"http:\/\/43.205.93.38\/#website","url":"http:\/\/43.205.93.38\/","name":"PrepBytes Blog","description":"ONE-STOP RESOURCE FOR EVERYTHING RELATED TO CODING","publisher":{"@id":"http:\/\/43.205.93.38\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"http:\/\/43.205.93.38\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"http:\/\/43.205.93.38\/#organization","name":"Prepbytes","url":"http:\/\/43.205.93.38\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/","url":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","contentUrl":"https:\/\/blog.prepbytes.com\/wp-content\/uploads\/2025\/07\/uzxxllgloialmn9mhwfe.webp","width":160,"height":160,"caption":"Prepbytes"},"image":{"@id":"http:\/\/43.205.93.38\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/prepbytes0211\/","https:\/\/www.instagram.com\/prepbytes\/","https:\/\/www.linkedin.com\/company\/prepbytes\/","https:\/\/www.youtube.com\/channel\/UC0xGnHDrjUM1pDEK2Ka5imA"]},{"@type":"Person","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/3f7dc4ae851791d5947a7f99df363d5e","name":"Prepbytes","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"http:\/\/43.205.93.38\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/232042cd1a1ea0e982c96d2a2ec93fb70a8e864e00784491231e7bfe5a9e06b5?s=96&d=mm&r=g","caption":"Prepbytes"},"url":"https:\/\/prepbytes.com\/blog\/author\/gourav-jaincollegedekho-com\/"}]}},"_links":{"self":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16679","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/users\/52"}],"replies":[{"embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/comments?post=16679"}],"version-history":[{"count":1,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16679\/revisions"}],"predecessor-version":[{"id":16680,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/posts\/16679\/revisions\/16680"}],"wp:attachment":[{"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/media?parent=16679"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/categories?post=16679"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/prepbytes.com\/blog\/wp-json\/wp\/v2\/tags?post=16679"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}