Home python ACMP.RU Task, Python

ACMP.RU Task, Python




The problem is not in the logic of code and in its ordering, in other words, I wrote how to make one or another function, I need it to bring it right way as they ask on the website ACMP.RU, my only problem is that I do not understand the principle Works of the input and output files, even kill, try to somehow adjust the conditions for making a file into a green color, this is the actual code:

r = open ('input.txt', 'R')
N = R.Read (1)
W = Open ('Output.txt', 'W')
V = 0.
For i in Range (0, int (n) +1, 1): # I think there is nothing to explain here.
  v + = i
w.Write (STR (V))

It would seem that here is a simple truth, well, if you throw this decision to the site, God knows what the compiler will reject it, and it will fall back in late. And here are the basic conditions for the “correct” code wording:

It is required to calculate the amount of integers located between numbers 1 and
N inclusive.

Input in the only line of the input file input.txt is recorded
The only integer N, not exceeding the absolute value of 10,000,000.

Output to the only row of output file Output.txt need
output one integer – the sum of the numbers located between 1 and n

Thank you in advance, for the help, for it is confident that brave programmers will help me to get out of the Cloak of the shitful on my shoulders, and deeply hope for your responsive and understanding soul.

Answer 1, Authority 100%

  1. you need to read not 1 byte, but a string.
  2. you need to turn into numbers.
  3. Use With to work with files.
  4. there is probably an example of how to write.
  5. Anyway, this time code will not pass.

By the way, you can write

at the beginning of the file

import sys
sys.stdin = Open ('Input.txt', 'R')
sys.stdout = Open ('Output.txt', 'W')

and then use the usual input and print

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions