CODING - Thinking Like a Computer

Coding is the art of giving precise instructions to a machine. But more fundamentally, it is a way of thinking — breaking complex problems into small, logical steps, expressing ideas with clarity, and building solutions that can be tested and improved. This course introduces the foundations of programming: logic, variables, loops, functions, data structures, and computational thinking — skills that apply across every programming language and discipline.

Course Progress

0 of 12 lessons completed

0% Complete

Lesson 1: What is Coding? — Algorithms and Computational Thinking

Coding is the process of writing instructions for a computer to follow. But before you write a single line of code, you need to think computationally — breaking a problem down into a sequence of precise, unambiguous steps that a machine can execute. An algorithm is exactly this: a finite, ordered set of instructions for solving a problem. Algorithms have three key properties: they must be precise (no ambiguity), finite (they must eventually end), and effective (they must actually solve the problem). Computers are extraordinarily fast and accurate at following instructions, but they have no common sense — they do exactly what you tell them, no more and no less. This means the most important skill in coding is not typing fast or memorising syntax; it is thinking clearly and precisely. Computational thinking involves four processes: decomposition (breaking problems into smaller parts), pattern recognition (spotting similarities), abstraction (ignoring irrelevant detail), and algorithmic thinking (creating step-by-step solutions).

💡 Think of it this way:

Writing an algorithm is like writing directions for someone who is perfectly obedient, perfectly literal, and has absolutely no common sense. If you write 'turn left at the traffic lights' and there are no traffic lights, they stop and wait forever. Precision is not optional — it is the entire job.

✨ Example:

Algorithm to make a cup of tea: (1) Fill kettle with water. (2) Switch kettle on. (3) Wait until water boils. (4) Place teabag in cup. (5) Pour boiling water into cup. (6) Wait 3 minutes. (7) Remove teabag. (8) Add milk if desired. Each step is unambiguous and must happen in order. A computer would need this level of detail for every task.

Lesson 2: Variables and Data Types — Storing Information

A variable is a named container in a program's memory that stores a value. You can think of a variable as a labelled box: you give it a name and put something in it. The value can change as the program runs — hence the name 'variable.' Every variable has a data type, which determines what kind of information it can hold. The most common data types are: integers (whole numbers: 5, −3, 100), floats or decimals (numbers with decimal points: 3.14, −0.5), strings (sequences of characters — text: 'hello', 'Priya', '42'), booleans (true or false — used for logical conditions), and lists or arrays (ordered collections of values). Choosing the right data type matters — a phone number stored as an integer would lose leading zeros and prevent string operations. Naming variables clearly is a professional habit: 'studentAge' is far better than 'x' or 'data1'. Well-named variables make code readable by other humans, which is just as important as making it readable by a machine.

💡 Think of it this way:

A variable is like a labelled jar in a kitchen. The label tells you what belongs inside (the variable name and type), and the contents can change over time — today the jar has sugar, tomorrow it might have flour. The label stays the same; the contents evolve.

✨ Example:

In Python: name = 'Aanya' stores the string 'Aanya' in a variable called name. age = 12 stores the integer 12. height = 1.52 stores the float 1.52. is_student = True stores a boolean. If the student has a birthday: age = age + 1 (now age is 13). The variable updates; the name stays the same.

Lesson 3: Input, Output, and Basic Operations

All programs, at their core, take input, process it, and produce output. Input is data provided to the program — from a user typing, a file being read, a sensor, or another program. Processing is what the program does with that data — calculations, comparisons, transformations. Output is the result — printed to a screen, written to a file, sent to another device. In most programming languages, getting input from a user and printing output to a screen are among the first things you learn. Arithmetic operators in code correspond to mathematical operations: + for addition, - for subtraction, * for multiplication, / for division, and ** for exponentiation in many languages. The modulo operator % gives the remainder after division — 17 % 5 = 2, because 5 goes into 17 three times with 2 left over. String operations allow you to join (concatenate) strings, find their length, and extract substrings. Understanding input/output and basic operations is the foundation of every program you will ever write.

💡 Think of it this way:

A program is like a machine in a factory. Raw materials (input) go in one end. The machine processes them according to its design. A finished product (output) comes out the other end. Change the machine's design (the code) and the same input produces a different output.

✨ Example:

