Printing Output

Use print() to write values to standard output:

print("Hello, World!")
print(42)
print(true)
print(null)

print() accepts any value and outputs it followed by a newline. In the REPL, expressions are auto-printed unless assigned to variables.

Printing Multiple Values

set x = 10
set y = 20
print("Sum: ")
print(x + y)

Each print() call is on its own line. Use string concatenation to combine values on one line.

String Input

Read a string from the user with input<str>(prompt):

set name = input<str>("What is your name?")
print("Hello, ")
print(name)

set color = input<str>("Your favorite color?")
print("You like: ")
print(color)

The prompt is displayed and the user's input is read as a string. Trailing newlines are removed.

Integer Input

Read an integer with input<int>(prompt):

set number = input<int>("Enter an integer:")
print("Number you entered: ")
print(number)

set a = input<int>("First number:")
set b = input<int>("Second number:")
print("Sum: ")
print(a + b)

Input is trimmed and parsed as an integer. Invalid input is rejected and the program prompts again. Input is read synchronously from standard input.

Float Input

Read a decimal number with input<float>(prompt):

set float_num = input<float>("Enter a decimal:")
print("You entered: ")
print(float_num)

set x = input<float>("First decimal:")
set y = input<float>("Second decimal:")
print("Sum: ")
print(x + y)

Input is trimmed and parsed as a floating-point number; invalid values are rejected and the program prompts again. Decimal and scientific notation are supported. Non-finite float input is rejected.

Accepting Multiple Input Types

Combine int, float, and str with | to accept a numeric value or text. For a numeric input, Kria tries integer parsing first and then float parsing; text is accepted when it does not parse as a number.

set value = input<int|float|str>("Enter a number or text: ")
print(type(value))

The prompt must evaluate to a string. These input forms require stdin and are intended for interactive programs.

Interactive Programs

Combine input and output to create interactive programs:

print("--- Simple Calculator ---")
set num1 = input<int>("First number:")
set num2 = input<int>("Second number:")

set sum = num1 + num2
print("Sum: ")
print(sum)

print("--- Age Categorization ---")
set age = input<int>("Your age:")

if (age < 13) {
    print("Child")
} else {
    if (age < 18) {
        print("Teenager")
    } else {
        print("Adult")
    }
}

Programs can prompt for multiple inputs and branch based on user responses. Use loops to repeat interactions.