Your first Python test

Welcome! This will be your first test with our Python platform. You'll spend a lot of time in it, so we want to make sure you understand how it works.

Step 1: Your first variable

In the first line (your_name = "") we're defining a variable named your_name which was assigned an "empty string". It's just blank/empty text. Go ahead and put your name in it. In my case, I'll have: your_name = "Santiago".

Step 2: Running the code

Once you have completed your name, try the Run Code function. Do you see the message in the output console?

Step 3: Running tests

Now we can run tests. We use tests to "check" if your code is behaving as expected. Testing is HUGE in professional software development. RMOTR is Test Driven (read more about TDD if you're interested).

Below you'll see a section (Test Cases) with two tests: "Test Name Is Not Blank" and "Test Name is Long Enough". Try clicking on each individual RUN TEST button.

This is an iterative process: writing the code, running tests, checking if the tests are passing, fixing them, reiterating.

Step 4: Submit and save your solution

Once your tests are passing, and you're sure your code is working, you can save your solution and "mark" this exercise as done. To do that, just click on the SUBMIT SOLUTION button. All what it does is "packaging" all these tests together and executing them. If the tests are passing, your "attempt" will be marked as complete.

Don't worry if your tests fail with SUBMIT SOLUTION. You can try it AS MANY times as you want. The advantage of SUBMIT SOLUTION is that it'll save your code in case you want to use it later (check the Previous Attempts section).

Test Cases

test name is not blank - Run Test

def test_name_is_not_blank():
    assert your_name != '', "Your Name can't be blank!"

test name is long enough - Run Test

def test_name_is_long_enough():
    assert len(your_name) > 3, "Your name must have more than 3 characters"

Solution 1

your_name = "Santiago"
course = "RMOTR Python"

greeting_message = "Welcome {} to the {} course!".format(your_name, course)
print(greeting_message)
your_name = "" course = "RMOTR Python" greeting_message = "Welcome {} to the {} course!".format(your_name, course) print(greeting_message)