{"id":17351,"date":"2022-08-23T19:01:31","date_gmt":"2022-08-23T13:31:31","guid":{"rendered":"https:\/\/copyassignment.com\/?p=17351"},"modified":"2022-11-28T18:30:59","modified_gmt":"2022-11-28T13:00:59","slug":"numbers-in-string-1-in-python-assignment-expert","status":"publish","type":"post","link":"https:\/\/copyassignment.com\/numbers-in-string-1-in-python-assignment-expert\/","title":{"rendered":"Numbers in String-1 in Python"},"content":{"rendered":"\n<p>This is a very simple question, you need to find the sum and average of all digits that appear in a string. For example,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># let declare a string\nmy_str = \"This is 10th string in 23rd para\"<\/code><\/pre>\n\n\n\n<p>Now, digits are <strong>1 and 0 from 10<\/strong> and <strong>2 and 3 from 23<\/strong>. So, the sum will be <strong>1+0+2+3=6<\/strong> and the average will be <strong>6\/4=1.5<\/strong>.<\/p>\n\n\n\n<script async=\"\" src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\n<ins class=\"adsbygoogle\" style=\"display:block; text-align:center;\" data-ad-layout=\"in-article\" data-ad-format=\"fluid\" data-ad-client=\"ca-pub-9886351916045880\" data-ad-slot=\"2002566052\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<p>Now, we will write a Python program to find the sum and average of numbers in a string.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Code:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>my_str = \"This is 10th string in 23rd para\"\n\ndigits=&#91;]\n\nfor i in my_str:\n    if i.isdigit():\n        digits.append(int(i))\n\nnumber_of_digits = len(digits)\ntotal_sum = sum(digits)\naverage = total_sum\/number_of_digits\n\nprint(total_sum)\nprint(average)<\/code><\/pre>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\">Output:<\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"722\" height=\"512\" data-src=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/Numbers-in-String-1-in-Python-Assignment-Expert.jpg\" alt=\"Numbers in String-1 in Python | Assignment Expert\" class=\"wp-image-17352 lazyload\" data-srcset=\"https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/Numbers-in-String-1-in-Python-Assignment-Expert.jpg 722w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/Numbers-in-String-1-in-Python-Assignment-Expert-300x213.jpg 300w, https:\/\/copyassignment.com\/wp-content\/uploads\/2022\/08\/Numbers-in-String-1-in-Python-Assignment-Expert-675x479.jpg 675w\" data-sizes=\"(max-width: 722px) 100vw, 722px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 722px; --smush-placeholder-aspect-ratio: 722\/512;\" \/><\/figure>\n\n\n\n<script async src=\"https:\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js?client=ca-pub-9886351916045880\"\n     crossorigin=\"anonymous\"><\/script>\n<ins class=\"adsbygoogle\"\n     style=\"display:block\"\n     data-ad-format=\"autorelaxed\"\n     data-ad-client=\"ca-pub-9886351916045880\"\n     data-ad-slot=\"7933252109\"><\/ins>\n<script>\n     (adsbygoogle = window.adsbygoogle || []).push({});\n<\/script>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>Also Read:<\/strong><\/p>\n\n\n<ul class=\"wp-block-latest-posts__list wp-block-latest-posts\"><li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/hyphenate-letters-in-python\/\">Hyphenate Letters in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/earthquake-in-python-easy-calculation\/\">Earthquake in Python | Easy Calculation<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/striped-rectangle-in-python\/\">Striped Rectangle in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/perpendicular-words-in-python\/\">Perpendicular Words in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/composite-number-in-python\/\">Composite Number in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/greatest-among-four-numbers-in-python\/\">Greatest Among Four Numbers in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/reverse-the-sentence-in-python\/\">Reverse the sentence in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/denominations-in-python\/\">Denominations in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/min-and-max-values-in-an-array-in-javascript-assignment-expert\/\">Min and max values in an array in JavaScript<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/keyboard-events-in-javascript-assignment-expert\/\">Keyboard events in JavaScript<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/reaching-ground-floor-in-python-assignment-expert\/\">Reaching Ground Floor in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/number-of-moves-in-python-assignment-expert\/\">Number of Moves in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/starks-adventure-in-python-assignment-expert\/\">Starks Adventure in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/neutralization-in-python-assignment-expert\/\">Neutralization in Python | Assignment Expert<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/free-shipping-in-python-assignment-expert\/\">Free shipping in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/raj-has-ordered-two-electronic-items-python-assignment-expert\/\">Raj has ordered two electronic items Python | Assignment Expert<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/first-place-in-python-assignment-expert\/\">First Place in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/triples-with-properties-in-python-assignment-expert\/\">Triples with Properties in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/nested-list-indexing-python-assignment-expert\/\">Nested list Indexing Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/team-points-in-python-assignment-expert\/\">Team Points in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/two-words-combination-in-python-assignment-expert\/\">Two words combination in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/id-card-in-python-assignment-expert\/\">ID Card in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/cipher-with-a-key-in-python-assignment-expert\/\">Cipher with a key in Python | Assignment Expert<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/multiple-of-5-in-python-assignment-expert\/\">Multiple of 5 in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/sandglass-star-in-python-assignment-expert\/\">Sandglass Star in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/multiple-of-3-in-python-assignment-expert\/\">Multiple of 3 in Python | Assignment Expert<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/ticket-selling-in-cricket-stadium-using-python-assignment-expert\/\">Ticket selling in Cricket Stadium using Python | Assignment Expert<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/sum-of-list-elements-in-python-assignment-expert\/\">Sum of List Elements in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/all-possible-subsets-in-python-assignment-expert\/\">All possible subsets in Python<\/a><\/li>\n<li><a class=\"wp-block-latest-posts__post-title\" href=\"https:\/\/copyassignment.com\/names-and-nicknames-in-python-assignment-expert\/\">Names and Nicknames in Python<\/a><\/li>\n<\/ul>","protected":false},"excerpt":{"rendered":"<p>This is a very simple question, you need to find the sum and average of all digits that appear in a string. For example, Now,&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1874],"tags":[],"class_list":["post-17351","post","type-post","status-publish","format-standard","hentry","category-python-very-small-program-assignments","wpcat-1874-id"],"_links":{"self":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts\/17351","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/comments?post=17351"}],"version-history":[{"count":0,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/posts\/17351\/revisions"}],"wp:attachment":[{"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/media?parent=17351"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/categories?post=17351"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/copyassignment.com\/wp-json\/wp\/v2\/tags?post=17351"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}