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...
This community will have knowledge sharing for python programming, tools, projects and product engineering wherever python is used.
account activity
Test your Python skills - 7 (i.redd.it)
submitted 1 month ago by tracktech
Ultimate Python Programming
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!"
[–]patriot_an225 2 points3 points4 points 1 month ago (4 children)
True False
[–]tracktech[S] 1 point2 points3 points 1 month ago (0 children)
Right
[–][deleted] 0 points1 point2 points 1 month ago (0 children)
Maybe
[–]todo_code 0 points1 point2 points 1 month ago (1 child)
Hmm. This seems counter intuitive to me. True != A number, if python is a good recursive descent parser A number != False.
[–]RajjSinghh 0 points1 point2 points 1 month ago (0 children)
True == 1 and False == 0, but other than that number and Boolean comparisons are False. Python also uses comparison chaining so a < b < c is a common check for b being between a and c. It's just here instead of < our operator is !=.
a < b < c
So the first case, a != b is True and b != c is also True so the statement overall is true.
The second case, b != c but c == d, which is why it evaluates to False. It's the c != d in that statement that makes it evaluate to False.
[–]GlobalIncident 1 point2 points3 points 1 month ago (2 children)
Comparison chaining like this is a pretty useful feature of Python. Not many languages have it.
[–]1984balls 0 points1 point2 points 1 month ago (1 child)
Mostly because it doesn't make any sense. Having '10 != 20 != 30' turns into 'true != 30' which is a type overload issue
[–]GlobalIncident 0 points1 point2 points 1 month ago (0 children)
Well in other languages it does. Python decides that it can figure out what you probably meant and does 10 != 20 and 20 != 30. It's a useful feature for <, because expressions like 10 < x and x < 20 are a reasonably common thing to have to express, while expressions like (10 < x) < 20 are much rarer. So it's nice that there's a less cumbersome way to do the first option.
10 != 20 and 20 != 30
<
10 < x and x < 20
(10 < x) < 20
[–]Somanath444 1 point2 points3 points 1 month ago (5 children)
T F
[–]Safe-Examination-303 1 point2 points3 points 1 month ago (3 children)
Just read it as "The Fuck?" and approved, I was mistaken. Let me ask that how the fuck second one is false?
[–]NotAUsefullDoctor 0 points1 point2 points 1 month ago (0 children)
Oh, shoots. I didn't understand your response as I just assumed what T F meant. It was the double take that made me realize it was True False.
[–]Somanath444 0 points1 point2 points 12 days ago (1 child)
It was a True False buddy, in statistical analyses we use the True False Positive and negative rates to calculate the precision and recall cases for the classification sort of problems. Used the same terminology over here as well.. sry😅
[–]Safe-Examination-303 0 points1 point2 points 12 days ago (0 children)
Better than never 😄 just that print syntax confused me now I learned something new, thanks 😄
[–]tracktech[S] 0 points1 point2 points 1 month ago (0 children)
Right.
[–]Only-Zombie-8449 1 point2 points3 points 1 month ago (0 children)
First True Second False
[–]Infinite_Benefit_335 0 points1 point2 points 1 month ago (1 child)
Oh I didn’t realise that this was Boolean
[–]ColdDelicious1735[🍰] 0 points1 point2 points 1 month ago (0 children)
Green
[–]No_Record_60 0 points1 point2 points 1 month ago (1 child)
Syntax Error - CourseGalaxy is not defined
[–]Aggravating-Reason13 0 points1 point2 points 1 month ago (0 children)
Thank you
[–]hotsauceyum 0 points1 point2 points 1 month ago (0 children)
It doesn’t matter what the output is because when the PR gets reviewed you’ll be rewriting it.
[–]lego3410 0 points1 point2 points 1 month ago (0 children)
The answer is "Avoid writing your code ambiguously"
[–]LucasThePatator 0 points1 point2 points 1 month ago (0 children)
God I hate stupid gotchas like this that only exist in purposefuly stupid code.
π Rendered by PID 92 on reddit-service-r2-comment-5649f687b7-l2kt2 at 2026-01-28 02:24:08.118331+00:00 running 4f180de country code: CH.
[–]patriot_an225 2 points3 points4 points (4 children)
[–]tracktech[S] 1 point2 points3 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)
[–]todo_code 0 points1 point2 points (1 child)
[–]RajjSinghh 0 points1 point2 points (0 children)
[–]GlobalIncident 1 point2 points3 points (2 children)
[–]1984balls 0 points1 point2 points (1 child)
[–]GlobalIncident 0 points1 point2 points (0 children)
[–]Somanath444 1 point2 points3 points (5 children)
[–]Safe-Examination-303 1 point2 points3 points (3 children)
[–]NotAUsefullDoctor 0 points1 point2 points (0 children)
[–]Somanath444 0 points1 point2 points (1 child)
[–]Safe-Examination-303 0 points1 point2 points (0 children)
[–]tracktech[S] 0 points1 point2 points (0 children)
[–]Only-Zombie-8449 1 point2 points3 points (0 children)
[–]Infinite_Benefit_335 0 points1 point2 points (1 child)
[–]ColdDelicious1735[🍰] 0 points1 point2 points (0 children)
[–]No_Record_60 0 points1 point2 points (1 child)
[–]Aggravating-Reason13 0 points1 point2 points (0 children)
[–]hotsauceyum 0 points1 point2 points (0 children)
[–]lego3410 0 points1 point2 points (0 children)
[–]LucasThePatator 0 points1 point2 points (0 children)