Intro to CS: Lecture 4 - Loops over strings, guess-and-check, and binary
This lecture explains iteration in simple programs like guess-and-check, binaries, and fractions in Python. Loops can iterate over any sequence of values including a range for numbers or a string. Guess-and-check provides a simple algorithm for solving problems. When the set of potential solutions is enumerable, exhaustive enumeration is guaranteed to work (eventually). Binary numbers help us understand how the machine works. Converting to binary will help us understand how decimal numbers are stored
Guess and check algorithms, and use of boolean flags is covered. Can’t use equal sign between floats due to approximation error. Dealing with floats as transaction amounts for a fintech company I worked for, this concept was applied.
Overall it was a review lecture for me. I guess one new thing I learned was the algorithm for converting a decimal integer to a binary number. Or I probably learned it before but forgot it. It basically checked if the number was odd or even, if odd, add 1 to the left of the string, otherwise add 0, then divide number by 2 and repeat process. The finger exercise was easy.
On to the next lecture.