CodeLab Practice
What is CodeLab?
CodeLab is an in-browser coding environment that lets you write and run Python or JavaScript code without installing any software. CodeLab uses the Piston API to execute code in a secure sandbox environment.
Accessing CodeLab
Access CodeLab at https://app.hamicodeviet.com/codelab. You must be logged in to use it.
Supported Languages
| Language | Version | Description |
|---|---|---|
| Python | 3.x | Primary language for beginners |
| JavaScript | Node.js | Popular web language |
Writing and Running Code
- Select a language (Python or JavaScript)
- Write your code in the editor
- Click the Run button to execute
- Results will appear in the panel below
- Enter input data (stdin) if needed
Python Example
# Print a greeting
print("Hello, HaMi Code Việt!")
# Sum from 1 to 10
total = sum(range(1, 11))
print("Sum from 1 to 10 is: " + str(total))
# For loop
for i in range(5):
print("Iteration " + str(i + 1))JavaScript Example
// Print a greeting
console.log("Hello, HaMi Code Việt!");
// Sum from 1 to 10
let total = 0;
for (let n = 1; n <= 10; n++) total += n;
console.log("Sum from 1 to 10 is: " + total);
// For loop
for (let i = 0; i < 5; i++) {
console.log("Iteration " + (i + 1));
}Practice Exercises
Each exercise in CodeLab includes:
- Problem description — What you need to solve
- Input data — Sample input
- Expected output — Sample output
- Test cases — Test scenarios to validate your solution
- Time limit — Maximum execution time (10 seconds)
How Piston Works
CodeLab uses Piston — an open-source code execution service. When you click Run:
- Your code is sent to the Piston API
- Piston runs the code in a secure sandbox container
- Results (stdout, stderr) are returned
- The system compares output against expected results
- Pass/fail status is shown for each test case
Each run is limited to 10 seconds. Code that runs too long will be terminated. File system and network access are not available from within code.
Security
Your code runs in a fully isolated sandbox environment. Piston ensures:
- No access to the host file system
- No outbound network connections
- CPU and memory limits
- Execution time limits
In the future, HaMi Code Việt will deploy a private Piston instance to enhance privacy and reliability for grading.
Submission History
All your submissions are saved and can be reviewed. Go to the CodeLab page and select the History tab to view previous submissions.