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 | 1 or 0, not true/false | print(True) → 1 |
String | the text itself, quotes not included | print("hi") → hi |
Strings are printed as-is, so spaces inside them are preserved:
print("a b c")
print() with no arguments prints just a newline.
One thing print refuses: printing a NoneType value is a compile error. The message spells it out:
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.
Cast functions
Int8, Int16, Int32, Float16, Float32, and Bool are also built-in functions that convert values. (There is no String(...) conversion.) They get their own section on the Casts page.