anonymous
  • anonymous
Ok this function works perfectly, I just need to know how do i make it so it so the random integers that are generated, are written to the mynumbers.txt file. def main(): #Open a file for writing outfile = open ('mynumbers.txt' , 'w') #Generate random integer number from random import randint number = randint(6, 12) print("Write will create", number, "random numbers") import random i = 0 while i < 11: # Get random number in range 10 through 20. n = random.randint(10, 20) print(n) i += 1 main()
Computer Science
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
chestercat
  • chestercat
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
rsmith6559
  • rsmith6559
outfile.write( something ) outfile.close() If you're going to use the code on Windows, Windows still has a "wb" mode of file writing. If I remember correctly, when you read the file, you'll have to convert the numbers to numbers, it will read as a string.

Looking for something else?

Not the answer you are looking for? Search for more explanations.