This uses python to make a fibonacci sequence

def fibonacci(n):
    numbers = []
    for i in range(n):
        if i == 0 :
            print("0")
            numbers.append(0)
        elif i ==1 :
            print("1")
            numbers.append(1)
        else:
            print(numbers[i-2] +numbers[i-1])
            numbers.append(numbers[i-1] + numbers[i-2])

fibonacci(10) # calls the function fibonacci and gives in 10
0
1
1
2
3
5
8
13
21
34

This also runs the fibonacci however in javascript

function fibonacci(n) {
    var numbers = []
    for (let i = 0; i < n; i++) {
        if (i===0) {
            numbers.push(0)
            console.log("0")
        } else if (i===1) {
            numbers.push(1)
            console.log("1")
        } else {
            numbers.push(numbers[i-2] + numbers[i-1])
            console.log(numbers[i-2] + numbers[i-1]) 
        }
    }
}
fibonacci(7)
0
1
1
2
3
5
8

This uses javascript and html to test for a palindrome

// <input type="text" id="input" placeholder="give palindrome" class="form-control"> <input type="text" id="text" placeholder="palindrome?" class="form-control">

<script>
var input = document.getElementById("input")
document.getElementById("input").addEventListener("change", Palindrome);
function Palindrome() {
    console.log(document.getElementById("input").value)
    const word = document.getElementById("input").value
    var reverse = ""
    for (var i = word.length - 1; i >= 0; i--) { 
        reverse += word[i]; 
    }
    console.log(reverse)
    if (reverse== word) {
        document.getElementById("text").value = "this is a palindrome"
    } else {
        document.getElementById("text").value = "this is not a palindrome"
    }
}

</script>

TRUTH TABLE

</div> </div> </div>
{/* <p id="text1" style="padding: 15px; line-height: 1.6; border: 1px solid white; width: 150px">
<script> */}
function truth(){
    var data = [[1,1], [1,0], [0,1], [0,0]];
    var text = ""
    for(let i =0; i < data.length; i++) {
        text += data[i][0] + "&" + data[i][1] + "-->" + (data[i][0] & data[i][1]).toString() + "<br>"
    }
    for(let i =0; i < data.length; i++) {
        text += data[i][0] + "|" + data[i][1] + "-->" + (data[i][0] | data[i][1]).toString() + "<br>"  
    }
    for(let i =0; i < data.length; i++) {
        text += data[i][0] + "^" + data[i][1] + "-->" + (data[i][0] ^ data[i][1]).toString() + "<br>"
    }
    let newdata = [1,0]
    for(let i =0; i < newdata.length; i++) {
        text += "~" + newdata[i] + "=" + ~newdata[i] + "<br>"
    }
    document.getElementById("text1").innerHTML = text
}
truth()

</script>

Come up with a Procedure/Function that show...

The function that I created is the truth function that generates a truth table using binary data

Data Abstraction

  • uses an array of arrays with binary data that will represent the rows in the truth table Procedural Abstraction
  • I made a truth function that runs an algorithm that populates the truth table, this can be called to multiple times because it is a function Algorithm using iteration and selection
  • I used multiple loops to parse through the binary data and evaluate the binary logic to determine whether the statements where true
  • if statements can be used to check if the binary logic was true or not Frontend / Backend, using an API and persistent storage
  • made html text box that was populated by the javascript
</div>