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

2. What is another word for sound quality? timbre interference overtone acoustics
What are the three plot points and is it over the x-axis or y-axis
A restaurant needs a staff of 3 waiters and 2 chefs to be properly staffed. The joint probability model for the number of waiters (X) and chefs (Y) that show up
Where should charts with food code 3-401 be displayed
In the market for wheat, if the price of ethanol (which is made from corn, a substitute in the production process) increased dramatically, the _____ wheat would
A small auditorium has 20 seats in the first row and each successive row contains 2 additional seats. If there are 12 rows in the auditorium, how many seats are
Someone help me. PLEASE!
Read the given excerpt from Oscar Wilde's The Importance of Being Earnest, Morning-room at the Manor House, [Gwendolen and Cecily are at the window, looking out
What’s the nouns replacing
if 5x-26=x+50, then what is the value of x​