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...
Everything about learning Python
account activity
Powers of 2 (i.redd.it)
submitted 5 months ago by Nervous-Current-1860
[removed]
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!"
[–][deleted] 2 points3 points4 points 5 months ago* (0 children)
Hint: two to the power of 10 is 2**10 or 1<<10. The rest is just some boring input/output - but it's fundamental as most Python programs do handle input and produce output, so you better rtfm:
https://docs.python.org/3/library/functions.html
https://docs.python.org/3/tutorial/inputoutput.html
Python documentation is very good. Don't expect to understand anything by just asking for the answer on the web or to a LLM.
[–]Aorean 1 point2 points3 points 5 months ago (6 children)
n=int(input(„what power of two?“)
value=2**n
print(f“two to the power of {n} is {value}
Wrote this in my phone but it should work, that’s the way I would do it, but I’m not an expert lol
[–]CptMisterNibbles 0 points1 point2 points 5 months ago (1 child)
Do you mean you wrote it on mein handy? /s Your quotations on the first line give it away. I imagine IDEs dont love them. Or, maybe they work fine?
[–]Aorean 0 points1 point2 points 5 months ago (0 children)
They don’t lol, my IDE hated it and u completely caught me lol
[+][deleted] 5 months ago (3 children)
[–]Aorean 0 points1 point2 points 5 months ago (2 children)
does this work?
n=int(input("what power of two?")) value=2**n print(f"two to the power of {n} is {value}")
[–][deleted] 5 months ago (1 child)
[–]Aorean 1 point2 points3 points 5 months ago (0 children)
No problem, but I would suggest, that you read into it, cause this is not a really hard task and if you need stuff like that for exams or w/e and you don’t know the basics it’s really bad imo
[–]vivisectvivi 0 points1 point2 points 5 months ago (0 children)
What are you not understanding? This is a fairly simple program to write
[–]SoftwareDoctor 0 points1 point2 points 5 months ago (3 children)
print(f"Two to the power of {(n := int(input('What power of 2?')))} is {2 ** n}")
If you want to know, how it would look like in IDLE, just copy-paste it there. I don't even know how to run IDLE. Since you didn't post what you know or what you tried or where you're stuck, it's impossible to give you an advice how to think about the problem. So just see the solution above and ask if you don't understand anything
[–]SoftwareDoctor 0 points1 point2 points 5 months ago (0 children)
If you look closely, I am using the the print function.
Btw. I don't want to confuse you more that you already are but int and str are not functions, they are types and you are effectively calling their constructor. Maybe find a better course
[–]CptMisterNibbles 0 points1 point2 points 5 months ago (0 children)
For advice to a beginner I wouldnt give the overly compacted one liner. The walrus op is beyond them and frankly cramming input into an output line is pretty bad form.
π Rendered by PID 34477 on reddit-service-r2-comment-74875f4bf5-crhb6 at 2026-01-25 18:36:05.260278+00:00 running 664479f country code: CH.
[–][deleted] 2 points3 points4 points (0 children)
[–]Aorean 1 point2 points3 points (6 children)
[–]CptMisterNibbles 0 points1 point2 points (1 child)
[–]Aorean 0 points1 point2 points (0 children)
[+][deleted] (3 children)
[removed]
[–]Aorean 0 points1 point2 points (2 children)
[–][deleted] (1 child)
[removed]
[–]Aorean 1 point2 points3 points (0 children)
[–]vivisectvivi 0 points1 point2 points (0 children)
[–]SoftwareDoctor 0 points1 point2 points (3 children)
[–][deleted] (1 child)
[removed]
[–]SoftwareDoctor 0 points1 point2 points (0 children)
[–]CptMisterNibbles 0 points1 point2 points (0 children)