Question
Please use Python for this program

Random Number File Writer Write a program that writes a series of random numbers to a file. Each random number should be in t
0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE

import random

print("This program writes random numbers to the random.txt file")
n = int(input("How many numbers would you like to write: "))

f = open("random.txt", "a")
for x in range(n):
f.write('%d ' % random.randint(1, 501))

print("%d numbers were written to the random.txt file" % n)

1 import random 3 print(This program writes random numbers to the random.txt file) nint(input (How many numbers would you

Content of random.txt

214
105
486
231
38
221
88
344
294
288
451
196
30
399
457
305
211
286
71
212

Add a comment
Know the answer?
Add Answer to:
Please use Python for this program Random Number File Writer Write a program that writes a...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1.Write a python program that writes a series of random numbers to a file named random.txt....

    1.Write a python program that writes a series of random numbers to a file named random.txt. Each random number should be in the range of 1 through 300. The application should let the user specify how many random numbers the file will hold. 2. Write another program that reads the random numbers from the random.txt file, displays the numbers, then displays the following data: I. The total of the numbers II. The number of random numbers read from the file

  • This assignment assumes you have completed Programming Assignment 6, Random Number File Writer. Write another program...

    This assignment assumes you have completed Programming Assignment 6, Random Number File Writer. Write another program that reads the random numbers from the random.txt file created in Programming Assignment 6, display the numbers, and then display the following data: The total of the numbers. The number of numbers read from the file. Please program in python

  • This is an Introduction to Programming Course It is in Python 3. At one college, the...

    This is an Introduction to Programming Course It is in Python 3. At one college, the tuition for a full-time student is $8,000 per semester. It has been announced that the tuition will increase by 3 percent each year for the next 5 years. Write a program with a loop that displays the projected semester tuition amount for the next 5 years. The program should print out the result in the form: In 1 year, the tuition will be $8240.0....

  • Write a program that writes a series of random numbers to a file. Each random number...

    Write a program that writes a series of random numbers to a file. Each random number should be in the range of 1 through 500 inclusive. 1.Use a file called randoms.txt as a input file and output file a. If you go to open the file and its not there then ask the user to create the file     and then quit 2. Ask the user to specify how many random numbers the file will hold. a.Make sure that the...

  • Don't understand why code isn't running properly Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options...

    Don't understand why code isn't running properly Scottir.UnitB.py D/Python/Scottir UnitB.py (670 File Edit Format Run Options Window Help #Declare a variab i e and initialize it def displayInstructions (1angCode): 3tr . ENGLISHPROMPT = "Please enter your weight in poundョ >> " str.SPANISH PROMPT Por favor entre en su peso en libras > if langCode1: - print ("ENGLISH prompt) print ("SPANISH prompt") print ("Stop") elif langCode2 else: code input ( Enter code for instructions") num code weight = input ("Enter weight...

  • need help with python program The objectives of this lab assignment are as follows: . Input...

    need help with python program The objectives of this lab assignment are as follows: . Input data from user Perform several different calculations Implement conditional logic in loop • Implement logic in functions Output information to user Skills Required To properly complete this assignment, you will need to apply the following skills: . Read string input from the console and convert input to required numeric data-types Understand how to use the Python Modulo Operator Understand the if / elif /...

  • Write a PYTHON program that asks the user for the name of the file. The program...

    Write a PYTHON program that asks the user for the name of the file. The program should write the contents of this input file to an output file. In the output file, each line should be preceded with a line number followed by a colon. The output file will have the same name as the input filename, preceded by “ln” (for linenumbers). Be sure to use Try/except to catch all exceptions. For example, when prompted, if the user specifies “sampleprogram.py”...

  • Write a PYTHON program that reads a file (prompt user for the input file name) containing...

    Write a PYTHON program that reads a file (prompt user for the input file name) containing two columns of floating-point numbers (Use split). Print the average of each column. Use the following data forthe input file: 1   0.5 2   0.5 3   0.5 4   0.5 The output should be:    The averages are 2.50 and 0.5. a)   Your code with comments b)   A screenshot of the execution Version 3.7.2

  • Write a python program that writes to an output file "decoder.txt" a table of letters as...

    Write a python program that writes to an output file "decoder.txt" a table of letters as follows: ___1_2_3_4_5 1: A B C D E 2: F G H I K 3: L M N O P 4: Q R S T U 5: V W X Y Z Note that the letter J has been removed. Use string.ascii_uppercase to start

  • Python 3.x: Write a function typos(fname) that finds suspected typos in the file fname. To do...

    Python 3.x: Write a function typos(fname) that finds suspected typos in the file fname. To do that we need a dictionary, for which we use the file words.txt which is a reasonably complete list of English words (though you may disagree after running it on some sample texts). Any word in fname that is not in the dictionary should be printed, and we should be told how often it occurs in fname. Below I ran a Mark Train novel to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT