BashaByte

Free previewLesson 1.160 min

What is programming?

Computer basics (CPU, memory, input and output) in 5 minutes; what a program is; what a programming language is; how this course works.

By the end of this lesson you can

  • Name the four main parts of a computer (input, CPU, memory, output) and say what each one does when a program runs.
  • Explain what a program and an algorithm are, and write the steps of an everyday task in the correct order.
  • Explain why we write in a programming language instead of machine code, and run and change a one-line Python program.

01Notes

Why this lesson matters

You pay a friend Rs. 200 on UPI. In under two seconds, your phone reads the amount you typed, checks your PIN, talks to your bank, and shows a green tick.

No person did those steps. A program did. Someone wrote clear instructions, in the right order, and the computer followed them exactly.

In this lesson you will learn what a computer really does, what a program is, and why we need a language like Python to talk to a computer.

And you don't have to wait till the end to touch code. In the very next step, you will run your first Python program, without typing a single letter.

02Try it

Your first program: just press Run

Don't worry about understanding anything yet. Below is a complete Python program, already written for you. You don't have to type anything.

1. Press **Run**.
2. Look at the output panel on the right.
3. Press **Submit**.

That's it. You have just run your first Python program! Millions of programmers, including the ones at Google and Instagram, started with exactly this line. In the next video, I will tell you what actually happened.

main.pyRun
print("Hello World!")

In the lesson player this runs in the BashaByte compiler.

03Concept video

Concept video: What is programming?

Video coming soon. About 7:00 long. The notes below cover everything in it.

  1. 0:00You just ran your first program
  2. 1:00What a computer does
  3. 2:45What a program is
  4. 4:15Why programming languages
  5. 5:45How every lesson works
  6. 6:30Recap

04Notes

Notes: computers, programs and languages

1. What a computer doesLink to this section

Every computer, from your phone to a bank server, works in three stages:

Input -> Process -> Output

Part What it does Examples
Input Takes data in Keyboard, mouse, touch screen, camera, microphone
CPU (processor) Runs instructions: calculates and decides Intel Core, AMD Ryzen, Apple M-series, Snapdragon
Memory (RAM) Holds the program and data being used right now; cleared when power goes off 8 GB RAM
Storage Keeps files and apps permanently SSD, hard disk, pen drive
Output Shows or sends the result Screen, speaker, printer

Kitchen example

the recipe book is storage, the kitchen counter is RAM, the cook is the CPU, and the plate served is the output. The cook can only work with what is on the counter, so data is brought from storage into RAM before the CPU uses it.

2. What is a program?Link to this section

A program is a set of instructions, written in order, that a computer follows exactly.

An algorithm is the plan behind it: the step-by-step method to solve a problem. First we think of the algorithm, then we write it as a program.

Example algorithm: making tea 1. Boil water. 2. Add tea powder. 3. Add milk and sugar. 4. Boil for 2 minutes. 5. Filter into a cup.

If you filter before boiling, you get no tea. Computers are the same: they do exactly what you write, in the order you write it. They do not guess what you meant.

3. Why do we need programming languages?Link to this section

The CPU understands only machine code: long patterns of 0s and 1s, like 10110000 01100001. Humans cannot write big programs this way quickly or without mistakes.

A programming language lets us write instructions in a form close to English. A translator program then turns them into machine code. Python's translator is called the interpreter. You will learn more about it in Lesson 1.5.

Your first Python instruction:

print("Hello, BashaByte!")

Output

Hello, BashaByte!

print() shows on the screen whatever you put inside the brackets. Text must be inside quotes.

4. How this course worksLink to this section

Every lesson has the same 8 steps: video, notes, predict the output, try it in the compiler, arrange the code, quick check with fix-the-bug, and coding tasks. Each module ends with a mini-project and an exam. Use hints only after you have tried.

Common mistakes

  • Thinking RAM and storage are the same. RAM is temporary working space; storage is permanent.
  • Forgetting the quotes: print(Hello) is an error, print("Hello") is correct.
  • Writing Print with a capital P. Python is case-sensitive, so it must be print.

Key words

Input, output, CPU, RAM, storage, program, algorithm, machine code, programming language, interpreter.

05Predict the output

Predict the output

Read each program. Decide what it will print before you look at the options. Then check your answer.

Q1

What is the output of this program?

