NEED PYTHON PROGRAM CODE FOR THIS QUESTION
Average of numbers Assume that a file containing a series of integers is named numbers.dat and exists on the computer’s disk. Design a program that calculates the average of all the numbers stored in the file.
try:
with open('numbers.dat') as f:
total, count = 0, 0
for line in f:
words = line.strip().split()
for word in words:
total += int(word)
count += 1
print("Average of all the numbers in numbers.dat is", total / count)
except FileNotFoundError:
print('numbers.dat does not exists!')
NEED PYTHON PROGRAM CODE FOR THIS QUESTION Average of numbers Assume that a file containing a...
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
Question 2: Assume that a text file containing a series of integers is named numbers.txt and exists on the c:Temp. Write a program that reads all of the numbers stored in the file and calculates their total. In order to test this program, you may create a text file using notepad. No GUI is necessary. Name the program number.py
should be in c++
Shire MIS 102 Computer Logic Chagter 10 Fles Assume that a file containing a series of integers is named number dat and exist on the computer's disk Design a program that calculates the average of all the numbers stored in the file. Hint: Your program should contain a loop structure and a EOF to indicate the end of file. Chapter 11 Menu-Oriven Programs Design a program thet can be used to keep all of your friend's...
a. Provide me with your code file, output file and the text file. 1. Create a file with a series of integers. Save it as numbers. txt. Write a program that reads all the numbers and calculates their sum . 2. Create a file having different integers than the first one. Save it as numbers1. txt . Write a program that reads all the number and calculates their average. Important: The two files that you are creating will contain different...
In Python Provide me with your code file, output file and the text file Create a file having different integers than the first one. Save it as numbers1. txt . Write a program that reads all the number and calculates their average. Important: The two files that you are creating will contain different numbers.
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...
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
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
USING PYTHON PROGRAMMING
LANGUAGE
15. Write code to open a file named data.txt, which contains 3 numbers, and print the sum of those numbers to the console 16. Write code that opens a file named words.txt containing an essay, and the prints out the SECOND word in the file to the console
Write a program **(IN C)** that displays all the phone numbers in a file that match the area code that the user is searching for. The program prompts the user to enter the phone number and the name of a file. The program writes the matching phone numbers to the output file. For example, Enter the file name: phone_numbers.txt Enter the area code: 813 Output: encoded words are written to file: 813_phone_numbers.txt The program reads the content of the file...