2006/5/2, michel maho <[EMAIL PROTECTED]>: > > To all > I have the following calculation: > > "Je Body Mass Index is",gewicht/lengte**2 > > The result is a (digital?)floating point figure with with 10 decimal > numbers. For = > example 27.2345678487 > Did I mis something? I would like to reduce it to one or two decimal = > numbers.(27.2) but round(_,1) does not work. > Is there any other way? > Thank You > Michel Maho > Sorry if this is a second mail. > Something went wrong
You can use string formatting here: "Je Body Mass Index is %.1f"%gewicht/lengte**2 The % inside the string says that one should format the thing following the % after the string here. ".2f" specifies how it should be formatted - f says that we will have a floating-point value, shown in decimal (not exponentional form), and the .1 means that there should be 1 digit after the decimal dot. -- Andre Engels, [EMAIL PROTECTED] ICQ: 6260644 -- Skype: a_engels _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor