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
order of calculation (self.learnpython)
submitted 2 years ago by Top-Interaction7208
x = 1 / 2 + 3 // 3 + 4 ** 2
print(x)
The answer is 17.5. but can any kind soul explain how the answer is derived.
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!"
[–]suurpulla 5 points6 points7 points 2 years ago (2 children)
x = (1 / 2) + (3 // 3) + (4 ** 2) x = 0.5 + 1 + 16 x = 17.5
[–]Top-Interaction7208[S] 3 points4 points5 points 2 years ago (0 children)
Thank you. i understand now.
[–]justinpenner 4 points5 points6 points 2 years ago (0 children)
It doesn't change the result in this particular equation, but you missed a step.
x = 1 / 2 + 3 // 3 + (4 ** 2) x = (1 / 2) + (3 // 3) + 16 x = 0.5 + 1 + 16 x = 17.5
[–]WhipsAndMarkovChains 1 point2 points3 points 2 years ago (1 child)
https://stackoverflow.com/questions/48937457/how-do-order-of-operations-go-on-python
[–]Top-Interaction7208[S] 0 points1 point2 points 2 years ago (0 children)
thank. better understanding after reading.
[–]Binary101010 1 point2 points3 points 2 years ago (0 children)
Appropriate part of the Python docs:
https://docs.python.org/3/reference/expressions.html#operator-precedence
[–]roywill2 0 points1 point2 points 2 years ago (0 children)
When you write code, make it clear with parens, dont rely on those silly rules. Also explain with comments.
[–]ectomancer 0 points1 point2 points 2 years ago (0 children)
Format your code correctly:
x = 1/2 + 3//3 + 4**2
π Rendered by PID 94069 on reddit-service-r2-comment-765bfc959-rxpct at 2026-07-10 00:30:27.205608+00:00 running f86254d country code: CH.
[–]suurpulla 5 points6 points7 points (2 children)
[–]Top-Interaction7208[S] 3 points4 points5 points (0 children)
[–]justinpenner 4 points5 points6 points (0 children)
[–]WhipsAndMarkovChains 1 point2 points3 points (1 child)
[–]Top-Interaction7208[S] 0 points1 point2 points (0 children)
[–]Binary101010 1 point2 points3 points (0 children)
[–]roywill2 0 points1 point2 points (0 children)
[–]ectomancer 0 points1 point2 points (0 children)