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
What is computer generation​
MA_775_DIABLO [31]

Answer:

Generation in computer terminology is a change in technology a computer is/was being used which includes hardware and software to make of an entire computer system .

8 0
2 years ago
The trim video feature allows you to trim your clip by time measurements that are accurate to ____ of a second.
grigory [225]
The trim video feature allows you to trim your clip by time measurements that are accurate to one-thousandth of a second.  An example would be the P<span>owerPoint's </span>Trim Video feature which allows you<span> to </span>trim<span> the beginning and end of </span>your clip<span> by designating </span>your<span> desired Start </span>Time<span> and End </span>Time. These precise time measurements<span> are </span>accurate<span> to </span>one-thousandth<span> of a </span>second<span>.</span>
3 0
3 years ago
Add the following binary numbers. 101110010 and 111001101
bonufazy [111]

Answer:

101110010 is 370 in decimal (base 10, what we usually do math in) and 111001101 is 461 in decimal. The sum of 370 and 461 is 831, and 831 is binary is 1100111111. So, if you want the answer in decimal it is \boxed{831_{10}} and if you want the answer in binary, it is \boxed{1100111111_2}.

4 0
3 years ago
Lian's dad uses an interactive machine that allows him
klemol [59]

Answer:

introduction to robotics

Explanation:

just took the test

4 0
3 years ago
Read 2 more answers
What is Tesla BEST know for designing this? ANSWER
Aleonysh [2.5K]

Answer:

  1. tesla coils
  2. tesla
  3. edison
  4. x ray
  5. slinky
  6. time travel
  7. he spent it
  8. blue tooth

Explanation:

3 0
3 years ago
Other questions:
  • What's the difference in unicode value between 'e' and 'a'? (consult a table of unicode values):?
    7·1 answer
  • The united states attempted to halt the communist revolution in cuba by​
    7·1 answer
  • Three healthcare firms jointly own and share the same cloud resources to meet their computing needs. Which cloud model does this
    15·1 answer
  • Which of the following is a professional organization in the field of IT? Society for the Prevention of Cruelty to Animals (SPCA
    6·2 answers
  • When people take a image on their phone how can they copy the image into google docs.
    6·2 answers
  • Your co-worker is at a conference in another state. She requests that you
    9·1 answer
  • What is python?????????
    11·1 answer
  • The fastest way to get help is to type a word or two in the search box.
    7·1 answer
  • PLEASE HELP ASAP<br> Which technology encrypts traffic between a web browser and a website?
    10·2 answers
  • Which of the following can help organize your email messages? Select all that apply.
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!