In Python: name = input('What is your name? ') gets a name from the user. age = int(input('How old are you? ')) gets their age as an integer. print('Hello, ' + name + '! In 10 years you will be ' + str(age + 10) + ' years old.') produces a personalised output. This tiny program contains input, processing (arithmetic), type conversion, and output — all the fundamentals.

Lesson 4: Conditionals — Making Decisions in Code

Conditionals allow a program to make decisions — to execute different code depending on whether a condition is true or false. The fundamental conditional structure is the if/else statement: IF a condition is true, DO this; ELSE, DO that. Conditions are expressed using comparison operators: == (equal to), != (not equal to), > (greater than), < (less than), >= (greater than or equal to), <= (less than or equal to). Multiple conditions can be combined using logical operators: AND (both conditions must be true), OR (at least one must be true), NOT (inverts the condition). More complex decision trees use elif (else if) to test multiple conditions in sequence. Conditionals are everywhere in real programs — from checking a user's password to deciding what content to display, from validating a form to determining a game's outcome. Every branch in a conditional represents a path the program might take, depending on the state of the world at that moment.

💡 Think of it this way:

A conditional in code is like a fork in a road with a signpost. The signpost checks a condition ('Is it raining?') and directs you accordingly: if yes, take the sheltered path; if no, take the scenic route. The program always takes exactly one of the available paths based on the current conditions.

✨ Example:

In Python: if score >= 90: print('A grade') elif score >= 70: print('B grade') elif score >= 50: print('C grade') else: print('Below passing'). The program evaluates each condition in sequence, executes the first true branch, and skips the rest. Every score will produce exactly one output.

Lesson 5: Loops — Repetition Without Repetition

Loops allow a program to repeat a block of code multiple times — either a fixed number of times, or until a condition is met. Without loops, you would have to write the same lines of code over and over. There are two main types. A 'for' loop iterates a specific number of times, often over the items in a list or sequence: 'for each item in this list, do this.' A 'while' loop continues executing as long as a condition remains true: 'keep doing this while this is still true.' Loops can be nested — a loop inside a loop — which is useful for working with grids or matrices. An infinite loop is a loop that never ends (usually a bug — caused by a while condition that can never become false). A 'break' statement can exit a loop early; a 'continue' statement skips the current iteration and moves to the next. Loops are one of the most powerful constructs in programming — they transform what would require thousands of lines into a handful.

💡 Think of it this way:

A loop is like a chef following a recipe instruction that says 'repeat the following step for each guest.' Rather than writing separate instructions for each person, one instruction applies to all. The loop handles the repetition; the programmer just defines the pattern once.

✨ Example:

In Python, to print the numbers 1 to 5: for i in range(1, 6): print(i). The loop runs 5 times — i takes values 1, 2, 3, 4, 5 in sequence. Without the loop, you'd write 5 separate print statements. For 1,000 numbers, the loop still takes exactly 2 lines. This is the power of iteration.

Lesson 6: Functions — Writing Reusable Code

A function is a named, reusable block of code that performs a specific task. Instead of writing the same logic repeatedly in different parts of a program, you define it once as a function and call it whenever needed. A function is defined with a name, optional parameters (inputs the function receives), a body (the code it executes), and optionally a return value (the result it sends back). Functions support the principle of DRY: Don't Repeat Yourself. They also make code modular — each function does one thing, and the program is built from these building blocks. Functions can call other functions. The built-in functions provided by a programming language (like Python's print(), len(), and input()) are themselves functions someone else wrote for you to use. Writing your own functions is one of the most important habits in programming — it makes code easier to write, easier to read, easier to test, and easier to fix.

💡 Think of it this way:

A function is like a vending machine. You choose a product (call the function by name), insert the required input (parameters), and receive a defined output (return value). You don't need to know how the machine works inside — only what you put in and what you get out. The internal mechanism is abstracted away.

✨ Example:

In Python: def calculate_area(length, width): return length * width. Calling area = calculate_area(5, 3) returns 15. Calling area = calculate_area(10, 4) returns 40. The same function works for any rectangle. Without a function, you'd write length * width every time — the function names the operation, making the code self-documenting.

Lesson 7: Lists and Data Structures — Organising Information

