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

You want to buy a new computer for $1500. You only have $500 right now, so you decide to deposit the money into an account yeilding 5% interest compounded month
if a narrative essay cannot have a thesis statement what does it have
Can someone please help me? :(
in need help this is due at the end of the class You're a gunter. It's a typical day in the OASIS searching for the Easter Egg. You've just heard Parzival fou
How long does Odysseus stay with the god of the winds?
how do u find law of conservation
How is houston trying to combat increasing ozone pollution? by raising taxes on vulnerable populations by increasing access to health care by encouraging use of
Please HELP I WILL GIVE BRAINLYEST
Evaluate 1/2x^4-1/4x^2 for x=2
select your favorite song and tell the texture of the song after.​