3
How do I make the user choose the number of decimals of a number?
EX:
from math import pi
x = int(input('número de casas decimais de pi: '))
I want to be able to print on the screen pi
formatted with x
decimal places.
3
How do I make the user choose the number of decimals of a number?
EX:
from math import pi
x = int(input('número de casas decimais de pi: '))
I want to be able to print on the screen pi
formatted with x
decimal places.
Browser other questions tagged python
You are not signed in. Login or sign up in order to post.
i would like to print for example: 'the number pi matches 3.14 ' # pi with x decimal places clear, have to use f strings, . format or % ?
– rafael gonçalves filho
Anderson’s answer is the one you’re looking for then
– fernandosavio
You can include the call from
round
in f-string also:f'pi = {round(pi, casas)}'
– Woss
but round() round, wanted type, user says he wants 4 decimal places, so I print, 'pi corresponds to 3.1415'
– rafael gonçalves filho