Back

Printing and comments - Answers

Q1. Type the code in.
Q2. Pairs of single quotes be used in the same way as pairs of double quotes for printing, but you can't use one single and one double quote!
Q3. To print the word don't, either use double quotes, or use the backslash just before the ' like this don\'t.
Q4. To force the cursor to stay on the same line at the end of printing a line, put a common after the end single or double quote, followed by end=' ' .
Q5. The backslash is easily confused with the forward slash.
Q6. You can force the cursor to move along to the next tab position by using \t.
Q7. To move the cursor down three lines, use print('\n\n\n').
Q8. To display a backslash, precede it with a backslash i.e. \\.
Q9. To display a piece of ASCII art, for example, surround the printing block with three double quotes or three single quotes. This tells Python to ignore its normal rules for whitespace and new lines.
Q10. You can use three single quotes as well as three double quotes to display blocks of characters.
Q11. To add a comment to the top of a program, you precede each line of comments with the hash symbol #.
Q12. To add a comment to the right of a single line of code, you just tab along a bit from the end of the line and then type the hash symbol # followed by your comment.
Q13. To add a block of comments e.g. across a number of lines at the top of a program, just surround the block of comments befroe and after with three double quotes or three single quotes.

Extension task
Seach Google for Python 3 escape sequence to find out about the other escape sequence charaters that you can use in Python.

Back