To Home Page

IT 212 -- Project 1

Bitwise Operations

  1. Convert the integers 57 and 123 into one byte binary and hex. Show your work. Call the resulting hex values a and b.
  2. Compute the values of these Python Expressions:
    a | b   a & b   a ^ b
    
  3. Convert the results from Part 2 to hex and decimal. Show your work.
  4. Write a Python script to verify the calculations in parts 2 and 3. Use the Bitwise Example to help you.
  5. The file quiz-scores.bin in the zip file quiz-scores.zip contains records with three fields each:

    Field Name Format Size
    first_name ASCII Code 8 bytes
    student_id Packed Decimal 4 digits representing decimal digits (2 bytes)
    quiz_answers Bit String
    0 means F, 1 means T.
    5 bits with 3 padding bits (1 byte)

    Use the hex dump utility to interpret the data in quiz-scores.bin.
    Here is a sample hex dump and interpretation of one record:
    > py hexdump.py examp.bin
    00000 41 6c 69 63 65 20 20 20 12 34 68
           A  l  i  c  e          ^R  4  h
    
    You can also redirect the dump from the Command Prompt Window to an output text file like this:
    > py hexdump.py examp.bin > dump.txt
    
    Here is the hex dump for quiz-scores.bin in case you have trouble running hexdump.py and saving the output.

    Include this dump in your submission for Project 1. Here is the interpretation of the hex dump for Alice:

    Interpretation:
    Field 1 (first_name): 41 6c 69 63 65 20 20 20
    8 bytes: ASCII codes for Alice padded with three spaces.
    Field 2 (student_id): 12 34
    2 bytes: The student id 1234 which consists of 4 packed decimal digits.
    Field 3 (quiz_answers): 68 = 01101000
    1 byte: 01101 represents the answers to a true/false quiz F,T,T,F,T, with 3 zero bits of padding.
  6. Grading:  10 points per question; Show your work for each question; Submitted Correctly: 10 points.
  7. Check the Project Submission Guidelines before submitting your project.