Output is
defined as what the program gives away as a result. This is a text that will be
displayed in your screen during the running of your program. For printing your
output on Python 3 we use:
print( )
Inside the
parenthesis is where you type the text that you would like to be displayed.
This can be a string, a variable, or both.
To print a
string, which is an extract of text typed by the programmer, it is necessary to
place it between quotation marks. Otherwise, you will receive a message saying
you have a Syntax Error. In this example, the text displayed in the screen will
be: Hello World!
print(“Hello
World!”)
For printing
a variable, you need to place the name of the variable between the parentheses
without using any quotation marks. Otherwise, you will be printing text. Also,
you can create some mathematical operations between the parenthesis and the
output will be the result of those operations. For example, the text displayed
in the screen when running this program will be: 12
X = 5
Y = 7
Print(x+y)
You can
also print string variables by the same method
For
printing plain text and the value of a variable. It is necessary to place the
text between quotation marks. The text and the variable need to be separated by
a comma. For example, the following program will print: Hi, Laura!
Name= Laura
Print(“Hi,”,
name, “!”)
This other
program will print: The sum of 5 + 7 equals to 12
X=5
Y=7
Print(“The
sum of”, x, “+”, y, “equals to”, (x+y))
No hay comentarios:
Publicar un comentario