Outline

main_lesson_page_planning_720

Speaker Roles:

Binary: Ananya Truth Tables: Theo Binary Conversions: Samarth Binary Search: Haseeb Hacks: Ava and Alexa (recording)

Grading Plan:

Hacks: total 1/1

notetaker: 0.1 Quiz: 0.2 conversions practice: 0.3 binary search questions: 0.3

for conversions and binary search: if incorrect but completed= 0.2 each if any section not complete= no points

extra credit opportunity: translate to octal (show work and explain thought process so no translator) 0.1

Binary

What is Binary?

  • According to Computer Hope: Binary is a base-2 number system invented by Gottfried Leibniz that's made up of only two numbers or digits: 0 and 1. This numbering system is the basis for all binary code, which writes digital data such as the computer processor instructions used with your devices every day.

  • 0 = represents OFF

  • 1 = represents ON

Fun Fact! Connections with Binary

power button

Do you see how the iconic power button is comprised of a zero and a one? The zero represents the device being off, and the one represents the device being on.

Counting with Binary

Boolean Expressions

definition here

How is Binary Related to Boolean Expressions?

Binary and Boolean expressions are closely related because Boolean expressions are typically used to evaluate binary values, which can either be true or false (1 or 0).

Binary values are used to represent information. Boolean expressions are used to express the logical operations performed on these binary values(AND, OR, and NOT).

Operator Logical Operation
and Conjunction
or Disjunction
not Negation

Truth Tables

Truth tables represent the possible inputs and outputs of the logical operations of AND, OR, and NOT.

5 > 3 and 5 == 3 + 2
True
5 < 3 and 5 == 5
False
5 == 5 or 5 != 5
True
5 < 3 or 5 != 5
False
inputs = [(0, 0), (0, 1), (1, 0), (1, 1)]

# Define the functions
def logical_and(a, b):
    return a and b

def logical_or(a, b):
    return a or b

def logical_not(a):
    return not a

print("AND:")
for a, b in inputs:
    result = logical_and(a, b)
    print(f"{a} AND {b} = {result}")
print("OR:")
for a, b in inputs:
    result = logical_or(a, b)
    print(f"{a} OR {b} = {result}")
AND:
0 AND 0 = 0
0 AND 1 = 0
1 AND 0 = 0
1 AND 1 = 1
OR:
0 OR 0 = 0
0 OR 1 = 1
1 OR 0 = 1
1 OR 1 = 1

Real life examples

The following examples use boolean expressions to decide whether someone is eligible to vote or not (true= old enough, false= not old enough)

age = 18
citizen = True

if age >= 18 and citizen:
    print("You are eligible to vote.")
else:
    print("You are not eligible to vote.")
You are eligible to vote.