CSC 1200 Lecture Notes - Lecture 5: Negation, Ator, Exponentiation

10 views11 pages
2 Apr 2023
School
Course
Professor

Document Summary

Operators are used to perform operations on variables and values. In the example below, we use the + operator to add together two values: Get your own python server print(10 + 5) Python divides the operators in the following groups: Arithmetic operators are used with numeric values to perform common mathematical operations: Assignment operators are used to assign values to variables: Try it x = 5 x = 5. Try it x += 3 x = x + 3. Try it x -= 3 x = x - 3. Try it x *= 3 x = x * 3. Try it x /= 3 x = x / 3. Try it x %= 3 x = x % 3. Try it x //= 3 x = x // 3. Try it x **= 3 x = x ** 3. Try it x &= 3 x = x & 3. Try it x |= 3 x = x | 3.