Number type

2 snippets across 2 stacks — Python, TypeScript

Also written as number types

PYPython

Integers & Floats

PY · Numbers
syntax
x = 42      # int
y = 3.14    # float
example
count = 1_000_000
ratio = 0.618
print(type(count), type(ratio))
print(count + ratio)
output
<class 'int'> <class 'float'>
1000000.618

Note Underscores in numeric literals are ignored and serve as visual separators. Python ints have unlimited precision.

TSTypeScript

string, number, boolean

TS · Basic Types
syntax
let varName: string = value;
let varName: number = value;
let varName: boolean = value;
example
let username: string = "alice";
let price: number = 29.99;
let isActive: boolean = true;
output
// All three are primitive types inferred automatically when initialized

Note Use lowercase string, number, boolean. The uppercase versions (String, Number, Boolean) are wrapper objects and almost never what you want.