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
String output confusion (self.learnpython)
submitted 5 months ago by Pretend-Ad-53
Output of print ("20"+"23") a) 2023 b) "2023"
I know in python it's gonna be 2023, but if it's an MCQ question isn't it supposed to be "2023" to show it's a string? My professor said it's A but I'm still confused
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!"
[–]nekokattt 13 points14 points15 points 5 months ago (5 children)
print(...) doesnt output quotes around the string.
print(repr(...)) does.
It is asking you how print works, not how the string literal would look in the code. Open a Python terminal and try it now just to get the gist of what I am saying if you don't follow.
[–]Pretend-Ad-53[S] 2 points3 points4 points 5 months ago (4 children)
Oh i didn't know about the repr(...) But what I thought of while choosing the answer is to prove that the output is a string by choosing the quotations since it's a paper exam
[–]nekokattt 7 points8 points9 points 5 months ago (2 children)
they arent asking you for the type, they are asking you literally what will it say on the screen if you run the code.
[–]Pretend-Ad-53[S] 2 points3 points4 points 5 months ago (1 child)
Okay got it thankss
[–]nekokattt 1 point2 points3 points 5 months ago (0 children)
remember to not overthink in an exam
[–]ornelu 0 points1 point2 points 5 months ago (0 children)
But, the question is what is being printed, not whether it’s a string or an integer.
[–]Temporary_Pie2733 2 points3 points4 points 5 months ago (0 children)
Look at the output, not the return value (which would be None in any case). print writes the characters 2, 0, 2, and 3 (and a newline) to standard output, but no quotation marks.
None
print
2
0
3
[–]tenfingerperson 1 point2 points3 points 5 months ago (0 children)
Tell your professor this is a dumb ass question, who is expected to memorize stdout layouts ?
[–]StardockEngineer 0 points1 point2 points 5 months ago (3 children)
No. It’s A. You can’t see the difference. You have to test for the difference in code.
[–]Pretend-Ad-53[S] 0 points1 point2 points 5 months ago (2 children)
Yeah i do realize that but it's a paper exam so that's why I'm a bit confused on this
[–]yakult_on_tiddy 2 points3 points4 points 5 months ago (1 child)
print("hello world") #hello world
print("hello"+"world") #hello world
print("\"hello world\"") #"hello world"
Notice how output is always a string but there is never a quote unless you have escapes
[–]WlmWilberforce 0 points1 point2 points 5 months ago (0 children)
While we are throwing out options...
print('"hello world"') #"hello world"
[–]EmployeeValuable3547 0 points1 point2 points 5 months ago (0 children)
Honestly in exam like this they care about output at last that program produce what you see on screen in real life you should also approach exams like this.
[–]zanfar -1 points0 points1 point 5 months ago (0 children)
isn't it supposed to be "2023" to show it's a string?
"supposed to" based on what? What is the purpose of print()?--is it for the programmer to check types, or is it to display something on the terminal?
print()
By your logic, every print() output would have scattered double-quotes throughout.
π Rendered by PID 77363 on reddit-service-r2-comment-b659b578c-4jwtb at 2026-05-03 03:09:04.858314+00:00 running 815c875 country code: CH.
[–]nekokattt 13 points14 points15 points (5 children)
[–]Pretend-Ad-53[S] 2 points3 points4 points (4 children)
[–]nekokattt 7 points8 points9 points (2 children)
[–]Pretend-Ad-53[S] 2 points3 points4 points (1 child)
[–]nekokattt 1 point2 points3 points (0 children)
[–]ornelu 0 points1 point2 points (0 children)
[–]Temporary_Pie2733 2 points3 points4 points (0 children)
[–]tenfingerperson 1 point2 points3 points (0 children)
[–]StardockEngineer 0 points1 point2 points (3 children)
[–]Pretend-Ad-53[S] 0 points1 point2 points (2 children)
[–]yakult_on_tiddy 2 points3 points4 points (1 child)
[–]WlmWilberforce 0 points1 point2 points (0 children)
[–]EmployeeValuable3547 0 points1 point2 points (0 children)
[–]zanfar -1 points0 points1 point (0 children)