+8

Is “print” required to show text strings?

In a sample it said: >>>”spam” + ‘egg’ “Spam egg” When I try it myself, there is no output? I thought you can get the text shown without typing in “print”?

7/10/2019 8:05:51 AM

Sean Wu

10 Answers

New Answer

+12

Sean Wu When you work on interpreter( three ">>>" is an indication you are working on interpreter) then you don't need to write print (although you can) When you work with script, like a python program in codeplayground, then you must if you want to print any data.

+3

Yes

+2

You kind of have to, because just putting random strings doesn't do anything

+2

An explanation of the command prompt, what you enter and the output you get from the Python interpreter.

+1

thanks Airree. So that part of the sample is not sample of codes but just an explanation i guess?...

+1

Your prompt (aka Interpreter) is not the same as a python program. Stuff you put in a file is evaluated at runtime, while the interpreter prints the returning value, you don't have to type the print. If you put a string in a file, the file doesn't return anything, you have to print it.

+1

You need to direct the print output to the console so you need the print command 🤔

+1

In python print used print because when goes string length it does come for example input if typing "I am learning python " to give print it come output:I am learning python

0

No it not required

-1

Print is required only in script mode as it requires. Py. extension as script mode require more information than interactively mode so print is not required to show a text