-
Notifications
You must be signed in to change notification settings - Fork 26
Cyber Dojo Instructions
We currently host our monthly challenges on https://www.cyber-dojo.org/. This page explains how it works.
This website allows us to run Python code online, so that newcomers do not need to install Python on their device. You are free to use your own tools if you prefer.
First, join the online Cyber-Dojo session:
- Go to https://www.cyber-dojo.org/
- Select "We're in a group", then "Join a session"
- Enter the ID that will be shared with the group at the time of the meeting, or on the Meetup page directly.
- An animal will be assigned to you, then you will be able to start coding on the next page.
On the Cyber-Dojo interface, you will see:
- The editor (middle / bottom-right), which occupies most of the page and is where you will be coding.
- The list of files on the left, click on a file to access it.
- Your test run history (top bar of the page), which will be empty to start with. Tests are color-coded as:
- green: all tests passed
- red: at least one test failed
- yellow: there was an unexpected error while running the tests
To try your code, click the "Test" button in the top-left. This will run the code in the test_
files, which should in turn run the code you wrote to verify that it works.
The Cyber-Dojo coding website is designed according to the [Test-Driven Development] practice. In other words: write the tests first, build the code after! We encourage you to do the same, but the choice is yours.
To add a test, add an assert
statement in test_my_code.py
, such as follows:
assert my_function_to_test(test_input) == expected_result
# Examples:
assert add_numbers(1, 2) == 3
assert is_even(1024)
The assert
statement works by checking if what follows on the line is (or evaluates to) True
, and throws an error if it is not.
More information:
- Test-Driven Development on Wikipedia
- Reference for assert in the official Python documentation.
- If you feel stuck, you can add
print()
calls in your code to see what's going on. - You can read other people's code! Click on the animal image in the top-left to access the session dashboard, and click on the other animals to access their code.
- Don't hesitate to ask for help!