Getting started
Hello, Qu
hello, world, and a bit of arithmetic.
catalog/demo_hello.qu
The first program to run in Qu. Prints a greeting, does some ordinary arithmetic, and shows string interpolation with a format spec.
What it exercises
- print(), string interpolation, +/-/*// and ^, variables
How it works
Say hello
print("Hello, Qu!")
Do some arithmetic
a = 6
b = 7
print("a + b = {a + b}")
print("a * b = {a * b}")
print("b ^ 2 = {b ^ 2}")
print("pi = {pi:.4f}")
Results
printed
Hello, Qu! a + b = 13 a * b = 42 b ^ 2 = 49 pi = 3.1416
The whole program
Runnable as it stands: qu run catalog/demo_hello.qu
# demo_hello.qu — hello, world, and a bit of arithmetic.
#
# The first program to run in Qu. Prints a greeting, does some ordinary
# arithmetic, and shows string interpolation with a format spec.
#
# Exercises:
# print(), string interpolation, +/-/*// and ^, variables
backend auto
#%% Say hello
print("Hello, Qu!")
#%% Do some arithmetic
a = 6
b = 7
print("a + b = {a + b}")
print("a * b = {a * b}")
print("b ^ 2 = {b ^ 2}")
print("pi = {pi:.4f}")