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

The number of grocery items on two grocery lists differs by 7. the total number of items is 33. How many items are on each list?
what is the climax in the book miracle on 49th street
why are the temperatures fairly constant in the surface zone and the deep zone
the perimeter of a triangle is 59 in. The longest side is 11in. longer than the medium side, and the medium side is 3in longer than the shortest side. find the
What fraction is equal to 9//11
what does "Beto" mean in spainish
What happens when an object is dropped? A. force and mass increase every four seconds B. decelerates as it gets closer to the ground C. accelerates due to t
What is the variable of the project "How does music affect a person's blood pressure."
Georgia’s economy was helped by the New Deal. The New Deal helped the state construct libraries, roads, schools, parks, hospitals, airports, and public housing
the perimeter of a triangle is 59 in. The longest side is 11in. longer than the medium side, and the medium side is 3in longer than the shortest side. find the