Intro to Programming Tutorial menu

What is Programming?

Programming is the skill of telling a computer exactly what to do, one clear step at a time.

Instructions, Like a Recipe

Think about how Ayesha's mother makes chai. She follows steps in order:

  1. Boil water
  2. Add tea leaves
  3. Add milk and sugar
  4. Boil again, then pour into cups

A computer program works the same way. It is a list of steps, and the computer follows them in order, from top to bottom. The big difference is that a computer does exactly what you write. If you forget a step, it will not guess. If you write a step in the wrong order, it will happily do it in the wrong order.

What is a Programming Language?

Computers do not understand Urdu or English. Deep inside, they only understand numbers. A programming language is a middle ground: it is easy enough for people to read and write, and strict enough for a computer to follow without confusion.

There are hundreds of languages. Some popular ones are:

LanguageOften used for
PythonAutomation, data, AI, beginners
JavaScriptWebsites and web apps
Java / KotlinAndroid apps, big business systems
C / C++Games, fast software, hardware
PHPWebsites such as WordPress

In this tutorial we use Python and JavaScript, because they are friendly for beginners and used everywhere.

Your First Program

The classic first program just shows a message on the screen.

In Python, you use print():

Example

python
print("Hello, World!")
print("I am learning to code.")
Output
Hello, World!
I am learning to code.

In JavaScript, you use console.log():

Example

javascript
console.log("Hello, World!");
console.log("I am learning to code.");
Output
Hello, World!
I am learning to code.

Each line is one instruction. The text inside the quotes is called a string. The computer shows it exactly as written.

In JavaScript, a semicolon ; at the end of a line marks the end of an instruction. Python does not need it. Both languages ignore extra spaces at the end of a line.

Code, Programs and Programmers

A few words you will hear a lot:

  • Code: the text you write in a programming language
  • Program: a complete set of code that does a job, like a calculator
  • Programmer or developer: a person who writes code
  • Run or execute: asking the computer to follow your code
  • Output: what the program shows or produces

Comments: Notes for Humans

Sometimes you want to write a note in your code that the computer should ignore. This is called a comment.

Example

python
# This line is a comment. Python skips it.
print("Shop is open")  # a comment can also go here

Example

javascript
// This line is a comment. JavaScript skips it.
console.log("Shop is open"); // a comment can also go here
Output
Shop is open

Python comments start with #. JavaScript comments start with //. Good comments explain why you wrote something, so you (or a classmate) can understand it later.

Where Can You Run Code?

You do not need anything special to start:

  • Python: install it from python.org, or use a free online Python editor
  • JavaScript: every web browser already has it. In Chrome, press F12 and open the Console tab to type JavaScript

Do not worry about choosing the "best" language right now. Learn the ideas first. Once you understand variables, conditions, loops and functions in one language, a second language is much easier.

Exercise

Exercise

Which line shows a message on the screen in Python?

Learn Intro to Programming with a teacher

Join the Python Programming course at Workownix, online or in Orangi Town, Karachi, and get a certificate.

See the course Ask on WhatsApp