Screen Link: https://app.dataquest.io/m/311/programming-in-python/3/the-print-command
Hey guys. I was just wondering how the site is showing that you can run multiple things at once such as in the link above
3 print (2+1)
then the output is:
using actual python console, it won’t let me list it out like 1,2,3 above for it to give you all the results at once. As soon as you hit enter, it gives you the result for the first line then you can move on and put in the other one to get that individual result. I was just wondering why it isn’t reflective of actual python format, or if I’m missing something. The way I did it to get the output listed out on separate lines was to just do
“print (20+10), print (5+3)”… no quotations, just next to each other and separated by commas, then it gave me:
Not sure why the output says the none part…
This doesn’t actually concern
print specifically. When you code, you do so in some sort of computer programming environment.
In a console, the type of environment you’re coding in is called read–eval–print loop (REPL). The same is self-descriptive: it reads each line, then it evaluates it (in other words, it runs it) and then prints the result.
In fact, even if you don’t use print statements, it will print the result.
Another kind of environment, and this is (roughly) the one we use at Dataquest, is text editors with some added functionalities. We simply create a text file that we’ll later run, in which case you won’t be interactively inputting code, it’s simply already there in the text file; hence the result of the multiple print statements showing up all at once.