Game Development Reference
In-Depth Information
5 - Jokes
to the previous line, instead of on its own line. There was no newline printed after the
'Interrupting cow wh' string.
Summary
This chapter briefly covered how software (including our Python programs) runs on your
computer. Python is a higher-level programming language that the Python interpreter (that
is, the Python software you have downloaded and installed) converts into machine
language. Machine language are the 1s and 0s that make up instructions that your computer
can understand and process.
The rest of this chapter explores the different ways you can use the print() function.
Escape characters are used for characters that are difficult or impossible to type into the
code with the keyboard. Escape characters are typed into strings beginning with a backslash
\ followed by a single letter for the escape character. For example, \n would print out a
newline. To display a backslash, you would use the escape character \\.
The print() function automatically appends a newline character to the end of the
string we pass it to be displayed on the screen. Most of the time, this is a helpful shortcut.
But sometimes we don't want a newline character at the end. To change this, we pass the
end keyword argument with a blank string. For example, to print "spam" to the screen
without a newline character, you would call print('spam', end='') .
By adding this level of control to the text we display on the screen, we have much more
flexible ways to display text on the screen the exact way we want to.
Search WWH ::




Custom Search