Hacks

Review each of the sections above and produce …

  1. A function that takes in 2 variables and adds, subtracts, multiplies, dividies, and mods the two numbers
  2. Use an algorithm to find certain values of the Fibonacci sequence. For example, your code should output the nth index in the sequence. An example of how the sequence works is 0,1,1,2,3,5,8,13. The pattern is you add the previous 2 numbers together to get the new number.
a, b = 11, 0

Add = a + b
Subtract = a - b
Multiply = a * b
Divide = a / b if b != 0 else 'undefined'

print(f"Add: {Add}")
print(f"Subtract: {Subtract}")
print(f"Multiply: {Multiply}")
print(f"Divide: {Divide}")
Add: 11
Subtract: 11
Multiply: 0
Divide: undefined
def fibonacc(n):
    if n <= 0:
        return "invalid"
    elif n == 1:
        return 0
    elif n == 2:
        return 1
    else:
        return fibonacc(n - 1) + fibonacc(n - 2)


n = 10 
print(f"The {n}th Fibonacci number is: {fibonacc(n)}")
The 10th Fibonacci number is: 34
    <script src="https://utteranc.es/client.js"
        repo="manas12709/portfolio_2025"
        issue-term="pathname"
        label="utterances"
        theme="github-light"
        crossorigin="anonymous"
        async>
    </script>