1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
nekit [7.7K]
3 years ago
8

Write code that does the following: opens an output file with the filename number_list.txt, uses a loop to write the numbers 1 t

hrough 100 to the file, then closes the file.
Computers and Technology
1 answer:
Lady_Fox [76]3 years ago
8 0

Answer:

# create the file

filename = "Testfile.txt"

# for writing, we create the output file:

outPutfile = open(filename, "w")

# Writing numbers from 1-100

for item in range(1,101):

 outPutfile.write((str)(item))

outPutfile.close()

# printing the contents to verify it worked correctly

infile = open(filename, "r") #note the "r" indicates the mode

fileContents = infile.read()

infile.close()

print(fileContents)

Explanation:

  • Define the working file fileName = TestFile
  • Create the output file for writting outPutfile = open(filename, "w")
  • Use a for loop to write numbers from 1-100 to the file outPutfile.write((str)(item))
  • Close the file outPutfile.close()
  • You may open the file read its content and print the contents to verify it worked correctly
You might be interested in
What color model should Joe use if he will be using an offset printing press?
EleoNora [17]

Answer:

CMYK

Explanation:

Monitors typically use RGB color (additive model — adding to make white), but offset printing uses CMYK pigments (subtractive color — subtracting from the existing white). Printed images have less visual range, saturation, and contrast than digital images, so in print, colors will usually appear darker and less vibrant.

6 0
2 years ago
Describe software as a service. what features distinguish it from application software installed on a personal computing device
Triss [41]
???????????????????????????
6 0
3 years ago
Read 2 more answers
Which argument forces a writer to return to and change the input before resolving a “UnicodeError”?
garri49 [273]

Answer:

B

Explanation:

3 0
3 years ago
ANYONE WANNA FRIEND ME ON DISCORD ゴRose joestarゴ#2088
Sergeeva-Olga [200]

JOJO fan!?!!?!??!?!?!!?!?

6 0
2 years ago
How does technology influence the development of personal and public identity?
Marysya12 [62]

Answer:

Technology affects the way individuals communicate, learn, and think. It helps society and determines how people interact with each other on a daily basis. Technology plays an important role in society today. It has positive and negative effects on the world and it impacts daily lives.

Hope it's helpful to u

6 0
2 years ago
Other questions:
  • What combination of words and boolean operators would display all audio files about chiropractic?
    6·1 answer
  • Select the correct answer.
    7·2 answers
  • Write a program that takes in a line of text as input, and outputs that line of text in reverse. The program repeats, ending whe
    12·1 answer
  • Plz help ASAP
    10·1 answer
  • Select all the sets that are countably infinite. Question 3 options: the set of real numbers between 0.1 and 0.2 the set of all
    12·1 answer
  • If you delete a shortcut from your desktop, have you also deleted the original file?
    11·2 answers
  • What is GIGO ?<br>plz answer me​
    7·1 answer
  • Please help it’s timed
    13·1 answer
  • In which situation is coauthoring of presentations primarily utilized?
    13·2 answers
  • What is the difference between Brainly.com and Brainly.in? Ive been wondering because im not signed in under Brainly.in.
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!