Input / Output
Print output and read user input with type-specific functions.
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("What is your name?")
print("Hello, ")
print(name)
set color = input("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("Enter an integer:")
print("Number you entered: ")
print(number)
set a = input("First number:")
set b = input("Second number:")
print("Sum: ")
print(a + b)
The input is parsed as an integer. If the user enters non-numeric input, an error occurs.
Float Input
Read a decimal number with input<float>(prompt):
set float_num = input("Enter a decimal:")
print("You entered: ")
print(float_num)
set x = input("First decimal:")
set y = input("Second decimal:")
print("Sum: ")
print(x + y)
The input is parsed as a floating-point number. Supports decimal notation.
Interactive Programs
Combine input and output to create interactive programs:
print("--- Simple Calculator ---")
set num1 = input("First number:")
set num2 = input("Second number:")
set sum = num1 + num2
print("Sum: ")
print(sum)
print("--- Age Categorization ---")
set age = input("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.