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
a blank search examines the first item to see if it is a match, then the second, and so on. answers: linear, binary, and orderly
Mazyrski [523]

Answer:

The answer is a linear search

Explanation:

3 0
3 years ago
Read 2 more answers
What type of computer needs a systemthat will take up little space​
egoroff_w [7]

MAC is a computer that needs a system that takes up a little space.

<u>Explanation:</u>

MAC is short for Macintosh Operating System. MAC is developed and owned by Apple Inc.

The MAC operating system is a graphical user interface and supports high-performance graphics. Generally, the MAC is used for designing purposes because of the high multimedia management capabilities.

MAC comes in handy while working on projects that deal with graphics building, and management plus people also make use of MAC in blogging.

7 0
3 years ago
Silvia fue a una revisión odontológica porque tiene problemas de salud en la dentadura y sus cepillos sólo duran dos semanas. Ah
Neko [114]

Answer: ella puede usar un cepillo de dientes eléctrico

8 0
3 years ago
You have just created this algorithm and want to make it less complex without changing its output. What type of function should
Mariulka [41]

Algorithm analysis is an important part of computational complexities. The complexity theory provides the theoretical estimates for the resources needed by an algorithm to solve any computational task. Analysis of the algorithm is the process of analyzing the problem-solving capability of the algorithm in terms of the time and size required

3 0
3 years ago
The highway transportation system<br> has helped
Charra [1.4K]
The Highway Transportation System has helped reduce traffic deaths. The systematic way of controlling the traffic has kept a leash on rash driving and this has definitely helped to reduce the rate of accidents. The presence of Highway transportation System has also helped the country economically.
4 0
3 years ago
Other questions:
  • Machine language is made up of which following codes
    11·1 answer
  • A _____________ is used to make a deep copy of an object.
    6·1 answer
  • Which statement about trees is false?
    12·1 answer
  • What are the tools which are used by search engine ? explain them? ​
    7·1 answer
  • What type of device does a computer turn to first when attempting to make contact with a host with a known IP address on another
    9·2 answers
  • Write an application that inputs three numbers (integer) from a user. (10 pts) UPLOAD Numbers.java a. display user inputs b. det
    10·1 answer
  • What is programming blocks?
    11·1 answer
  • Your company wants to use an IoT device but wants to make sure it does not interfere with other RF devices that use the 2.4 GHz
    12·1 answer
  • A small group of travelers is meeting inside an ancient building, and the travelers need access to the Internet using their mobi
    11·1 answer
  • write a loop that reads positive integers from standard input, printing out those values that are greater than 100, each followe
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!