print writes values to standard output, separated by spaces, ending with a newline.
print("Hello,", 1, 2.5, True)
Each type formats its own way:
| Type | Output | Example |
|---|---|---|
Int32, Int8 | digits, with a minus sign if negative | print(-3) → -3 |
Float32 | always 6 decimal places | print(2.5) → 2.500000 |
Bool | True or False | print(True) → True |
String | the text itself, quotes not included | print("hi") → hi |
List | the items between square brackets | print([1, 2]) → [1, 2] |
Dict | the key/value pairs between braces | print({"a": 1}) → {a: 1} |
Strings are printed as-is, so spaces inside them are preserved:
print("a b c")
print() with no arguments prints just a newline. A NoneType value prints as None:
def nothing() -> NoneType
return
def main() -> Int32
print(nothing())
return 0
input
input reads one line from standard input and returns it as a String. The trailing newline is stripped.
name: String = input()
Give it a prompt and the prompt is printed first, with no trailing newline, so your input lands on the same line:
n: Int32 = Int32(input("Enter a number: "))
print(n + 1)
If input runs out of data (for example at the end of a redirected file), it returns an empty string. Watch out: converting that empty string with Int32("") is a runtime error, and only caught in debug mode. The 07_conversion example on the Examples page shows the safe pattern.
len
len returns the number of items in a collection, as an Int64. It only takes a List or a Dict — passing a String fails to compile with Function 'len' expects a List or Dict, got String (strings have no length function yet; the workaround is a manual loop, described on the Strings page).
names: List[String] = ["ann", "bob", "clyde"]
print(len(names))
The empty collection has length 0. len is handy with for loops and indexing.
Related builtin: dict_key(d, i) returns the key of a Dict at position i (an Int64). It exists mostly as the machinery behind for key in d, but you can call it yourself if you want to step through a dict by index.
ages: Dict[String, Int32] = {"ann": 30, "bob": 40}
print(dict_key(ages, Int64(0)))
chr
chr(code) takes an Int32 code point (0–255) and returns a one-character String holding that byte. It is how you build characters that have no literal escape, like the ANSI escape byte 27 that the colorama module uses:
print(chr(65))
Codes outside the byte range are silently truncated to their low 8 bits.
Cast functions
Int8, Int16, Int32, Int64, Float16, Float32, Float64, Bool, and String are all built-in functions that convert values. String(...) turns numbers and bools into text — print(String(3.5)) prints 3.500000 — and is covered on the Casts page together with the rest.