ITP 115 Lecture Notes - Lecture 3: Access Granted, Order Of Operations, Boolean Expression
Document Summary
Recall: python has 2 types of variables to store numbers. Float: we can do mathematical operations with each. Only gives us the whole integer of how many times 3 goes into 7. Helpful for determining if a number is even (mod by 2, and if output is 0, then it"s even) 7**3 gives us 2401 (7*7*7: floats (real numbers) General rules: with many operations, they work as you"d expect. Makes it a float (easier to convert an int into a float) 4//3 1 (int//int int: true division. Result is always float regardless of input type. Truncates decimal part of answer int//int int float//float float float//int float. Modulo operator (%: modulo (modulus, mod for short) gives remainder of division, e. g. 14 divided by 4 is 3 with remainder of 2. Determining if 1 integer is evenly divisible by another integer. Arithmetic operations: only work in pairs. Expressions w/more than 2 operators are really a series of steps and only 2 operands.