How we can round off a float to a give value?

hey @mtf
how we can round off a float to a give value?
i known that if a float is given; by using int( ) we can cut off its decimal so that only integer remains like:

meta =6.6
print (int (meta) )
   # would output 6

so how we can make it round off to nearest figure like 0.5
EX :

meta = 7.3
  #somehow it should be 7.5 as output. how to do it?

Not quite getting your question. Can you describe it another way?

@mtf uhhhhh, i just want to ask how i can tell the program to print its nearing .5 rounded figure

     *like 7.7 should be  8 ,    6.2 should be 6,    7.3 should be 7.5,   9 should be 9,    10.5 should be 10.5,    11.1 should be 11, 6.4 should be 6.5,   2.9 should be 3*  

just want to tell programm to round off the float to the nearest rounding figure of .5 like above examples . the float must round of to its nearest rounding figure here, 0.5 

did you get it now?

7.3 should be 7. The rounding rule is simple, up on 5, down on 4.

For what you want to do we need some way to increase the .3. How about doubling?

round(7.3 * 2)

That will give us 15. Divide by 2 and we get 7.5

1 Like