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]
4 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]4 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
I want to discard my old computer and want to securely erase the data from my hard drive what is the process called.
laiz [17]
I believe the process is called High Level Format.
8 0
4 years ago
Read 2 more answers
A group of users in a small publishing office want to share large image files in a common folder with high availability. Which o
mash [69]

Answer:

Network storage appliances

Explanation:

Because I just took a test

7 0
3 years ago
True or false, USBs are slower than RAM.
Zina [86]

Answer:

False

Explanation:

6 0
3 years ago
What is a header and/or a footer? The bolded subtitle for each section or the footnote on any section Text inserted into the top
USPshnik [31]

Answer:

Option B: Text inserted into the top and bottom margins.

is the correct answer.

Explanation:

Header and footer can further be defined as:

  • Data inserted in the top and bottom margin of the page.
  • This data can be the one which you want to display on each page of the document.
  • Header and footer are the optional data.
  • We can add, document name, Author name, page number etc as header and footer.
  • In order to add header and footer, go to the Insert tab.
  • Locate header/ footer group under this tab.
  • All the settings are available and can be modified easily.

i hope it will help you!

4 0
3 years ago
How do you activate the Slicer Tools contextual tab?
Strike441 [17]

Answer:

i need this one too

Explanation:

4 0
3 years ago
Other questions:
  • How to use translate on a website?
    15·1 answer
  • How can improving one’s reasoning skills also improve one’s performance on the job?
    12·2 answers
  • The American Footwear and Apparel Group exerts pressure
    12·1 answer
  • What is this effect in photoshop or photography?
    12·2 answers
  • The university computer lab’s director keeps track of lab usage, as measured by the number of students using the lab. This funct
    11·1 answer
  • Which of the following is considered a white collar crime?
    13·1 answer
  • When you see this traffic signal is turned on, you may _____________________.
    5·2 answers
  • Create ER Models & Normalization for the following scenarios:
    5·1 answer
  • Alicia uses a software application to store the names, email addresses, and phone numbers of her friends in alphabetical order. 
    11·1 answer
  • Reflection image and design
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!