{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


Week_6_Mice_NestedLoops - CMPT120 J Ye Nested Loops...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
CMPT120 J. Ye Nested Loops & Miscellaneous Stuff ( Week 6 ) Miscellaneous Stuff: more assignment operators escape sequences id and help functions more about docstrings Nested Loops CMPT120 J. Ye 1 Often we perform an operation on a variable, and then store the result back into that variable. Some assignment operators can be used to do this. For example, the statement num += count is equivalent to num = num + count 2 More Assignment Operators
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CMPT120 J. Ye The following are all assignment operators: 3 Operator += -= *= /= %= Example x += y x -= y x *= y x /= y x %= y Equivalent To x = x + y x = x - y x = x * y x = x / y x = x % y More Assignment Operators (cont) In Python, double quotes or single quotes enclose a string (object). What if we want to print the quote character? The following line would confuse Python because it would interpret the second quote as the end of the string print("I said "Hello" to you.") # not ok An escape sequence is a series of characters that represents one single special character An escape sequence begins with a backslash character ( \ ) print("I said \"Hello\" to you.") # ok 4 Escape Sequences
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}