Question

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is code:

total = 0

for line in enumerate(open("Q:\cpp\python\file\read\random.txt", 'r')):

total += int(line[1])

print(int(line[1]))

print("Total : ", total)

random.txt:

20
40
66
53
18
55
44
78
99
4
25
22
26
41
88
46
13
85
21
17
16
9
60
30
94
59
37
2
89
41
55
3
3
62
57

Output:

total θ 2 for line in enumerate(open(Q:cpplpython IfilelIread\Irandom.txt, r)) total + int(line[1]) print (int (line[1]))

Add a comment
Know the answer?
Add Answer to:
This assignment assumes you have completed Programming Assignment 6, Random Number File Writer. Write another program...
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
  • Random Number File Reader This exercise assumes you have completed Programming Problem 13, Random Number File...

    Random Number File Reader This exercise assumes you have completed Programming Problem 13, Random Number File Writer . Create another application that uses an OpenFileDialog control to let the user select the file that was created by the application that you wrote for Problem 13. This application should read the numbers from the file, display the numbers in a ListBox control, and then display the following data: • The total of the numbers • The number of random numbers read...

  • Please use Python for this program Random Number File Writer Write a program that writes a...

    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...

  • 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

  • Please help me this problem. Provide the design and codes with pictures also separate answer Than...

    Please help me this problem. Provide the design and codes with pictures also separate answer Thank you Random Number File Reader This exercise assumes you have completed Programming Problem 13, Randorm Number File Writer. Create another application that uses an OpenFileDialog con- trol to let the user select the file that was created by the application that you wrote for Problem 13. This application should read the numbers from the file, display the numbers in a ListBox control, and then...

  • I need help in Python. This is a two step problem So I have the code...

    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...

  • For this assignment you are to create two programming projects. The first should have a project...

    For this assignment you are to create two programming projects. The first should have a project directory with Lab02-2WriteNumbers and the second should have a project directory with Lab02-2ReadNumbers. Lab02-03WriteNumbers – Write a program that asks the user to enter five numbers. Use a double data type to hold the numbers. The program should create a file and save all five numbers to the file. Enter a number (1 of 5): 45 Enter a number (2 0f 5): 23 Enter...

  • Could anyone please help with this Python code assignment? In this programming assignment you are to...

    Could anyone please help with this Python code assignment? In this programming assignment you are to create a program called numstat.py that reads a series of integer numbers from a file and determines and displays the following: The name of the file. The sum of the numbers. The count of how many numbers are in the file. The average of the numbers. The average is the sum of the numbers divided by how many there are. The maximum value. The...

  • I am in C++ programming, I need help with this assignments. The answer in this assignments...

    I am in C++ programming, I need help with this assignments. The answer in this assignments when I look for it it doesn't work in my visual studios. Can you please help me? I hardly have C in the class, if I fail I will fail the whole class and repeat this class again.   The file named Random.txt contains a long list of random numbers. Download the file to your system, then write a program that opens the file, reads...

  • 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...

  • C++ programming please Write a program that will display random numbers in order from low to...

    C++ programming please Write a program that will display random numbers in order from low to high. 1. Declare an integer array of size 100. Ask the user how many numbers to work with (n). It can be less than 100. 2. Generate random numbers from 10 to 50. 3. Write the random numbers to an output file named random.dat. Close the file. 4. Open random.dat for input and read the data values into your array. Pass your array 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