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

Steve drives 13 miles each way to work and has to pay $2.72 in tolls each way. He works 241 days in the year. Gas is $3.47 per gallon. What MPG must his car ave
I need it soon. For Mythology and Folklore. Step 1: The Princess Who Outwitted Death Watch the following short video about the hero Savitri: Iseult Gillespie’
essay with context clues
Trouble shoot system startup 2 8.8.10
This Week We Learned About Memory Please use this discussion post to think about how the chapter's materials and videos relate to your life and/or today's soc
Mr. Fox organizes a field trip to a museum. He orders 52 student tickets and 2 adult tickets. The cost of a student ticket is s and the cost of an adult ticket
If the area of a rectangle is: x² + 24x - 81 Find the perimeter. Explain the steps please.
(x)((y)(Axf gtuehiqgliutehjklluhigtegehrtuilguehlruhliregqulhigreuhgri
i have a essay i need to write and its due in 2 hours it's on survival I NEED HELP FAST
What time period does this cartoon represent?