print("Hi")
print("Python")
  1. Hi Python (on one line)
  2. Hi Python (on two lines)
  3. HiPython
  4. Error
Q2

What is the output of this program?

print("5 + 3")
  1. 8
  2. 5 + 3
  3. "5 + 3" (with the quotes)
  4. Error

You'll answer these in the lesson player, with an explanation after every choice.

06Fix the bug

Spot the difference

This program should print exactly: Hello World! Run it. The output looks almost the same, but not exactly. Put your output and the expected line one below the other and compare them letter by letter. Find the tiny difference and fix it. This is the most important habit in programming: the computer prints exactly what you tell it, not what you meant.

The program should print exactly:

Hello World!

Run it, compare the output with the expected line letter by letter, and fix the difference.

buggy.py · PythonSubmit
print("Hello world!")

In the lesson player your code is checked against hidden tests, with hints if you get stuck.

07Try it

Try it: run and change

1. Press Run and look at the output.
2. Change the text inside the quotes to your own name and run again.
3. Add one more print line that shows your city.
4. Remove one quote mark and run. Read the error message, then fix it.

main.pyRun
print("Hello, BashaByte!")
print("I am learning Python.")

In the lesson player this runs in the BashaByte compiler.

08Arrange the code

Arrange the code: ATM withdrawal

These print lines describe how an ATM gives you cash, but they are mixed up. Drag them into the correct order. One line does not belong anywhere; leave it out.

  • print("Enter your PIN")
  • print("Print the passbook")
  • print("Take your card")
  • print("Insert your card")
  • print("Take your cash")
  • print("Enter the amount")

In the lesson player you drag these into order.

09Quick check

Quick check

Five questions on this lesson. You need 60% to complete the lesson. Read the explanation after each answer.

Q1

Which part of the computer runs the instructions of a program?

  1. RAM
  2. Storage (SSD)
  3. CPU
  4. Monitor
Q2

You are typing a document and the power goes off before you save it. What is lost?

  1. Files already saved on the SSD
  2. The unsaved work that was only in RAM
  3. The apps installed on the computer
  4. Nothing, everything is saved automatically
Q3

Which statement best describes a program?

  1. Any file stored on a computer
  2. A set of instructions, in order, that a computer follows exactly
  3. A hardware part inside the CPU
  4. A connection to the internet
Q4

Why do programmers write in Python instead of machine code?

  1. The CPU understands Python directly
  2. Python is easier for humans to write, and an interpreter translates it for the computer
  3. Machine code runs slower than Python
  4. Python programs do not need a CPU
Q5

In a UPI payment app, typing the amount you want to send is an example of which stage?

  1. Input
  2. Process
  3. Output
  4. Storage

You'll answer these in the lesson player, with an explanation after every choice.

10Fix the bug

Fix the bug

This program should print a welcome message, but it does not run. Find the mistake and fix it.

This program should print exactly:

Welcome to BashaByte

It shows an error instead. Find the mistake and fix it.

buggy.py · PythonSubmit
print("Welcome to BashaByte)

In the lesson player your code is checked against hidden tests, with hints if you get stuck.

11Coding task

Hello, World!

Solve the three tasks. Your output must match exactly, including spaces and capital letters. Pass at least 2 to complete the lesson.

Write a program that prints exactly:

Hello, World!

Check the comma, the space and the exclamation mark.

solution.py · PythonSubmit
# Write your code below

In the lesson player your code is checked against hidden tests, with hints if you get stuck.

12Coding task

Welcome banner

Solve the three tasks. Your output must match exactly, including spaces and capital letters. Pass at least 2 to complete the lesson.

Print this banner exactly, in three lines:


Welcome to Python


The star lines have exactly 10 stars each.

solution.py · PythonSubmit
# Write your code below

In the lesson player your code is checked against hidden tests, with hints if you get stuck.

13Coding task

Input, process, output of a calculator

Solve the three tasks. Your output must match exactly, including spaces and capital letters. Pass at least 2 to complete the lesson.

A calculator app adds two numbers. Print its three stages, in the correct order, exactly like this:

Input: two numbers Process: add them Output: their sum

solution.py · PythonSubmit
# Write your code below

In the lesson player your code is checked against hidden tests, with hints if you get stuck.

Like the way this lesson works?

Enroll in Core Python to take every lesson with live practice and progress tracking.

See the full course