Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to get decimal part of a double in python

number_dec = str(number-int(number))[1:]
Comment

how to get decimal part of a double in python

decimal = input("Input decimal number: ") #123.456

# split 123.456 by dot = ['123', '456']
after_coma = decimal.split('.')[1] 

# because only index 1 is taken then '456'
print(after_coma) # '456'
Comment

PREVIOUS NEXT
Code Example
Python :: python fill 0 
Python :: remove idx of list python 
Python :: python [remote rejected] master - master (pre-receive hook declined) 
Python :: catch error python 
Python :: how to merge more than 2 dataframes in python 
Python :: print output python to file 
Python :: python delete white spaces 
Python :: force garbage collection in python 
Python :: python get response from url 
Python :: python get element from list 
Python :: dir template 
Python :: case in python 
Python :: python selenium find by class name 
Python :: add custom field to serializer 
Python :: run python file using python code 
Python :: how to change the background of heading in tkinter 
Python :: python ssh connection 
Python :: jupyter notebook delete the output 
Python :: count values in numpy list python 
Python :: python dict print keys 
Python :: ipython save session 
Python :: second y axis matplotlib 
Python :: malier module python 
Python :: pd df to series 
Python :: python datetime day of year 
Python :: assignment 7.1 python data structures 
Python :: sqlite3 delete row python 
Python :: remove index from dataframe pandas 
Python :: pylint import error 
Python :: print from 1 to n in python 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =