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          of a monomial is the sum of the exponents of its variables.
10y+23=4y+26 please help
In the expression 5x^3-4x^2+2x+3, what is the coefficient of the quadratic term? Choices: 1.) -5 2.) -4 3.) 3 4.) 4
Ocean tides are the result of -the rotation of earth -the suns gravitational pull on earth -changes in earths orbital position around the sun -differences in bo
calculate the wavelength of violet light with a frequency of 750×10 to the 12
calculate the wavelength of violet light with a frequency of 750×10 to the 12
which person below is an entrepreneur?a) a person who writes technical manuals for a computer companyb) a secretary in a law firmc) an artist who runs a busines
Work equal to 136.0 Joules is expanded in moving 8.5*10^18 electrons between two points in an electric circuit. What potential difference does this estabilish b
When a net force of 17.0 newtons is applied to a dictionary placed on a frictionless table, it accelerates by 3.75 meters/secondÆ. What is the mass of the book?
Why does a CPU need Thermal Grease?