Skip to content

Write Code Online

my coding journey

Menu
  • Blog
  • Python
Menu

Python>>Data Type:Float

Posted on August 26, 2021 by coden00b
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
>>> z = -1.234
>>> type(z)
<class ‘float’>
Let’s do arithmetic:
>>> x = 8+8.1
>>> print (x)
16.1
>>> print (type(x))
<class ‘float’>
Some key notes:

1. numbers separated with underscore can consider a valid float as long has decimal point

>>> x = 66_77_88.3_21
>>> type (x)
<class ‘float’>
2. real numbersĀ  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 “infinity” or “inf”
>>> 1.8e308
inf
>>> x = 1.8e308
>>> print (x)
inf
>>> type (x)
<class ‘float’>
>>> 0.4e9
400000000.0
>>> x = 0.4e9
>>> type (x)
<class ‘float’>
3. there’s a function float() to convert string into float class.
>>> x = 100
>>> float (x)
100.0

Related

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • Python>>Strings: Indexing and Slicing
  • Python>>Data Type:Strings
  • Zero or Free SSL
  • Python>>Data Type:Float
  • Python>>Data Type:Integer

RSS Linux Feeds

  • Secure Cron Permissions and Ownerships for Ubuntu Linux
  • Run Android Apps on Linux Part 2 : Install Genymotion and Google Playstore on Ubuntu
  • Run Android Apps on Linux : Install Anbox and Google Playstore on Ubuntu
  • Installation and Configuration of Conky and Conky-Manager on Ubuntu Linux
  • Quick Tip: Install Sticky Notes on Ubuntu 20.04 Linux

RSS Networking Feeds

  • OSPF and OSPFv3 Configuration on Huawei Routers
  • EBGP Configuration on Huawei Router
  • Useful Cisco IOS-XR Hardware-related commands
  • Static Management Configuration for Cisco vs Juniper vs Huawei Comparison
  • VLAN and Port-Channel Configuration (Cisco to Juniper Conversion)

Recent Comments

No comments to show.

Archives

  • August 2021

Categories

  • blog
  • python
© 2022 Write Code Online | Powered by Minimalist Blog WordPress Theme
  • bitcoinBitcoin(BTC)$29,288.00-3.90%
  • ethereumEthereum(ETH)$1,967.53-5.06%
  • tetherTether(USDT)$1.00-0.15%
  • binancecoinBNB(BNB)$322.99-2.86%
  • usd-coinUSD Coin(USDC)$1.00-0.18%
  • rippleXRP(XRP)$0.403675-5.38%
  • Binance USDBinance USD(BUSD)$1.00-0.01%
  • cardanoCardano(ADA)$0.51-6.78%
  • SolanaSolana(SOL)$49.41-8.51%
  • dogecoinDogecoin(DOGE)$0.083870-4.78%