How to think like a programmer easy.pptx

arnavalt9 13 views 16 slides Sep 15, 2024
Slide 1
Slide 1 of 16
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16

About This Presentation

A ppt on how to think like a programmer


Slide Content

How to think like a programmer A programmers guide

Know what you want to make It may vary, but right now, we want something to make that will make you think like a programmer. So we will make a code that prints out the Fibonacci Series

Fibonacci Series Invented back in 200 BC, a work by Pingala and named after a Italian Mathematician called Leonardo of Pisa aka, Fibonacci. Leonardo of Pisa Pingala

What is Fibonacci Series? By definition, the Fibonacci series is a sequence of the 2 preceding numbers, starting from 0 and 1. So, 0 + 1 = 1 As the sum is 1, we will add it to the second number, 1- 1 + 1 = 2 As the sum is 2, we will add it to the second number, 1- 2 + 1 = 3 As the sum is 3, we will add it to the second number, 2- 3 + 2 = 5 And so on

Why is it special? These squares have their side length as their Fibonacci number. Notice something

Why is it special? It has the same pattern as the special number, Φ (phi) or otherwise known as the, “Golden Ratio”

IT’S EVERYWHERE

So how do we write the Fibonacci Series Know the steps of thinking like a programmer. Understand the problem Reframe it in programming terms Understand logic Refine your logic until it is perfect Code

The problem is to Find the next number by summing up the previous 2 numbers.

Reframe it in programming terms Take the sum of the current sum and the previous number.

Understand the logic Take the sum of the current sum and the previous number. We can use variables to do so.

Understand the logic a+b =c b+c =d c+d =e So on and on and on.

Refine the logic a+b =c b+c =d c+d =e So on and on and on. But this will take like a million variables. So maybe something simpler?

Refine the logic What about this? a+b =c Change the value of a to b, and the value of b to c a+b =c Repeat the loop

Much simpler right? What about this? a+b =c Change the value of a to b, and the value of b to c a+b =c Repeat the loop

Let’s code
Tags