Class Notes (839,096)
Canada (511,185)
CMPT 165 (21)


4 Pages

Computing Science
Course Code
CMPT 165
Colin Stewart

This preview shows page 1. Sign up to view the full 4 pages of the document.
Strings Strings are variables used to store characters letters digits punctuation spaces When writing the value of a string you use quotation marks Eg stofurkey Quotation marks indicate where a string begins and ends So what if you want to put quotation marks in a stringEscape Characters In order to do that you need to type a slash before the quotation markEg print they said hi to him Program output they said hi to him A slashin a string is always the start of a special character called an escape character n is a newline character Everything after it will appear on the next line down Eg print Youll neednChloroformnDuct tape Output Youll need Chloroform Duct tape t is a tab character an indentation eight spaces wide Eg print Youll needntChloroformntDuct tape Output Youll needChloroformDuct tapeis an actual slash character Eg print The files at CMedicineFungicides Output The files at CMedicineFungicides Note that to use escape characters they must always appear in a stringthat is inside quotation marks Eg print n ERROR print n correct Say you need to type a string that is too long to fit in the window That is you have to scroll horizontally to see the whole string To avoid having to scroll back and forth you can break up long strings into several smaller strings then join them together with theoperator Also to let Python know that the string continues on the next line down you need to use a backslashat the end of the lineExample Eg print A few of my favourite things ntWarm woolen mittens ntBright copper kettles ntBrown paper packages tied upwith string
More Less
Unlock Document

Only page 1 are available for preview. Some parts have been intentionally blurred.

Unlock Document
You're Reading a Preview

Unlock to view full version

Unlock Document

Log In


Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.