Lesson 04 of 55
9 mins readPython Numbers & Arithmetic Operators
In Plain English
Lua 5.3+ seamlessly integrates 64-bit integers and double-precision floats. In addition to standard math operators, Lua provides floor division (`//`) and exponentiation (`^`).
Deep Dive: How It Works
Floor Division (//): Truncates quotient towards negative infinity (`17 // 5` is `3`).
Exponentiation (^): Power operator (`2 ^ 8` is `256.0`).
Modulo (%): Modulo division (`17 % 5` is `2`).
math Library: Built-in functions like `math.floor`, `math.ceil`, `math.sqrt`, `math.random`.
Core Rules to Remember

Floor Division (//): Performs integer division truncating remainder.

Built-in Exponentiation (^): Native power operator without needing function calls.
Live Interactive Example
Hit Run Code to see it liveArithmetic and Math Functions
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
Output Console
Click "Run Code" to view the rendered output.
How it works: 17 // 5 evaluated to integer 3, while 2 ^ 8 computed 256.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Compute Modulo and Power
Calculate `local rem = 100 % 7` and `local cube = 3 ^ 3`.
Print `"Remainder: " .. rem .. " Cube: " .. cube`.
1
2
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.