Multiplication and division in Python | Sololearn: Learn to code for FREE!

+4

Multiplication and division in Python

When I multiply 63 by (10/100), I get 6.300000000000001 but I want the output to be 6.30. How do I do that? I'm working on a code and I want my output to be in one or two decimal places but I don't know how to do that. If I multiply the same fraction by 70, I'll get 7.0. Can someone help me?

5/2/2022 7:54:36 AM

Gideon Ayivi

7 Answers

New Answer

+4

write, ( 63 * 10 ) / 100, it will just give 6.3 Alternatively, 👇👇 use str.format( ) do this way 👇👇👇👇 https://code.sololearn.com/cjrIf2qHWUla/?ref=app

+4

this will round up the resulting float number up to two digits after point. print(round(63*(10/100),2)) to make it easy to read: x = 63*(10/100) z = round(x,2) print(z)

+3

Please go through string formatting It just take 3 min approx and u will have a understanding & the answer

+2

It is work try it x = 63*(10/100) result = "{:.2f}".format(x) print(result)

+1

i think this works: print(f"{63/(10/100):.2f}")

+1

https://www.sololearn.com/Discuss/3046857/?ref=app

0

In python, to multiply number, we will use the asterisk character ” * ” to multiply number. After writing the above code (how to multiply numbers in Python), Ones you will print “ number ” then the output will appear as a “ The product is: 60 ”. https://www.direct2hr.org/