Section Summary
Last updated
Was this helpful?
Last updated
Was this helpful?
The print() function
is a built-in function. It prints/outputs a specified message to the screen/console window
Built-in functions, contrary to user-defined functions are always available and dont have to be imported. Python 3.8 comes with 69 built-in functions. You can find the full list in alphabetical order in the
To call a functions (function invocation) you need to use the function name followed by parentheses. You can pass arguments into a function by placing them inside the parentheses. You must separate arguments with a comma. print ("Hello" , "world!")
. An "empty" print ()
function outputs an empty line to the screen
Python strings are delimited with quotes (single or double) "I am a string"
or 'I am a string'
Computer programs are collections of instructions. An instruction is a command to perform a specific task when executed. eg. to print a certain message to a screen
In Python strings, the backslash (\)
is a special character which announces the next character has a different meaning. eg \n
(the newline character) starts a new output line
Positional arguments are the ones whose meaning is dictated by their position. eg, the second argument is outputted after the first, the third is outputted after the second etc
Keyword arguments are the ones who's meaning is not dictated by their location, but by a special word (keyword) used to identify them
The end
and sep
parameters can be used for formatting the output of the print ()
function. The sep
parameter specifies the separator between the outputted arguments.
eg. print ("H", "E", "L", "L", "O", sep="-")
H-E-L-L-O
eg print ("Game over", "Want to Play Again?" , end=" ")
print ("Select", "Yes or No")
Game over Want to Play Again? Select Yes or No