1.1 Hello World
A program is a set of instructions that asks a computer to solve a problem. A beginner-friendly way to think about programming is this: computers do not understand natural human language. Even a request as simple as “calculate 1 + 2” must be written as precise executable steps.
At the lowest level, computers process binary information represented with 0 and 1. A programming language helps turn human intent into structured instructions. You write source code, and the Python interpreter reads that code, understands the syntax, and executes it in order.
Common mainstream programming languages include:
- Python: beginner-friendly and widely used for data analysis, AI, automation, and web backends.
- C: closer to low-level computer systems, often used for operating systems, embedded systems, and performance-sensitive programs.
- C++: extends C with more abstraction, and is common in game engines, high-performance computing, and large software systems.
- Java: widely used in enterprise backends, Android development, and large cross-platform systems.
- JavaScript / TypeScript: central to web frontends, and also used for backend and full-stack development.
- Go, Rust, and C#: common in cloud services, systems programming, game development, and enterprise applications.
These languages differ in syntax, use cases, and learning curve, but they share the same basic goal: turning human ideas into precise instructions a computer can execute.
What is a program?
Most programs combine four basic kinds of action:
- Input: receive data from a keyboard, file, network, or another source.
- Processing: calculate, compare, transform, or store data.
- Output: display a result, write a file, or send data somewhere else.
- Control flow: decide what runs first, what repeats, and what only runs when a condition is true.
When learning Python, you do not need to master every syntax rule immediately. First build this mental model: a program is a clear sequence of steps, and the computer follows those steps exactly.
Flowchart
A flowchart is a visual way to describe program steps before writing code.
The flowchart below describes how to sum integers from 1 to 100. Notice the diamond-shaped node: it represents a decision. If the condition is true, the program keeps adding; if it is false, the program prints the result and stops.
Sum integers from 1 to 100
A standard flowchart uses terminators for start/end, rectangles for processes, and a diamond for decisions.
In code, this becomes initialization, a loop condition, accumulation, variable update, and final output.
i = 1
total = 0
while i <= 100:
total = total + i
i = i + 1
print(total)Your first Python program
Hello World is usually the first program in a new language. Its job is simple: print a piece of text to the screen.
print("Hello World!")Output:
Hello World!There are three details to notice right away:
printis a built-in Python output function.- Parentheses
()pass data into the function. "Hello World!"is a string. A string is text, and text values are wrapped in quotes.
You can read the line as: “call print, and display the string Hello World! on the screen.”
Hello World in other languages
Different languages use different syntax, but the purpose is the same: display text on the screen. Comparing these examples also shows how concise Python can be.
#include <stdio.h>
int main() {
printf("Hello World!\n");
return 0;
}#include <iostream>
using namespace std;
int main() {
cout << "Hello World!" << endl;
return 0;
}public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}C, C++, and Java make the program entry point, imports, classes, or function structure more explicit. Python lets the first program be one line, which is one reason it works well as an introductory language.
Comments
Comments are notes for humans. They are not executed as program instructions. Use comments to explain intent, record context, or mark a point that future readers should understand.
Common Python comment styles:
- Single-line comments start with
#. - Multi-line notes are often wrapped in triple quotes
""" ... """.
print("Hello World!") # display "Hello World!"More comments are not always better. For beginners, a good rule is to comment why something is done, not merely repeat what the line already says.