A data structure is a way of organising and storing data so that it can be accessed and modified efficiently. The simplest and most commonly used data structure is the list (also called an array). A list is an ordered collection of items, stored under a single variable name, accessed by their index (position). Lists are zero-indexed in most languages — the first item is at index 0. Lists can contain any data type, including other lists. Common list operations include: appending items, removing items, accessing by index, slicing (extracting a portion), sorting, and finding the length. Beyond lists, other important data structures include: dictionaries (key-value pairs — like a real dictionary, where you look up a word to find its definition), tuples (immutable ordered collections), and sets (unordered collections of unique items). Choosing the right data structure for a problem significantly affects how elegant, readable, and efficient your solution is.

💡 Think of it this way:

A list is like a numbered row of lockers. Each locker is identified by its number (index), and you can put anything in any locker. Adding a new locker at the end is easy. Looking up locker number 5 is instant. Without lockers, you'd have to leave items in a heap on the floor and search through the pile every time.

✨ Example:

In Python: fruits = ['apple', 'banana', 'mango', 'cherry']. fruits[0] returns 'apple'. fruits[-1] returns 'cherry' (last item). fruits.append('grape') adds 'grape' to the end. len(fruits) returns 5. for fruit in fruits: print(fruit) prints every item. Lists are the backbone of most real-world programs.

Lesson 8: Debugging — Finding and Fixing Errors

Debugging is the process of finding and fixing errors (bugs) in code. Every programmer, at every level of experience, encounters bugs — the question is how efficiently you can locate and correct them. There are three types of errors. Syntax errors occur when the code breaks the rules of the language — missing brackets, incorrect indentation, misspelled keywords. The interpreter or compiler catches these before the program runs. Runtime errors occur while the program is running — trying to divide by zero, accessing a list index that doesn't exist, or calling a function with the wrong number of arguments. Logical errors are the trickiest: the program runs without crashing, but produces the wrong answer — because the logic is flawed. Debugging strategies include reading error messages carefully (they usually tell you the line and type of error), using print statements to track variables' values, testing with simple inputs first, isolating the problem by commenting out sections, and using a debugger tool. Good debugging is a mindset: systematic, curious, and patient.

💡 Think of it this way:

Debugging is like being a detective in your own crime scene. The crime is the wrong output. The evidence is the error messages, the variable values, the lines of code. Your job is to reason backwards from the symptom to the cause — not to guess, but to investigate methodically until the culprit is found.

✨ Example:

A function to average two numbers: def average(a, b): return a + b / 2. For inputs 4 and 6, the expected answer is 5, but the function returns 7. Why? Operator precedence — division happens before addition, so it calculates a + (b/2) = 4 + 3 = 7. The fix: return (a + b) / 2. This is a logical error — the code runs fine, but the logic is wrong.

Lesson 9: Object-Oriented Programming — Modelling the World

