Problem stub - A problem stub (also known as a ‘language stub’) is the skeleton
code that the teacher has provided for a particular language. You have to solve the
coding problems by adding your code to the given skeleton code.
Execution Time limit - This is the time taken for code to execute from start to finish
for a given input on the server. Note: This time is independent of your internet speed.
In case your code execution time exceeds the time limit for a particular input, you will
receive an error message like this: ‘Time limit exceeded. The execution took more
than 5.00 seconds’.
Load language stub - This is the action that you can find in the overflow menu.
Clicking it will enable you to go back to the problem stub. Note: Your current
solution code will be replaced by the problem stub. This action will help you to clear
your current solution code and will replace it with the problem stub or the skeleton
code.
Demystifying Test Cases
Test cases are a tool to evaluate your code. A test case determines whether the
solution code (the code written by you) works for a particular scenario or not. In
most questions, your code is checked against multiple test cases to assess whether
it meets the requirements specified by the teacher or not.
A test case has two major components: an input, which is the scenario for which
your code is being tested, and an expected output, which is the expected results for
that particular input. If the output returned by your code is the same as the expected
output given a specific input, then the test case is deemed ‘Passed’; otherwise, it is
deemed ‘Failed’.
Let us consider the problem that we saw in the earlier video. An example of a test
case for this problem would be something like the one shown here.
Input
2
87 98
87 89 67 56
Expected Output
2
4
In this example, the input of the test case contains two arrays with lengths of 2 and
4. If the output of your code for these test cases matches the expected output,
which is 2 and 4, then your code will pass the test case.
You have now seen how the coding console looks and have also learnt how you
can write your code in it. However, you might be wondering how you can test and
submit your code using the editor. This will be covered by the next video.
Play Video
622103
In the video, you learnt the three actions that you can perform using the coding
console. They are as follows:
1. Run Code
Used to check your code’s output against a custom input provided under the section
‘input’
Can be performed as many times as possible
Is commonly used to debug and check errors and mistakes during the process of
writing solution code
2. Verify
Used to verify your code against sample test cases
Can be performed as many times as possible
3. Submit
A formal submission that tests your code for correctness by checking against all test
cases
Can be performed a limited number of times only
Types of Test Cases
Now we will help you quickly understand the two types of test cases that were
discussed in the earlier video:
1. Sample Test Case
It is executed at the time of ‘Verify’ and ‘Submit’.
You will be able to see the input and the expected output at all times.
The primary purpose is to check how your code is performing against some test cases
so that you make corrective changes and then resubmit the code.
2. Non-Sample Test Case
It is executed only at the time of ‘Submit’.
You will be able to see the input and the expected output only after you have
exhausted all submissions or have answered a question completely correctly.
The primary purpose is to check the correctness of the solution code.
Now that you know how to submit your code, you will next learn how to complete
a question by making further attempts. After this, we will look at a few additional
pointers, which will help you to use this tool effectively.
Play Video
622103
You would have seen some statuses as we went through the process of solving an
entire coding question. Now you will learn about some of the statuses that you
would encounter while attempting a code question:
Unsolved - You have not added anything on top of the Problem Stub.
Attempted - You have made some changes to the problem stub, which have been
saved.
Submitted - This is a temporary state, which comes when you have clicked on
‘Submit’ and the test cases are being executed on the server. The status changes after
the test cases have been executed. Note that this will be the final state in questions
that have no test cases.
Rejected - All non-sample test cases have failed.
Partially Correct - Some of the non-sample test cases have failed.
Accepted - All non-sample test cases have passed. Your solution code is correct.
Note: Our internal code evaluation engine requires the name of a class to be
‘Source’. Please ensure you do not tamper with this part as doing so will result
in this error message being displayed:
Image
Let us go through a few important pointers before we end this tutorial:
1. We match the exact output. Spaces, Prints, etc. are to be managed separately.
2. We strongly recommend that you write code here and not transport it to an external
IDE. Note: Since the console automatically loads the libraries used in Python code,
copy-pasting code directly to Jupyter, or to any other external IDE, would require you
to manually add the libraries for the code to run.
3. Spelling mistakes in output statements will result in failed test cases. So, please be
careful.
You can download the list of detailed FAQs by clicking here.
With this, we have come to the end of the tutorial for the upGrad Coding Console.