W
W
Web__Nikita032019-02-08 19:18:44
Python
Web__Nikita03, 2019-02-08 19:18:44

How to write this phrase in python?

The Olympiad on inf will begin soon. On do will do input and output from a text document. I can work with files in python, but not in pascal. But the input and output template is written in pascal. How to write this in python?

var a,b: longint;

begin;

assign(input, 'input.txt'); reset(input);

assign(output, 'output.txt'); rewrite(output);

read(a,b);

write(a+b);
end.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
longclaps, 2019-02-08
@Web__Nikita03

with open('input.txt') as fi, open('output.txt', 'w') as fo:
    a, b = int(fi.readline()), int(fi.readline())
    print(a + b, file=fo)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question