CMPT 120 Lecture Notes - Lecture 7: Concatenation, Exponentiation, Init

17 views6 pages
meghan78 and 39786 others unlocked
CMPT 120 Full Course Notes
29
CMPT 120 Full Course Notes
Verified Note
29 documents

Document Summary

2 * (3-1) = 2 * 2 = 4: exponentiation has the next highest precedence. 1* 2**3 = 1*8= 8: multiplication and both division operators have the same precedence, which is higher than addition and subtraction. 5 -2*2 = 5-4 = 1: operators with the same precedence (except for **) are evaluated from left to right. If the operations had been evaluated from right to left, it would have been 1. Ex. print ( 2 ** 3 ** 2) -> right to left. Ex. print ((2 ** 3) ** 2) -> parenthesis first. 2 * 5 = 10 / 3 = 3 (integer value rounds down always) The indexing operator (python uses square brackets to enclose the index) selects a single character from a string. The characters are accessed by their position or index value. Example: school = sfu m = school[2] print(m) -> t will be the result. The expression in brackets is called an index.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions