Lesson 1: Computational Thinking

Syed Faizan
PythonForKids
Published in
3 min readDec 19, 2018

The ability to identify patterns, decompose large problems into small parts, develop algorithms to solve problems, and generalize to find solutions.

Computational thinking matters because computer science and programming rely heavily on problem solving. Thinking like a computer, using computer science concepts that make computers possible, is one way to become an effective programmer and computer scientist.

Assume what would happen when you start designing a solution for a problem without knowing what the problem actually is. In CS, understanding the problem is 90% of the solution!

C omputational thinking helps you break down a problem and solve each part logically.

Let’s get started with it:

  • Break down the problem.
  • Find and identify any patterns in the problem.
  • Filter and prioritize information about the problem.
  • Design possible solutions.

Let’s get it practical:

Here goes the problem: 1, 2, A, 4, B, A, 7, 8, A, B, 11, A, 13, 14,AB…..

Step 1: Break It Down

There are 2 things in the problem, Numbers and Alphabets. But Numbers are in ascending order while alphabets are limited to (A and B only). Why is the AB together at the end of the problem statement.

Step 2: Find Patterns

i) A appears on every 3rd position

ii) B appears on every 5th position

iii) The numbers are basically the position value, see 1,2,A(3) then comes 4. followed by B(5),A(6) comes 7,8

Step 3: Prioritize or Validate your Theory

Does our defined patterns validate our story? Let’s focus on the last AB together. i) A appears on every 3rd Position ==> 1, 2, A(3), 4, B, A(6), 7, 8, A(9), B, 11, A(12), 13, 14,A(15) B

ii) B appears on every 5th position ==> 1, 2, A, 4, B(5), A, 7, 8, A, B(10), 11, A, 13, 14,A B(15)

Woah, !so our patterns pass the test with flying Colors, explaining Why A and B are together at the end!

Step 4: Design Possible Solution

1. Loop Through 1–n

2. Inside Loop, Check if (i comes in the table of 3(i%3==0)) THEN insert ‘A’

3. Inside Loop, Check if (i divided by 5 == 0)|(i%5 == 0) THEN insert ‘B’

4. If both conditions (2,3) fails then insert value of i

Here’s the Algorithm implemented in Code!
Output Matches! Woah!

Seeing the first error 😆. Code just has never to execute on its first time for experienced programmers too! 😜

--

--