Object-Oriented Programming (OOP) is a programming paradigm that organises code around objects — entities that combine data (attributes) and behaviour (methods). A class is the blueprint for creating objects. An object is an instance of a class. For example, a class 'Dog' might have attributes like name, breed, and age, and methods like bark() and fetch(). Each specific dog (Bruno, Laika, Rex) is a separate object — an instance of the same class, with its own attribute values. OOP is built on four core principles: Encapsulation (keeping data and methods together inside the object, protecting internal state), Inheritance (a child class can inherit attributes and methods from a parent class — a 'GuideDog' inherits from 'Dog' and adds its own features), Polymorphism (objects of different classes can respond to the same method call in different ways), and Abstraction (hiding complex implementation details, exposing only what's necessary). OOP makes large programs easier to design, maintain, and extend.

💡 Think of it this way:

A class is like a cookie cutter, and objects are the cookies. The cutter defines the shape — all cookies have the same structure. But each cookie can have different decorations (attribute values). Hundreds of cookies can be made from one cutter, and changing the cutter changes the shape of all future cookies without touching the existing ones.

✨ Example:

In Python: class Animal: def __init__(self, name, sound): self.name = name; self.sound = sound. def speak(self): return self.name + ' says ' + self.sound. dog = Animal('Rex', 'Woof'). cat = Animal('Miso', 'Meow'). dog.speak() returns 'Rex says Woof'. Same class, different objects, different attribute values — this is OOP in its simplest form.

Lesson 10: Web Technologies — How the Internet Works

The internet is a global network of computers that communicate using standardised protocols. The World Wide Web — a system of interlinked pages accessed via browsers — is built on top of the internet. When you type a URL into a browser, a request is sent to a server, which sends back data that your browser renders as a web page. Every web page is built from three core technologies: HTML (HyperText Markup Language) defines the structure and content — headings, paragraphs, links, images. CSS (Cascading Style Sheets) controls the visual presentation — colours, fonts, layout, spacing. JavaScript is the programming language that makes web pages interactive — responding to clicks, animating elements, validating forms, loading new data without refreshing the page. This separation of concerns — structure, style, and behaviour — is a design principle that makes web development manageable. Beyond these basics, modern web development involves frameworks, databases, APIs, and server-side code — but HTML, CSS, and JavaScript remain the fundamental building blocks.

💡 Think of it this way:

A web page is like a house. HTML is the structure — the walls, floors, and rooms. CSS is the interior design — the paint, furniture, and decoration. JavaScript is the functionality — the lights that switch on when you enter a room, the doors that open automatically, the alarm that responds to movement.

✨ Example:

A simple HTML page: <h1>Hello World</h1> displays a large heading. Adding CSS: h1 { color: blue; font-size: 32px; } makes it blue and large. Adding JavaScript: document.querySelector('h1').addEventListener('click', function() { alert('You clicked the heading!'); }); makes it respond to a click. Three languages, three roles, working together.

Lesson 11: Databases — Storing and Retrieving Data

A database is an organised collection of structured data, stored and accessed electronically. Almost every application you use relies on a database: social media platforms store posts, users, and relationships; online shops store products, orders, and customers; banks store accounts, transactions, and balances. Relational databases organise data into tables — rows and columns, like a spreadsheet — with relationships defined between tables. SQL (Structured Query Language) is the standard language for working with relational databases. Core SQL operations follow the CRUD pattern: Create (INSERT new records), Read (SELECT existing records), Update (UPDATE existing records), Delete (DELETE records). A SELECT query can filter results with WHERE, sort with ORDER BY, limit results with LIMIT, and join data from multiple tables with JOIN. Non-relational databases (NoSQL) store data in formats like documents (JSON), key-value pairs, or graphs, and are often used for large-scale, flexible data. Understanding databases is fundamental to back-end development and data science.

💡 Think of it this way:

A database is like a highly organised filing cabinet in a very large office. Each drawer (table) holds files on a specific subject. Each file (row) contains a record. The filing system (schema) ensures everything is stored consistently, and the assistant (SQL) can find any file or combination of files instantly — however large the cabinet.

✨ Example:

A school database has a Students table with columns: id, name, age, class_id. A Classes table has: id, class_name, teacher. The SQL query: SELECT students.name, classes.class_name FROM students JOIN classes ON students.class_id = classes.id WHERE students.age = 12; retrieves the names and class names of all 12-year-old students — combining data from two tables in a single, efficient query.

Lesson 12: Project Thinking — Building Real Software

Real software is not written in a single sitting by a single person. It is designed, built, tested, revised, and maintained — often by teams, over extended periods. Understanding the software development lifecycle is as important as knowing syntax. The main phases are: Planning (what problem does this solve? who are the users? what are the requirements?), Design (how will the solution be structured? what data, functions, and interfaces are needed?), Implementation (writing the actual code), Testing (verifying that the code does what it should — unit tests, integration tests, user testing), Debugging and revision (fixing problems found in testing), and Deployment and maintenance (releasing the software and updating it over time). Version control — using tools like Git — allows developers to track changes, collaborate without overwriting each other's work, and revert to earlier versions when things go wrong. Good software development is a disciplined craft: it requires not just programming skill, but communication, planning, and the humility to know that the first version is never the last.

💡 Think of it this way:

Building software is like building a house. You don't start by pouring concrete before you have a floor plan. You design first, build in stages, inspect each stage before proceeding, and know that maintenance and modifications will continue long after the initial build is finished. The code is the building; the architecture is the design.

✨ Example:

A student wants to build a quiz app. Planning: who are the users? what does it need to do? Design: a questions database, a scoring system, a timer, a results screen. Implementation: write the code in stages. Testing: try every type of question, wrong answers, edge cases. Deploy: share with classmates. Maintenance: fix bugs they report, add features requested. This is the full cycle — even for a small project.

Course Quiz — Coding: Thinking Like a Computer
Question 1 of 12

What is an algorithm?

Lotus

Continue Your Learning Journey

Sign in to unlock CODING - Thinking Like a Computer and explore joyful, accessible learning.

In loving memory of Saroj Singh