{"id":15431,"date":"2022-10-11T14:22:08","date_gmt":"2022-10-11T08:52:08","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/"},"modified":"2022-10-11T14:22:08","modified_gmt":"2022-10-11T08:52:08","slug":"solved-error-from-division-operator","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/","title":{"rendered":"[Solved] Error from division operator"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-32746748\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"32746748\" data-parentid=\"32746698\" data-score=\"0\" data-position-on-page=\"3\" data-highest-scored=\"0\" data-question-has-accepted-highest-score=\"0\" itemprop=\"suggestedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>The code you had was:<\/p>\n<pre><code>Traceback (most recent call last):\n  File \"C:\/Users\/Leb\/Desktop\/Python\/test.py\", line 14, in &lt;module&gt;\n    dayspermonth = (hourspermonth) \/ (hourspernight) * 24\nTypeError: unsupported operand type(s) for \/: 'NoneType' and 'int'\n<\/code><\/pre>\n<p>That&#8217;s because on line 12 you put <code>hourspermonth = print(\"you also sleep\", hourspermonth,\"hours per month\")<\/code>. Take out <code>hourspermonth<\/code> from your script. Same with last line.<\/p>\n<pre><code>#sleep calculator, user enters there hours slept over a nicght and the   program\n#will work out different facts about there sleaping\nprint(\"Welcome to the sleep calculator, all you have to do is answer one question...\")\nhourspernight = int(input(\"how many hours per night do you sleep?\"))\n#variable for the hours per week slept\nhoursperweek = hourspernight * 7\n#telling the user how many hours er week they sleep\nprint (\"you sleep\", hoursperweek,\"hours per week\")\n#variable for how many hours per month they sleep\nhourspermonth = float(hoursperweek * 4.35)\n#teling the user how namy hours per month they sleep\nprint(\"you also sleep\", hourspermonth,\"hours per month\")\n#ISSUE, this is the variable that python has a problem with, and I'm not sure why\ndayspermonth = (hourspermonth) \/ (hourspernight) * 24\n#telling the user how many days per month they sleep (this bits ok... I think)\nprint(\"you sleep for\",dayspermonth,\"days per month aswell!\")\n<\/code><\/pre>\n<p>Side note: In python it&#8217;s better if you make sense of your variables. Instead of using <code>hourspernight<\/code> use <code>hours_per_night<\/code> or even smaller <code>hrs_night<\/code> then next to it add comments if you need. Make it more presentable overall.<\/p>\n<p><strong>Edit<\/strong><\/p>\n<p>Change line 12 to:<\/p>\n<pre><code>print(\"you also sleep\", \"{0:.2f}\".format(hourspermonth),\"hours per month\")\n<\/code><\/pre>\n<p>This will fix your format issue and make it 2 digits after the decimal point<\/p>\n<p><strong>Edit 2<\/strong><\/p>\n<p>Change line 14 and 16 to:<\/p>\n<pre><code>dayspermonth = (hourspermonth) \/ 24\n...\nprint(\"you sleep for\",\"{0:.2f}\".format(dayspermonth),\"days per month aswell!\")\n<\/code><\/pre>\n<\/p><\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">5<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved Error from division operator <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] The code you had was: Traceback (most recent call last): File &#8220;C:\/Users\/Leb\/Desktop\/Python\/test.py&#8221;, line 14, in &lt;module&gt; dayspermonth = (hourspermonth) \/ (hourspernight) * 24 TypeError: unsupported operand type(s) for \/: &#8216;NoneType&#8217; and &#8216;int&#8217; That&#8217;s because on line 12 you put hourspermonth = print(&#8220;you also sleep&#8221;, hourspermonth,&#8221;hours per month&#8221;). Take out hourspermonth from your script. Same &#8230; <a title=\"[Solved] Error from division operator\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\" aria-label=\"More on [Solved] Error from division operator\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[349],"class_list":["post-15431","post","type-post","status-publish","format-standard","hentry","category-solved","tag-python"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] Error from division operator - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] Error from division operator - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] The code you had was: Traceback (most recent call last): File &quot;C:\/Users\/Leb\/Desktop\/Python\/test.py&quot;, line 14, in &lt;module&gt; dayspermonth = (hourspermonth) \/ (hourspernight) * 24 TypeError: unsupported operand type(s) for \/: &#039;NoneType&#039; and &#039;int&#039; That&#8217;s because on line 12 you put hourspermonth = print(&quot;you also sleep&quot;, hourspermonth,&quot;hours per month&quot;). Take out hourspermonth from your script. Same ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-10-11T08:52:08+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] Error from division operator\",\"datePublished\":\"2022-10-11T08:52:08+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\"},\"wordCount\":91,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"python\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\",\"name\":\"[Solved] Error from division operator - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-10-11T08:52:08+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] Error from division operator\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] Error from division operator - JassWeb","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:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] Error from division operator - JassWeb","og_description":"[ad_1] The code you had was: Traceback (most recent call last): File \"C:\/Users\/Leb\/Desktop\/Python\/test.py\", line 14, in &lt;module&gt; dayspermonth = (hourspermonth) \/ (hourspernight) * 24 TypeError: unsupported operand type(s) for \/: 'NoneType' and 'int' That&#8217;s because on line 12 you put hourspermonth = print(\"you also sleep\", hourspermonth,\"hours per month\"). Take out hourspermonth from your script. Same ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/","og_site_name":"JassWeb","article_published_time":"2022-10-11T08:52:08+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] Error from division operator","datePublished":"2022-10-11T08:52:08+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/"},"wordCount":91,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["python"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/","url":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/","name":"[Solved] Error from division operator - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-10-11T08:52:08+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-error-from-division-operator\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] Error from division operator"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1775798750","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/15431","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=15431"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/15431\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=15431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=15431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=15431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}