Mega-Zesty-Yeungs-MZY / zest

0 stars 0 forks source link

Mega Yeungs: A Guide to Binary Math, truth tables and logic (some code and hacks to be provided) (Big Idea 2) #2

Open dillonlee06 opened 1 year ago

dillonlee06 commented 1 year ago

Varalu, Harsha, Emaad, Ryan

dillonlee06 commented 1 year ago

Scrum Board

2.1 done by April 7

Emaad-Mir commented 1 year ago

Progress Check for Binary Math (As of 3/26/23)

def convertToBinary(n):
    # b represents the binary number
    b = ""

    # n represents the decimal number that will be converted into the binary number
    while n > 0:

    # r represents the remainder
        r = n % 2
        b = str(r) + b
        n = n // 2
    return b.zfill(8)

n = int(input("What decimal number would you like to convert to binary?"))
print("User input: ", n)
b = convertToBinary(n)
print("The number {} in binary is {}".format(n,b))
def convertToDecimal(b):
    # n represents the decimal number
    n = 0

    # p represents the position (power) of the binary digit (2 raised to the 0, to the 1st, to the 2nd, etc.)
    p = 0

    # goes through the binary digits from right to left
    for digit in reversed(b):
        if digit == '1':
            n += 2 ** p
        p += 1

    return n

b = input("What binary number would you like to convert to decimal? ")
print("User input: ", b)
n = convertToDecimal(b)
print("The number {} in decimal is {}".format(b, n))

Plans for Next Week

Emaad-Mir commented 1 year ago

Lesson Plans for Big Idea 2

Binary Math

Truth Tables

Logic Gates

nVarap commented 1 year ago

https://github.com/nVarap/blog/issues/21

^ Review ticket