Python hyung's conversion question!

Asked 2 years ago, Updated 2 years ago, 14 views

sum = 3 + 4.253; print(str(sum))

If I do this, why is the output ' 7.253". It doesn't work 7.253. Will it come out like this?

str(3 + 4.253) If you type it like this, ' 7.253." It's printed like this, right?

python

2022-09-20 10:53

1 Answers

If so, what you are looking for is repr().

print(str(3.425))
print(str('3.425'))
print(repr(3.425))
print(repr('3.425'))

Learn more


2022-09-20 10:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.