Python programs are executed on the server with the Python 2.7.8 or Python 3.4.1.
The syntax is checked with the
py_compile.compile function. Errors like
IndentationError lead to the
Compilation error judging result on this stage. Then the interpreter is invoked without additional arguments:
python %1. Since Python is an interpreted language, the errors like
NameError are recognized by the online judge as a
Runtime error but not as a
The set of the modules available for import is strictly limited.
You can find the interpreter here.
An example of solving a problem
A sample solution for the 1000. A + B problem in Python 2:
print sum(int(x) for x in raw_input().split(' '))
The same solution in Python 3:
print(sum(int(x) for x in input().split(' ')))
A sample solution for the 1001. Reverse Root in Python:
import sys, math
nums = 
for line in sys.stdin:
for word in line.split():
for num in nums:
print("%.4f" % math.sqrt(num))
More efficient solution of the same problem:
from sys import stdin, stdout
from math import sqrt
tokens = reversed(stdin.read().split())
stdout.write('\n'.join(['%.4f' % sqrt(float(t)) for t in tokens]))
- The Python 2.7.3 was used until October, 3 2014.
- The Python 2.3.0 was used until October, 3 2014.