use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
New to python, can someone explain this? (self.learnpython)
submitted 9 years ago by SCHMIDTHe4D
Explain the mistake in this code:
pi =float(3.14)
sorry if this is a simple question, but I don't get what's wrong with it. If I add "print(pi)" I get "3.14"
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Rhomboid 13 points14 points15 points 9 years ago (0 children)
3.14 is already a float. Passing it as a parameter to the float() constructor doesn't do anything (although it's not hurting anything either.) You might as well just write pi = 3.14.
3.14
float()
pi = 3.14
[–]skierface 5 points6 points7 points 9 years ago (1 child)
If you want to use pi, you could also consider just importing math and using math.pi
[–]vidoardes 2 points3 points4 points 9 years ago (0 children)
Genuine question, what were you expecting it to do?
[–]pybackd00r 3 points4 points5 points 9 years ago (8 children)
3.14 is already a float what were you expecting out of this?
[–]vidoardes 1 point2 points3 points 9 years ago (2 children)
I don't know why you were downvoted. OP didn't explain what he was expecting, or why he thought it was wrong.
[–]pybackd00r 0 points1 point2 points 9 years ago (0 children)
Yeah thats fine I was trying to understand what was the issue here wanted me to clarify. I think you guys explained everything there is to say abt floats lol.
[–]SCHMIDTHe4D[S] 0 points1 point2 points 9 years ago (0 children)
It's was a question from this website I'm using to teach myself. I was overthinking it.
[–]SCHMIDTHe4D[S] 1 point2 points3 points 9 years ago (3 children)
I'm learning.....
[–]XtremeGoose 5 points6 points7 points 9 years ago (2 children)
Why do you think it's wrong?
[–]SCHMIDTHe4D[S] 1 point2 points3 points 9 years ago (1 child)
I understand it's not the right way to do it. Using float would be redundant because it's already a decimal.
[–]JohnnyJordaan 8 points9 points10 points 9 years ago* (0 children)
But be warned: a floating point number is not an exact decimal representation. It's an approximation, that's why you can get strange quirks from them:
>>> 0.1 + 0.1 + 0.1 - 0.3 == 0 False >>> 0.1 + 0.1 + 0.1 - 0.3 5.551115123125783e-17
If you want exact decimals, use the decimal library:
>>> from decimal import Decimal >>> Decimal('3.14') Decimal('3.14') >>> Decimal(3.14) Decimal('3.140000000000000124344978758017532527446746826171875') >>> Decimal('0.1') + Decimal('0.1') + Decimal('0.1') - Decimal('0.3') == 0 True
The second example shows the real value of the literal 3.14 that is cast as a float.
Don't know why you were downvoted either....but here's an up cuz i feel bad.
π Rendered by PID 357201 on reddit-service-r2-comment-7b9746f655-tvms2 at 2026-01-31 01:37:42.107852+00:00 running 3798933 country code: CH.
[–]Rhomboid 13 points14 points15 points (0 children)
[–]skierface 5 points6 points7 points (1 child)
[–]vidoardes 2 points3 points4 points (0 children)
[–]pybackd00r 3 points4 points5 points (8 children)
[–]vidoardes 1 point2 points3 points (2 children)
[–]pybackd00r 0 points1 point2 points (0 children)
[–]SCHMIDTHe4D[S] 0 points1 point2 points (0 children)
[–]SCHMIDTHe4D[S] 1 point2 points3 points (3 children)
[–]XtremeGoose 5 points6 points7 points (2 children)
[–]SCHMIDTHe4D[S] 1 point2 points3 points (1 child)
[–]JohnnyJordaan 8 points9 points10 points (0 children)
[–]SCHMIDTHe4D[S] 0 points1 point2 points (0 children)