CSCA08H3 Lecture 2: CSC108 - Week 2 Notes
Document Summary
However, you"re so cold" will return a syntaxerror since the internal single quote prematurely ends the string. This can be xed by changing the containing quotes to double quotes: you"re so cold . Alternatively an escape character/sequence can be used. You\"re so cold. " will return you"re so cold. Cannot add a str to an int or a oat (returns typeerror). Even if the int or oat is in quotations (because that makes it a str like 5"): eg. personal" + penguin" returns personalpenguin". Spaces have to be included in the quotes (eg. personal + penguin" returns personal penguin"): you can also link variables that refer to strings. Example: name = alex" phrase = watch out" punctuation = !" name + phrase + punctuation returns alex watch out!". Strings can be multiplied by ints ( oats or str"s will return typeerrors): eg. ha" * 5 returns hahahahaha", order of operations still takes precedence. Bwa" + ha" * 5 returns bwahahahahaha".