Python Ask For Decimal Number -


can please tell me how code ask value (say user enter 100.00) , put number it's 2 decimal points value more functions later on, ie: multipling it, etc.

thanks.

here's start (for python 3; python 2, use raw_input instead of input):

while true:     snum = input("please enter decimal number:")     try:         num = float(snum)         break     except valueerror:         print("this not valid decimal number!") print("this number, rounded 2 places, is: {:0.2f}".format(num)) 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -