ACM at Bucknell University
Programming Contest

HomeGeneral Information → Python 3

Writing code

You may choose to write your code in idle or a standard text editor or in the contest screen.

Warning: To choose Python 3.x in the contest software, make sure it says "Python 3" not just "Python"
To launch idle, type
idle &

Using the contest screen

To write code, in the contest window, select your chosen language from the drop down menu at the top right side of the screen. Type your code into the box (ignore the Python 2 code it automatically provides).

Enter test input such as the provided sample input into the box on the mid right side of the screen. Click on the test button to compile and run your code using the test input. You will see results appear in the bottom right box.

To submit code for judging, click on the submit button. Feedback will appear in the bottom right box.

Compiling and running programs

Run your programs on the terminal command line as follows:

python Practice.py < input

input is the name of a file containing your input. The < redirects the contents of the input file into the python program as if you were typing them at the prompt. It is not doing file I/O.

Python Examples of how to read input

Some input will terminate after a known set of values. Some will terminate after reading an unknown amount of input.
# Read in an unknown amount of input and prints the input followed by the sum.
sum = 0
try:
  while True:
    i = int(input())
    sum = sum + 1
    print(i)
except Exception:
  pass
print(sum)


# Read in input until you see a 0
i = int(input())
sum = 0
while i != 0:
  sum = sum + i
  print(i)
  i = int(input())
print(sum)