Main Page Code for Tri 3 Team Project
Code and ideas for main page Tri 3 Project
- Outline
- Binary
- Boolean Expressions
- How is Binary Related to Boolean Expressions?
- Truth Tables
- Real life examples
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
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.
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
5 < 3 and 5 == 5
5 == 5 or 5 != 5
5 < 3 or 5 != 5
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}")
age = 18
citizen = True
if age >= 18 and citizen:
print("You are eligible to vote.")
else:
print("You are not eligible to vote.")