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

Who owns the factors of production?
The largest lake in Europe is LakeA. LadogaB. DoiraniC. OnegaD. BaikalPlease select the best answer from the choices providedO AOBOСOD​
' Are they sitting there?' he asked. change into indirect​
Diferencia entre huerto y cultivo?
The volume of a rectangular tank is 20 000 cm3 . Given that the length is 40 cm and width is 25 cm, find its height
Esquire Comic Book Company had income before tax of $1,000,000 in 2016 before considering the following material items: 1. Esquire sold one of its operating di
Please help me please I will give the Brainlest
Please help me with this question I’m stuck going to get this right because it’s a quiz
Simplify 18 - 2[x + (x - 5)]. 28 - 4 x 8 - 4 x 28 - 2 x
Job costing, unit cost, ending work in process. Rowan Company produces pipes for concert-quality organs. Each job is unique. In April 2016, it completed all out