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
Speech on inventors and inventions
vlada-n [284]
Interntors present an interesting kind of people who think in peculiar ways sometimes. This ability allows them to view certain situations in ways in which other people cannot. Because of this, they can think of new ways of how such situations can be tackled. This is how inventions are born. A person with an inventive mind sees a new situation where he thinks of a new solution how he could improve this situation with his invention.

This process is continued continuously with new generations of inventors seeing and coming back to old situations over and over again, inventing new things along the way. 
4 0
3 years ago
The Caesar Cipher has 25 different shifts to try.
statuscvo [17]

Answer:

D. 25x24x23x22x21.....3x2x1.

Explanation:

The ceasar cipher is a encryption technique, that uses a combination of information or keys to encrypt an information.

The 25 shift ceasar cipher has 25 different combinations, so the number of probable random cipher substitution is 25!,

That is = 25 × 24×23× 22×..... ×2×1.

3 0
2 years ago
Microsoft PowerPoint is an example of a(n) _____ application.
Daniel [21]

Answer: i'd say utility

Explanation:

3 0
3 years ago
Read 2 more answers
explain in detail how such a company can improve the focus and relationship with customers, and what they will benefit from this
Reil [10]
Advertisement maybe
6 0
3 years ago
Which symbol would be used in a flowchart to represent a connection to another part of the flowchart on the same page
AlekseyPX

Answer:

The answer is "Connectors".

Explanation:

Please find the Connectors image in the attached file.

In this question, the connectors symbol is usually small throughout the flowcharts. It is used as a connection to display and changes throughout the flux. It was usually marked by major letters that indicate jump points. This diagram visually shows the sequence of events in a system and who is accountable.

7 0
2 years ago
Other questions:
  • Never mind I got it
    8·2 answers
  • Which of the following explains the growing need for a standard IT professional licensing program? Check all of the boxes that a
    11·1 answer
  • The basic work area of the computer is it screen that you when you first fire up your computer
    6·1 answer
  • What year did buck tooth bob become famous
    11·2 answers
  • The code below is supposed to display the name and score for the student with the highest score one time before the program ends
    12·1 answer
  • in java how do i Write a Java program that takes ten numbers as input to calculate and print the average of the numbers.
    11·1 answer
  • a rule that states each foreign key value must match a primary key value in the other relation is called the
    5·1 answer
  • Type the correct answer in the box. Spell all words correctly.
    11·2 answers
  • A good CRM should Integrate marketing, sales, and customer support activities measuring and evaluating the process of knowledge
    13·1 answer
  • Online activities among businesses
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!