There are several full length programs in the book. I would like
you to copy these pieces of code and get them to run. Your code must
have the following template:
# the body of the program
Each program will be in a file by itself with .py extension. You
must make sure that it runs as shown in the book. These programs
do NOT have to be turned in. However, you are likely to see
variations of these programs in the quizzes.
- Listing 2.2: ComputeAreaWithConsoleInput.py
- Listing 2.3: ComputeAverage.py
- Listing 2.4: ComputeAverageWithSimultaneousAssignment.py
- Listing 2.5: DisplayTime.py
- Listing 2.6: SalesTax.py
- Listing 2.7: ShowCurrentTime.py
- Listing 2.8: ComputeLoan.py
- Convert the following numbers in decimal to 8-bit 2's complement
binary: 28, -39
- Write the binary equivalent of all numbers from 0 to 15 in 4-bit
- These are 8-bit 2's complement binary. What decimal numbers do
- 0110 1100
- 1111 1111
- 1000 0000
- 0111 1111
- Convert the following numbers to unsigned binary, octal,
and hexadecimal: 25, 32, 67, 96.
- Convert these numbers in octal to binary, decimal, and
hexadecimal: 672, 215.
- Convert these hexadecimal numbers into binary, octal, and
decimal: 2A5, D0C.
- The hexadecimal number B4 is a 2's complement number in 8-bit
binary. Convert it to decimal.
- Add 3D and F5 and express the answer in octal.
- Add 517 in octal to 3A in hexadecimal and express the answer
in decimal. [Hint convert both numbers to binary and add.]
- Add the following 2's complement 8-bit numbers: 1011 1001 and
1110 0110. Ignore the overflow bit. Express the answer in decimal.