CSC108H1 Lecture Notes - Lecture 1: Decimal Mark, Logical Form
yifanyang and 39659 others unlocked
21
CSC108H1 Full Course Notes
Verified Note
21 documents
Document Summary
[gcc 4. 2. 1 (apple inc. build 5666) (dot 3)] Python type help, copyright, credits or license for more information. # 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)