pricanoanda pricanoanda
  • 26-03-2017
  • Computers and Technology
contestada

Write a short program that uses a for loop to write the numbers 1 through 10 to a file

Respuesta :

Аноним Аноним
  • 26-03-2017
An example would be as follows:

outfile = open('filename.txt', 'w')
for num in range (1, 11):
outfile.write(str(num) + '\n')
outfile.close()

And a second example:

dataFile = open("filename", "w")
for line in range(11):
    dataFile.write("%s\n" % line)
dataFile.close()


Hope this helps.
Answer Link

Otras preguntas

What is the cause for which the soldiers buried at Gettysburg gave the last measure of devotion
constitutional amendment that outlawed slavery and indentured servitude
fifty-six out of 128 students went on a trip during vacation. what percent of students went on trips?
2x + 2y = 28 8x - 2y= 22 system of equations
there are a total of 127 cars and trucks on a lot. If there are four more than twice the number of trucks than cars , how many cars and trucks are on the lot ?
Find the rate of discount for a pair of pants that cost 65 dollars and are only on sale for 41.99 dollars. EXPLAIN each step.
how to do 8.478 in expanded form
If 0 < x < 1 and 0 < y < 1, which of the following must be true? A. xy> 0 B. xy < 0 C. x/y < 0 D. x-y > 0 E. x-y < 0 I found out the
How do simple machines make work easier? A. They add energy to the work. B. They increase the force needed to work. C. They reduce the speed of work. D. Th
fifty-six out of 128 students went on a trip during vacation. what percent of students went on trips?