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
Source code:
pr1.py
import random
f = open("random.txt", "a")
rn = input("How many random numbers you want to enter in file ?
")
rn = int(rn) #
convert string to int
for x in range(rn):
i = random.randint(1,301)
i = str(i)
# convert int to string
f.write(i +'\n')
# write to file line by line
prg2.py
f = open("random.txt", "r")
sumOfNums = 0
count = 0
for num in f:
print(num)
sumOfNums = sumOfNums + int(num)
# convert string to int and add it to
sumOfNums
count = count + 1
# increment count
print("Number of random numbers: %d\n" %count)
print("Sum of random numbers : %d\n" %sumOfNums)
Output:


1.Write a python program that writes a series of random numbers to a file named random.txt....
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 the range 1 through 500. The program should let the user specify how many random numbers to put into the file. The name of the file to write to should be 'random.txt'. Submit the random.txt file generated by your program with the assignment. Sample program execution: Python 3.4.3 Shell Eile Edit...
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...
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
Having some trouble on this Python problem. It has 2 parts. Part 1: Random Number file Writer Write a program that writes a series of random numbers to a file. Each random number should be in the range of 100 through 500. The application should let the user specify how many random numbers the file will hold. sample Outputs Enter the name of the file to which results should be written: ran_numbers_dude.txt Enter the number of random numbers to be...
Description: Create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the name of file, sum of numbers, count of numbers, average of numbers, maximum value, minimum value, and range of values. Purpose: The purpose of this challenge is to provide experience working with numerical data in a file and generating summary information. Requirements: Create a program called numstat.py that reads a series of integer numbers from a file and determines...
I need help in Python. This is a two step problem So I have the code down, but I am missing some requirements that I am stuck on. Also, I need help verifying the problem is correct.:) 7. Random Number File Writer 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. The application should let the user specify how many random numbers the file...
Write a program that reads a file named input.txt and writes a file that contains the same contents, but is named output.txt. The input file will contain more than one line when I test this. Do not use a path name when opening these files. This means the files should be located in the top level folder of the project. Do not use a copy method that is supplied by Java. Your program must read the file line by line...
a file containing a series of integers is named numbers.txt. Write a Python program that calculates the average of all the numbers stored in the file. Sample Run 49.6
PYTHON write a program that will open a file named data.txt and read each line of the file one at a time. Each line should be printed to the screen along with a line number
I need help writing these 2 programs please include all the indents :) In this programming challenge you are to create two Python programs: randomwrite.py andrandomread.py. One program, randomwrite.py, is to write a set of random numbers to a file. The second program, randomread.py, is to read a set of random numbers from a file, counts how many were read, displays the random numbers, and displays the total count of random numbers. Random Number File Writer (randomwrite.py) Create a program...