Create a Command Line Problem¶
A command line problem is a problem where you expect students to create an application that accepts input from the keyboard and prints output to the console using print statements. The computer will simulate a human entering input and will check the output for the correct response.
In this example, we’ll create a problem that asks students to make an application that receives keyboard input and prints it in reverse.
Create a Problem Set First
Before starting, make sure you’ve already created a problem set. If not, please create a problem set first by following the previous tutorial.
Add a new problem¶
-
From the problem set editor page, press the plus button in the top right corner.
-
A modal will appear. Select the New problem button in the middle.
-
Give the problem a name and click Create and add. In this example we’ll call it
Reverse Echo
.
Create the problem prompt¶
-
Back on the main screen, a new problem editor will appear.
-
In the problem prompt section, type exactly what you want your students to do. Be as clear as possible since this will be used by the AI to provide assistance to students.
Pro Tip
Including input and output examples in the prompt can be very helpful to students.
Markdown
The prompt supports both HTML and Markdown formatting. You’ll see a live rendering of the prompt in the right-hand box. For more on Markdown, check out this guide.
Add a command line test¶
-
Scroll down to the bottom of the problem editor and toggle the button labeled Command Line.
-
Uncheck the box named Add an example to the new test.
-
Click Create a command line test.
Set up the test¶
-
In the new field labeled keyboard input, type the text that the computer will simulate typing. For this example, type hello world.
-
Above this field, click the Add Check Action button. From the menu, select text. This will create an action for the computer to check the output that appears in the console.
-
In the new row that appears below, type dlrow olleh. The computer will look for this text in the console. If it finds the text, the student will pass the test.
Test edge cases
You can add more tests with different inputs (such as single letters, no words, or other edge cases) to thoroughly test the students' solutions.
Next Steps: Follow the next tutorial to learn how to link the problem set to your class.