Overview
This week we will complete Chapter 7 - Computers can Repeat Steps where we will learn about Python's for loops, range() function, and lists.
Thursday, October 20th
Classwork
After the earthquake drill today, we will have a short quiz, which will be returned immediately and discussed.
Homework
Complete as many of the Chapter 7 Exercises as your 90 minutes of homework time allow.
This assignment is due Sunday, October 23 at 11:59 am (by popular demand).
Shout Outs
Tuesday, October 18th
Classwork
We'll start today going over the homework, focusing on any questions you have about the assigned problems. Please ask questions if you have them, because similar questions will appear on your next quiz.
The rest of class time will be spent discussing number systems, particularly the ones of importance to computer science: binary numbers and hexadecmial numbers.
We'll begin with the following problems concerning binary numbers:
- Computer systems use binary numbers to represent data that it processes.
If it has a number in memory represented by the binary number
0010 1001
, and it is processing an instruction to add the decimal number 21 to it, what is the resulting number in binary format? - When designing a web page, you see a color you want to use listed in
binary as:
00101110
,10001011
,01010111
. Which color is it, given the decimal equivalents (red, green, blue)? - Using Wikipedia's Web colors entry as a resource, what would be the 24-bits of the color Hot Pink?
- A certain programming language uses 4-bit binary sequences to represent
nonnegative integers. For example, the binary sequence
0101
represents the corresponding decimal value 5. Using this programming language, a programmer attempts to add the decimal values 14 and 15 and assign the sum to the variable total. Which of the following best describes the result of this operation?- The correct sum of 29 will be assigned to the variable total.
- An overflow error will occur because 4 bits is not large enough to represent either of the values 14 or 15.
- An overflow error will occur because 4 bits is not large enough to represent 29, the sum of 14 and 15.
- A round-off error will occur because the decimal values 14 and 15 are represented as approximations due to the fixed number of bits used to represent numbers.
- Order the following numeric values:
- Binary 1011
- Binary 1101
- Decimal 5
- Decimal 12
- Consider the 4-bit binary numbers
0011
,0110
, and1111
. Which of the following decimal values is NOT equal to one of these binary numbers?- 3
- 6
- 9
- 15
Solutions to the first two of these problems can be found here. Please make sure you understand these solutions, since similar problems will henceforth be considered fair game for quiz questions.
Homework
Read
Chapter 7 - Computers can Repeat Steps, taking notes in a file named
ch07_notes.md
in your git repo.
This assignment is due Wednesday, October 19 at 7 pm.
Shout Outs
Shout outs to
Jack,
Sean,
Xander,
Blu,
Toby,
Evan,
Lary,
Grant,
Jake and
Ronan,
for maintaining well organized git repos. By well organized
I
mean they make effective use of subdirectories and have consistent naming
conventions, making it easier to find what you're looking for.