Learn to Code
All tracks
Learn to Code

Free lessons from scratch to pro — every language, databases and DevOps.

AboutContactPrivacy PolicyTerms of Use

Your progress is saved in this browser. © 2026 Learn to Code

PB
Programming Basics
0/10 completed
Beginner
How computers workWhat is a program?Thinking in algorithmsData, variables and types
Intermediate
Decisions and loopsBreaking problems into functionsErrors and debugging
Advanced
Reading documentation and learning on your ownClean code basics
Pro
Thinking like a software engineer
Tracks / Programming Basics / Beginner

Data, variables and types

Programs work with data: names, prices, dates, lists of products. To use data, we store it in variables and the language keeps track of its type.

Variables: labelled boxes

A variable is a name that refers to a value stored in memory.

JavaScript · editable
Python · editable

= means "store this value", not "is equal to". score = score + 10 reads: "take score, add 10, and store the result back in score".

Naming conventions

Language Convention Example
JavaScript, Java, C# camelCase totalPrice
Python, Ruby, Rust snake_case total_price
Constants (most languages) UPPER_SNAKE MAX_USERS

Good names describe what the value is: daysUntilDeadline beats d or x2.

The core data types

Almost every language has these:

Type Represents JavaScript Python
Integer Whole numbers 42 (number) 42 (int)
Float Decimals 3.14 (number) 3.14 (float)
String Text 'hello' "hello"
Boolean True / false true / false True / False
Nothing "No value" null, undefined None
List / array An ordered collection [1, 2, 3] [1, 2, 3]
Map / dictionary Key → value pairs { name: 'Asha' } {"name": "Asha"}
Python · editable
JavaScript · editable

Why types matter

The type decides what operations make sense. + adds numbers but joins strings:

Python · editable
JavaScript · editable

This is a classic difference:

  • Python is strongly typed: mixing types raises an error, so you find the bug early.
  • JavaScript is weakly typed: it converts types automatically, which can hide bugs. (TypeScript adds type checking to JavaScript for this reason.)

Converting between types

Python · editable

Static vs dynamic typing

Dynamic typing Static typing
Types are checked… While the program runs Before it runs (at compile time)
A variable can hold… Any type, and change type One declared type
Examples Python, JavaScript, Ruby Java, C#, Go, Rust, TypeScript
// Static (TypeScript / Java style):  the type is part of the declaration
let age: number = 28;
age = "twenty-eight";   // ❌ compile error, caught before running

Practice

Create variables describing a product: its name (string), price (float), quantity in stock (integer), whether it's on sale (boolean) and a list of tags. Print a sentence using all of them. Then convert the string "19.99" to a number and add it to the price.

Python · editable
✎ Check your understanding

1.In Python, what does "5" + 5 do?

2.Which type would you use to store whether a user is logged in?

← Thinking in algorithms