32
loading...
This website collects cookies to deliver better user experience
print("Hello, World!")
print
should be lowercase"puppy"
)print()
. You can go to the docs here: https://docs.python.org/3/library/functions.html#printprint(*objects, sep=' ', end='\n', file=sys.stdout, flush=False)
()
and are separated by commas. There are five arguments; We’ll go over the first three. Any arguments that have an =
are not required as they had defaults set to whatever is after the =
. Here are the three we’ll work with.objects
refers to whatever you want to print and the *
just means you can put as many things, separated by commas, as you want.sep=' '
is saying that each of those things, or objects, will be separated by a single space, by default. If you were to give sep=', '
your objects would be separated by ,
a comma and a space.end='\n'
says that at the end of whatever you are printing, it is giving a new line. It’s basically hitting the enter key after you print. You can change that if you want by giving something other than \n
for the end.
Sometimes it can be helpful to give a separator and/or a different end of the line. Here are a few examples. Try it out for yourself.
# print() separator example
print("cat", "mouse", "dog") # prints cat mouse dog
print("cat", "mouse", "dog", sep=", ") # prints cat, mouse, dog
print("cat", "mouse", "dog", sep="123") # prints cat123mouse123dog
# print() end example
print("1st print", end=", ") # prints 1st print,
print("2nd print")
Print("Hi there")" |
print"(Bom Dia!, sep="... ")" |
print("Nǐ hǎo", sep" - ") |
print("¡Hola"!) |
print.("Assalamu Alaikum", end=" ") |
Print Statement | What Would the Output look like | |
---|---|---|
Just words | ||
With a different Separator | ||
With a different End |