{"id":15,"date":"2022-08-23T07:30:29","date_gmt":"2022-08-23T07:30:29","guid":{"rendered":"https:\/\/python.freelinuxtutorials.com\/?p=15"},"modified":"2022-08-23T10:06:58","modified_gmt":"2022-08-23T10:06:58","slug":"python-data-type-float","status":"publish","type":"post","link":"https:\/\/python.freelinuxtutorials.com\/index.php\/2022\/08\/23\/python-data-type-float\/","title":{"rendered":"Python>>Data Type:Float"},"content":{"rendered":"<div>Floating point number is real numbers with decimal point (.)or fractional part. It can be positive or negative.<\/div>\n<div><\/div>\n<div>Example:<\/div>\n<div>5678.90<br \/>\n-2.88<\/div>\n<div>0.99<\/div>\n<div><\/div>\n<div>\n<blockquote>\n<div>&gt;&gt;&gt; z = -1.234<\/div>\n<div>&gt;&gt;&gt; type(z)<\/div>\n<div>&lt;class &#8216;float&#8217;&gt;<\/div>\n<\/blockquote>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>Let&#8217;s do arithmetic:<\/div>\n<div><\/div>\n<div>\n<blockquote>\n<div>&gt;&gt;&gt; x = 8+8.1<\/div>\n<div>&gt;&gt;&gt; print (x)<\/div>\n<div>16.1<\/div>\n<div>&gt;&gt;&gt; print (type(x))<\/div>\n<div>&lt;class &#8216;float&#8217;&gt;<\/div>\n<\/blockquote>\n<div><\/div>\n<\/div>\n<div>\n<p>Some key notes:<\/p>\n<p>1. numbers separated with underscore can consider a valid float as long has decimal point<\/p>\n<\/div>\n<div><\/div>\n<div>\n<blockquote>\n<div>&gt;&gt;&gt; x = 66_77_88.3_21<\/div>\n<div>&gt;&gt;&gt; type (x)<\/div>\n<div>&lt;class &#8216;float&#8217;&gt;<\/div>\n<\/blockquote>\n<\/div>\n<div>2. real numbers\u00a0 with a fractional part represented by scientific notation e or E, or those floating numbers that exceeded the maximum size (1.8 * 10^308), it will be referred as &#8220;infinity&#8221; or &#8220;inf&#8221;<\/div>\n<div><\/div>\n<div>\n<blockquote>\n<div>&gt;&gt;&gt; 1.8e308<\/div>\n<div>inf<\/div>\n<div>&gt;&gt;&gt; x = 1.8e308<\/div>\n<div>&gt;&gt;&gt; print (x)<\/div>\n<div>inf<\/div>\n<div>&gt;&gt;&gt; type (x)<\/div>\n<div>&lt;class &#8216;float&#8217;&gt;<\/div>\n<\/blockquote>\n<\/div>\n<div>\n<blockquote>\n<div>&gt;&gt;&gt; 0.4e9<\/div>\n<div>400000000.0<\/div>\n<div>&gt;&gt;&gt; x = 0.4e9<\/div>\n<div>&gt;&gt;&gt; type (x)<\/div>\n<div>&lt;class &#8216;float&#8217;&gt;<\/div>\n<\/blockquote>\n<\/div>\n<div><\/div>\n<div>3. there&#8217;s a function float() to convert string into float class.<\/div>\n<div><\/div>\n<div>\n<blockquote>\n<div>&gt;&gt;&gt; x = 100<\/div>\n<div>&gt;&gt;&gt; float (x)<\/div>\n<div>100.0<\/div>\n<\/blockquote>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Floating point number is real numbers with decimal point (.)or fractional part. It can be positive or negative. Example: 5678.90 -2.88 0.99 &gt;&gt;&gt; z = -1.234 &gt;&gt;&gt; type(z) &lt;class &#8216;float&#8217;&gt; Let&#8217;s do arithmetic: &gt;&gt;&gt; x = 8+8.1 &gt;&gt;&gt; print (x) 16.1 &gt;&gt;&gt; print (type(x)) &lt;class &#8216;float&#8217;&gt; Some key notes: 1. numbers separated with underscore can&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"footnotes":""},"categories":[3],"tags":[4,5],"class_list":["post-15","post","type-post","status-publish","format-standard","hentry","category-data-types","tag-data-type","tag-float"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/posts\/15","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/comments?post=15"}],"version-history":[{"count":1,"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions"}],"predecessor-version":[{"id":16,"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/posts\/15\/revisions\/16"}],"wp:attachment":[{"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/media?parent=15"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/categories?post=15"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/python.freelinuxtutorials.com\/index.php\/wp-json\/wp\/v2\/tags?post=15"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}