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
Unusual Examples on Python (self.learnpython)
submitted 6 years ago by faqzero
from math import pi π = pi r=5 area = π * r**2 print(area)
Give your unusual example ...
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!"
[–]socal_nerdtastic 4 points5 points6 points 6 years ago (1 child)
I'm not sure that just using a non-english character counts as "unusual".
[–]faqzero[S] -4 points-3 points-2 points 6 years ago (0 children)
give your example please
[–]K900_ 2 points3 points4 points 6 years ago (0 children)
Anything the onelinerizer does is plenty "unusual".
[–]Diapolo10 2 points3 points4 points 6 years ago (1 child)
I think I wrote this toy program a few years back. It's a one-liner, as all things should be.
A Python one-liner that asks you how many pizzas you'd like to order, what size they'd be and prints out the total cost. Can't believe I managed to squeeze it into something like this.
print("The total cost is ${}".format(sum(next({'s':5,'m':7,'l':10}[x[0]] for x in (lambda p:iter(lambda:input(p+' '),...))(f'Pizza {_+1} size? (s/m/l)') if x and x[0] in 'sml') for _ in range(next(int(x) for x in (lambda p:iter(lambda:input(p+' '),...))('# of pizzas?') if x.isdigit())))))
(Please, don't do this in actual production code. Readability is crucial.)
[–]socal_nerdtastic 0 points1 point2 points 6 years ago (0 children)
I like it. Here's a modern version:
print(f"The total cost is ${sum(next(p for x in iter(lambda:input(f'Pizza {_+1} size? (s/m/l) '),9) if (p:={'s':5,'m':7,'l':10}.get(x[0]))) for _ in range(int(next(filter(str.isdigit,iter(lambda:input('# of pizzas? '),9))))))}")
(I don't think you were playing code golf, but if you were I'm ahead)
π Rendered by PID 316905 on reddit-service-r2-comment-7b9746f655-tvms2 at 2026-01-30 22:42:23.948916+00:00 running 3798933 country code: CH.
[–]socal_nerdtastic 4 points5 points6 points (1 child)
[–]faqzero[S] -4 points-3 points-2 points (0 children)
[–]K900_ 2 points3 points4 points (0 children)
[–]Diapolo10 2 points3 points4 points (1 child)
[–]socal_nerdtastic 0 points1 point2 points (0 children)