CSC108H1- Midterm Exam Guide - Comprehensive Notes for the exam ( 13 pages long!)

450 views13 pages
5 Oct 2017
School
Course
yifanyang and 39659 others unlocked
CSC108H1 Full Course Notes
21
CSC108H1 Full Course Notes
Verified Note
21 documents

Document Summary

# when writing programs, we want to put in english languages explanations. Whatever comes after # symbol is not evaluated. # two types: int (numbers without fractional parts), float. # float = floating-point (numbers that may have a fractional part) # division (/) produces a float result since answer might not be int. # to get an int result use integer division ( // ) # 8 divided by 5 is 1 with a remainder of 3. # to get the remainder, use the remainder (or modulus) operator: % 2 ** 5 # 2 to the power 5. # (1) n % 2 is 0 for even numbers. # (2) n % 2 is 1 for an odd number. # x / y = q * y + r, q = (x // y), r = (x % y) # *, /, //, % (left to right)