
Modulus Operator - CS101 - Udacity
Modulus Operator - CS101 - Udacity
Other units in this course below:
Unit 1: • เพลย์ลิสต์
Unit 2: • เพลย์ลิสต์
Unit 3: • เพลย์ลิสต์
Unit 4: • เพลย์ลิสต์
Unit 5: • เพลย์ลิสต์
Unit 6: • เพลย์ลิสต์
Unit 7: • เพลย์ลิสต์
Q\u0026A: • เพลย์ลิสต์
To gain access to interactive quizzes, homework, programming assignments and a helpful community, join the class at http://www.udacity.com
Content
0 -> [Evans] To get our outputs in the correct range,
3 -> we're going to use the modulus operator.
6 -> This is written with a percent sign.
8 -> It's usually the Shift 5 on most keyboards.
11 -> What modulus does is takes a number and maps it to the range
16 -> based on the remainder when you divide that number.
19 -> The way modulo arithmetic works is like a clock,
23 -> so if we think of having a clock with 12 hours
26 -> and then arithmetic on the clock is modulo 12.
30 -> If we were to evaluate 14 % 12, what that would mean is if you start from 0
39 -> and we make 14 steps--we're going to go 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14--
48 -> where we end up is 2.
50 -> That's the same as the remainder we would get by dividing 14 by 12,
55 -> and that's the result of 14 % 12 is 2.
59 -> So now we're going to have a few quizzes
61 -> to make sure that you understand the modulus operator
63 -> as well as the ord and chr operators we introduced.
Source: https://www.youtube.com/watch?v=MrTtsX2Wg9Q