Skip to content

Unit 3 Lesson 16 Learning Resources #2

Description

@shruthim0

run this: wget https://raw.githubusercontent.com/shruthim0/datapirates/master/_notebooks/2022-12-12-hw.ipynb

Binary Hack EXPLANATION

Using Binary for Simulations

Now you will combine everything we have talked about so far, plus binary. Imagine that there is a zombie apocalypse. A household with 8 survivors is observed. Let's create a simulation where we see how many of the people have been transformed into zombies. This will involve three functions.

  1. FIrst, a function for randomizing decimal number 0-255
  2. Next, a function for converting this to a 8-bit binary number (one bit per person)
  3. Lastly, a function to read the binary bits, and assign each person a label (zombie or naw) based on the position of 0s and 1s

THe amount of people who are zombies is randomly determined. Based on the placement of the 1s and 0s in the 8 bit number, each person is assigned as being a zombie or not
Binary Hack ANSWER

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions